Add opt-in visible-overlay laser mode setting

This commit is contained in:
baketnk committed 2026-09-24 13:59:45 -04:00
1 parent f80da228b3
commit a9d6762ebd
12 files changed
+225 -28

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
#include "laser_setting.hpp"
#include <cassert>
#include <cstdlib>
#include <filesystem>
#include <fstream>
#include <string>
#include <vector>
int main() {
using namespace frameyap;
const auto pattern = (std::filesystem::temp_directory_path() / "frameyap-laser-test-XXXXXX").string();
std::vector<char> buffer(pattern.begin(), pattern.end());
buffer.push_back('\0');
const char* created = ::mkdtemp(buffer.data());
assert(created);
const std::filesystem::path root(created);
assert(::setenv("XDG_CONFIG_HOME", root.c_str(), 1) == 0);
assert(default_laser_settings_path() == root / "frameyap/lasers-anytime");
const auto path = default_laser_settings_path();
assert(!load_lasers_anytime(path));
assert(save_lasers_anytime(path, true));
assert(load_lasers_anytime(path));
assert((std::filesystem::status(path).permissions() &
(std::filesystem::perms::group_all | std::filesystem::perms::others_all)) == std::filesystem::perms::none);
assert(save_lasers_anytime(path, false));
assert(!load_lasers_anytime(path));
{ std::ofstream out(path, std::ios::trunc); out << "anything else\n"; }
assert(!load_lasers_anytime(path));
const auto link = root / "link";
std::filesystem::create_symlink(path, link);
assert(!load_lasers_anytime(link));
assert(!save_lasers_anytime(link, true));
assert(!load_lasers_anytime(path));
std::filesystem::remove_all(root);
}
+10 -1
View File
@@ -11,7 +11,9 @@ SurfaceEvent click(PanelSurface& surface, float x, float y, unsigned cursor = 0)
surface.pointer_down(cursor, x, y);
return surface.pointer_up(cursor, x, y);
}
void no_action(const SurfaceEvent& event) { assert(!event.action && !event.mount && !event.recenter); }
void no_action(const SurfaceEvent& event) {
assert(!event.action && !event.mount && !event.lasers_anytime && !event.recenter);
}
void snapshot(PanelSurface& surface, const std::string& path) {
std::ofstream out(path, std::ios::binary);
assert(out);
@@ -104,6 +106,12 @@ int main(int argc, char** argv) {
assert(click(surface, 680, 332).mount == Mount::RightWrist);
assert(click(surface, 680, 260).mount == Mount::Head);
assert(click(surface, 180, 260).mount == Mount::World);
auto laser = click(surface, 680, 420);
assert(laser.lasers_anytime == true && !laser.action && !laser.mount);
surface.set_lasers_anytime(true); assert(surface.render(p));
laser = click(surface, 680, 420);
assert(laser.lasers_anytime == false && !laser.action && !laser.mount);
surface.set_lasers_anytime(false); assert(surface.render(p));
assert(click(surface, 280, 610).action == UiAction::Cancel);
surface.set_placement_note("Wrist not tracked - using world space until it returns.");
assert(surface.render(p)); assert(!surface.render(p));
@@ -114,6 +122,7 @@ int main(int argc, char** argv) {
no_action(click(surface, 100, 160));
no_action(surface.pointer_up(1, 680, 260));
no_action(click(surface, 680, 260)); // mount controls not active on Review
no_action(click(surface, 680, 420)); // laser toggle only exists on Settings
// Long UTF-8, newlines and malformed bytes are bounded, paginated and navigable.
p.transcript.clear();