Centralize legacy canvas tool bridge
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "app_core/canvas_hotkey.h"
|
||||
#include "app_core/canvas_tool_ui.h"
|
||||
#include "app.h"
|
||||
#include "legacy_canvas_tool_services.h"
|
||||
#include "legacy_history_services.h"
|
||||
#include "log.h"
|
||||
#include "node_canvas.h"
|
||||
@@ -70,78 +71,6 @@ pp::paint_renderer::CanvasBlendGatePlan node_canvas_blend_gate_plan(
|
||||
return fallback;
|
||||
}
|
||||
|
||||
class LegacyNodeCanvasToolServices final : public pp::app::CanvasToolServices {
|
||||
public:
|
||||
void select_toolbar_button(pp::app::CanvasToolMode) override
|
||||
{
|
||||
}
|
||||
|
||||
void set_transform_action(pp::app::CanvasToolTransformAction) override
|
||||
{
|
||||
}
|
||||
|
||||
void set_canvas_mode(pp::app::CanvasToolMode mode) override
|
||||
{
|
||||
switch (mode) {
|
||||
case pp::app::CanvasToolMode::draw:
|
||||
Canvas::set_mode(kCanvasMode::Draw);
|
||||
return;
|
||||
case pp::app::CanvasToolMode::erase:
|
||||
Canvas::set_mode(kCanvasMode::Erase);
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void toggle_picking() override
|
||||
{
|
||||
}
|
||||
|
||||
void toggle_touch_lock() override
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class LegacyNodeCanvasHotkeyServices final : public pp::app::CanvasHotkeyServices {
|
||||
public:
|
||||
pp::foundation::Status execute_tool(const pp::app::CanvasToolPlan& plan) override
|
||||
{
|
||||
LegacyNodeCanvasToolServices services;
|
||||
return pp::app::execute_canvas_tool_plan(plan, services);
|
||||
}
|
||||
|
||||
pp::foundation::Status execute_history(const pp::app::HistoryUiPlan& plan) override
|
||||
{
|
||||
return pp::panopainter::execute_legacy_history_plan(plan);
|
||||
}
|
||||
|
||||
void save_document(pp::app::DocumentSaveIntent intent) override
|
||||
{
|
||||
App::I->save_document(intent);
|
||||
}
|
||||
|
||||
void toggle_ui() override
|
||||
{
|
||||
App::I->toggle_ui();
|
||||
}
|
||||
|
||||
void adjust_brush_size(float delta) override
|
||||
{
|
||||
if (!App::I || !App::I->stroke || !App::I->stroke->m_tip_size)
|
||||
return;
|
||||
|
||||
const float value = App::I->stroke->m_tip_size->get_value();
|
||||
const float next_value = glm::clamp<float>(value + delta, 0.0F, 1.0F);
|
||||
App::I->stroke->set_size(next_value, true, true);
|
||||
}
|
||||
|
||||
void show_cursor() override
|
||||
{
|
||||
App::I->show_cursor();
|
||||
}
|
||||
};
|
||||
|
||||
pp::app::CanvasHotkeyKey canvas_hotkey_key(kKey key) noexcept
|
||||
{
|
||||
switch (key) {
|
||||
@@ -181,8 +110,7 @@ pp::app::CanvasHotkeyState canvas_hotkey_state(bool mouse_focused, int touch_fin
|
||||
|
||||
void execute_canvas_hotkey_plan(const pp::app::CanvasHotkeyPlan& plan)
|
||||
{
|
||||
LegacyNodeCanvasHotkeyServices services;
|
||||
const auto status = pp::app::execute_canvas_hotkey_plan(plan, services);
|
||||
const auto status = pp::panopainter::execute_legacy_canvas_hotkey_plan(plan);
|
||||
if (!status.ok())
|
||||
LOG("Canvas hotkey action failed: %s", status.message);
|
||||
}
|
||||
@@ -206,8 +134,7 @@ void run_canvas_hotkey(
|
||||
void run_canvas_tool_mode(pp::app::CanvasToolMode mode)
|
||||
{
|
||||
const auto plan = pp::app::plan_canvas_tool_select(mode);
|
||||
LegacyNodeCanvasToolServices services;
|
||||
const auto status = pp::app::execute_canvas_tool_plan(plan, services);
|
||||
const auto status = pp::panopainter::execute_legacy_canvas_input_tool_plan(plan);
|
||||
if (!status.ok())
|
||||
LOG("Canvas input tool action failed: %s", status.message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user