128 lines
3.8 KiB
C++
128 lines
3.8 KiB
C++
#include "pch.h"
|
|
|
|
#include "legacy_app_preference_services.h"
|
|
|
|
#include "app.h"
|
|
#include "node_canvas.h"
|
|
#include "serializer.h"
|
|
#include "settings.h"
|
|
|
|
namespace pp::panopainter {
|
|
namespace {
|
|
|
|
class LegacyAppPreferenceServices final : public pp::app::AppPreferenceServices {
|
|
public:
|
|
explicit LegacyAppPreferenceServices(App& app) noexcept
|
|
: app_(app)
|
|
{
|
|
}
|
|
|
|
void apply_ui_scale(const pp::app::ScaleApplicationPlan& plan) override
|
|
{
|
|
app_.set_ui_scale(plan.scale);
|
|
}
|
|
|
|
void apply_viewport_scale(const pp::app::ScaleApplicationPlan& plan) override
|
|
{
|
|
if (!app_.canvas)
|
|
return;
|
|
|
|
app_.canvas->set_density(plan.scale);
|
|
Settings::set("vp-scale", Serializer::Float(plan.scale));
|
|
Settings::save();
|
|
}
|
|
|
|
void apply_interface_direction(const pp::app::InterfaceDirectionPlan& plan) override
|
|
{
|
|
app_.set_ui_rtl(plan.direction == pp::app::InterfaceDirection::right_to_left);
|
|
}
|
|
|
|
bool apply_vr_mode_preference(const pp::app::StoredBooleanPreferencePlan& plan) override
|
|
{
|
|
if (plan.value) {
|
|
return app_.vr_start();
|
|
}
|
|
|
|
app_.vr_stop();
|
|
return true;
|
|
}
|
|
|
|
void apply_vr_controllers_preference(const pp::app::StoredBooleanPreferencePlan& plan) override
|
|
{
|
|
app_.vr_controllers_enabled = plan.value;
|
|
Settings::set("vr-controllers-enabled", Serializer::Boolean(plan.value));
|
|
Settings::save();
|
|
}
|
|
|
|
void apply_timelapse_preference(const pp::app::TimelapsePreferencePlan& plan) override
|
|
{
|
|
if (plan.recording_action == pp::app::TimelapseRecordingAction::stop_recording) {
|
|
app_.rec_stop();
|
|
} else if (plan.recording_action == pp::app::TimelapseRecordingAction::start_recording) {
|
|
app_.rec_start();
|
|
}
|
|
|
|
Settings::set("auto-timelapse", Serializer::Boolean(plan.enabled));
|
|
Settings::save();
|
|
}
|
|
|
|
void apply_canvas_cursor_mode(const pp::app::StoredIntegerPreferencePlan& plan) override
|
|
{
|
|
if (!app_.canvas)
|
|
return;
|
|
|
|
app_.canvas->set_cursor_visibility(static_cast<NodeCanvas::kCursorVisibility>(plan.value));
|
|
Settings::set("show-cursor", Serializer::Integer(plan.value));
|
|
Settings::save();
|
|
}
|
|
|
|
private:
|
|
App& app_;
|
|
};
|
|
|
|
} // namespace
|
|
|
|
pp::foundation::Status execute_legacy_ui_scale_preference(App& app, float requested_scale)
|
|
{
|
|
LegacyAppPreferenceServices services(app);
|
|
return pp::app::execute_ui_scale_preference(requested_scale, app.display_density, services);
|
|
}
|
|
|
|
pp::foundation::Status execute_legacy_viewport_scale_preference(App& app, float requested_scale)
|
|
{
|
|
LegacyAppPreferenceServices services(app);
|
|
return pp::app::execute_viewport_scale_preference(requested_scale, 1.0F, services);
|
|
}
|
|
|
|
pp::foundation::Status execute_legacy_interface_direction_preference(App& app, bool right_to_left)
|
|
{
|
|
LegacyAppPreferenceServices services(app);
|
|
return pp::app::execute_interface_direction_preference(right_to_left, services);
|
|
}
|
|
|
|
pp::foundation::Status execute_legacy_vr_mode_preference(App& app, bool enabled)
|
|
{
|
|
LegacyAppPreferenceServices services(app);
|
|
return pp::app::execute_vr_mode_preference(enabled, services);
|
|
}
|
|
|
|
pp::foundation::Status execute_legacy_vr_controllers_preference(App& app, bool enabled)
|
|
{
|
|
LegacyAppPreferenceServices services(app);
|
|
return pp::app::execute_vr_controllers_preference(enabled, services);
|
|
}
|
|
|
|
pp::foundation::Status execute_legacy_timelapse_preference(App& app, bool enabled)
|
|
{
|
|
LegacyAppPreferenceServices services(app);
|
|
return pp::app::execute_timelapse_preference(enabled, app.rec_running, services);
|
|
}
|
|
|
|
pp::foundation::Status execute_legacy_canvas_cursor_mode_preference(App& app, int mode)
|
|
{
|
|
LegacyAppPreferenceServices services(app);
|
|
return pp::app::execute_canvas_cursor_mode_preference(mode, services);
|
|
}
|
|
|
|
} // namespace pp::panopainter
|