Extend app input planning to UI state

This commit is contained in:
2026-06-05 06:44:57 +02:00
parent b825d920d2
commit 32c95b224f
8 changed files with 196 additions and 19 deletions

View File

@@ -3,6 +3,7 @@
#include "foundation/result.h"
#include <cmath>
#include <cstddef>
namespace pp::app {
@@ -37,6 +38,17 @@ struct AppKeyDispatchPlan {
bool sync_vr_camera_rotation = false;
};
struct AppUiVisibilityTogglePlan {
bool next_ui_visible = true;
std::size_t first_panel_child_index = 1;
std::size_t panel_child_count = 0;
};
struct AppStylusAttachPlan {
bool set_has_stylus = true;
bool enable_canvas_touch_lock = false;
};
[[nodiscard]] inline pp::foundation::Status validate_input_zoom(float zoom)
{
if (!std::isfinite(zoom) || zoom <= 0.0F) {
@@ -163,4 +175,35 @@ struct AppKeyDispatchPlan {
};
}
[[nodiscard]] inline pp::foundation::Result<AppUiVisibilityTogglePlan> plan_app_ui_visibility_toggle(
bool current_ui_visible,
bool has_main_layout,
std::size_t main_child_count,
std::size_t panel_child_count)
{
if (!has_main_layout) {
return pp::foundation::Result<AppUiVisibilityTogglePlan>::failure(
pp::foundation::Status::invalid_argument("UI toggle requires a main layout"));
}
if (main_child_count <= 1U) {
return pp::foundation::Result<AppUiVisibilityTogglePlan>::failure(
pp::foundation::Status::invalid_argument("UI toggle requires a panel container child"));
}
return pp::foundation::Result<AppUiVisibilityTogglePlan>::success(AppUiVisibilityTogglePlan {
.next_ui_visible = !current_ui_visible,
.first_panel_child_index = 1U,
.panel_child_count = panel_child_count,
});
}
[[nodiscard]] constexpr AppStylusAttachPlan plan_app_stylus_attach(bool has_canvas) noexcept
{
return AppStylusAttachPlan {
.set_has_stylus = true,
.enable_canvas_touch_lock = has_canvas,
};
}
} // namespace pp::app