Route canvas input policy through platform services
This commit is contained in:
@@ -260,6 +260,25 @@ public:
|
||||
++sonarpen_starts;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool draws_canvas_tip_for_pointer(
|
||||
bool is_mouse,
|
||||
bool is_stylus,
|
||||
bool is_left_button_release) override
|
||||
{
|
||||
++canvas_tip_policy_checks;
|
||||
last_canvas_tip_mouse = is_mouse;
|
||||
last_canvas_tip_stylus = is_stylus;
|
||||
last_canvas_tip_left_release = is_left_button_release;
|
||||
return canvas_tip_visible;
|
||||
}
|
||||
|
||||
[[nodiscard]] float adjust_canvas_input_pressure(float pressure) override
|
||||
{
|
||||
++canvas_pressure_adjustments;
|
||||
last_canvas_pressure = pressure;
|
||||
return adjusted_canvas_pressure;
|
||||
}
|
||||
|
||||
[[nodiscard]] pp::platform::PreparedFileTarget prepare_writable_file(
|
||||
std::string_view type,
|
||||
std::string_view default_name,
|
||||
@@ -327,6 +346,8 @@ public:
|
||||
int ppbr_export_data_directory_override_checks = 0;
|
||||
int sonarpen_support_checks = 0;
|
||||
int sonarpen_starts = 0;
|
||||
int canvas_tip_policy_checks = 0;
|
||||
int canvas_pressure_adjustments = 0;
|
||||
int prepare_writable_file_requests = 0;
|
||||
int save_prepared_file_requests = 0;
|
||||
bool cursor_visible = false;
|
||||
@@ -338,9 +359,15 @@ public:
|
||||
bool network_tls_verification_disabled = false;
|
||||
bool ppbr_export_data_directory_override = false;
|
||||
bool sonarpen_supported = false;
|
||||
bool canvas_tip_visible = false;
|
||||
bool last_canvas_tip_mouse = false;
|
||||
bool last_canvas_tip_stylus = false;
|
||||
bool last_canvas_tip_left_release = false;
|
||||
bool deletes_recorded_files = true;
|
||||
bool live_asset_reloading = true;
|
||||
float last_platform_delta = 0.0f;
|
||||
float last_canvas_pressure = 0.0f;
|
||||
float adjusted_canvas_pressure = 0.75f;
|
||||
int last_frame_report = 0;
|
||||
std::string displayed_path;
|
||||
std::string shared_path;
|
||||
@@ -727,6 +754,25 @@ void platform_services_dispatch_sonarpen_policy_and_start(pp::tests::Harness& ha
|
||||
PP_EXPECT(harness, fake.sonarpen_starts == 1);
|
||||
}
|
||||
|
||||
void platform_services_dispatch_canvas_input_policy(pp::tests::Harness& harness)
|
||||
{
|
||||
FakePlatformServices fake("unused");
|
||||
pp::platform::PlatformServices& services = fake;
|
||||
|
||||
PP_EXPECT(harness, !services.draws_canvas_tip_for_pointer(true, false, true));
|
||||
fake.canvas_tip_visible = true;
|
||||
PP_EXPECT(harness, services.draws_canvas_tip_for_pointer(false, true, false));
|
||||
PP_EXPECT(harness, fake.canvas_tip_policy_checks == 2);
|
||||
PP_EXPECT(harness, !fake.last_canvas_tip_mouse);
|
||||
PP_EXPECT(harness, fake.last_canvas_tip_stylus);
|
||||
PP_EXPECT(harness, !fake.last_canvas_tip_left_release);
|
||||
|
||||
const auto pressure = services.adjust_canvas_input_pressure(0.5f);
|
||||
PP_EXPECT(harness, pressure == 0.75f);
|
||||
PP_EXPECT(harness, fake.last_canvas_pressure == 0.5f);
|
||||
PP_EXPECT(harness, fake.canvas_pressure_adjustments == 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main()
|
||||
@@ -762,5 +808,6 @@ int main()
|
||||
"platform services dispatch ppbr export directory policy",
|
||||
platform_services_dispatch_ppbr_export_directory_policy);
|
||||
harness.run("platform services dispatch sonarpen policy and start", platform_services_dispatch_sonarpen_policy_and_start);
|
||||
harness.run("platform services dispatch canvas input policy", platform_services_dispatch_canvas_input_policy);
|
||||
return harness.finish();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user