Extract draw toolbar and thin NodeCanvas and Win32 shell
This commit is contained in:
@@ -10,15 +10,12 @@
|
||||
#include "app_core/about_menu.h"
|
||||
#include "app_core/app_preferences.h"
|
||||
#include "app_core/brush_ui.h"
|
||||
#include "app_core/canvas_tool_ui.h"
|
||||
#include "app_core/document_layer.h"
|
||||
#include "app_core/document_canvas.h"
|
||||
#include "app_core/app_status.h"
|
||||
#include "app_core/tools_menu.h"
|
||||
#include "legacy_app_preference_services.h"
|
||||
#include "legacy_app_shell_services.h"
|
||||
#include "legacy_brush_ui_services.h"
|
||||
#include "legacy_canvas_tool_services.h"
|
||||
#include "legacy_document_layer_services.h"
|
||||
#include "legacy_preference_storage.h"
|
||||
#include "font.h"
|
||||
@@ -38,21 +35,6 @@ void bind_legacy_tools_menu(App& app);
|
||||
|
||||
namespace {
|
||||
|
||||
bool apply_brush_color_plan(App& app, glm::vec4 color, bool update_quick, bool update_color_panel)
|
||||
{
|
||||
return pp::panopainter::apply_legacy_brush_color_plan(app, color, update_quick, update_color_panel);
|
||||
}
|
||||
|
||||
bool apply_brush_texture_plan(App& app, pp::app::BrushUiTextureSlot slot, const std::string& path, const std::string& thumb)
|
||||
{
|
||||
return pp::panopainter::apply_legacy_brush_texture_plan(app, slot, path, thumb);
|
||||
}
|
||||
|
||||
bool apply_brush_preset_plan(App& app, const std::shared_ptr<Brush>& brush)
|
||||
{
|
||||
return pp::panopainter::apply_legacy_brush_preset_plan(app, brush);
|
||||
}
|
||||
|
||||
[[nodiscard]] bool should_open_tools_panel(const pp::app::ToolsPanelPlan& plan) noexcept
|
||||
{
|
||||
return plan.action == pp::app::ToolsPanelAction::open_floating_panel;
|
||||
@@ -112,64 +94,6 @@ void App::init_toolbar_main()
|
||||
pp::panopainter::bind_legacy_main_toolbar(*this);
|
||||
}
|
||||
|
||||
[[nodiscard]] bool current_canvas_mode_is_draw(App& app) noexcept
|
||||
{
|
||||
return app.canvas && app.canvas->m_canvas && app.canvas->m_canvas->m_current_mode == kCanvasMode::Draw;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void execute_canvas_tool_toolbar_binding(
|
||||
App& app,
|
||||
const pp::app::CanvasToolToolbarBinding& binding,
|
||||
T* button)
|
||||
{
|
||||
const auto plan = pp::app::plan_canvas_tool_toolbar_binding_action(
|
||||
binding,
|
||||
current_canvas_mode_is_draw(app));
|
||||
const auto status = binding.action == pp::app::CanvasToolToolbarAction::select_mode
|
||||
? pp::panopainter::execute_legacy_canvas_tool_plan(app, plan, button)
|
||||
: pp::panopainter::execute_legacy_canvas_tool_plan(app, plan);
|
||||
if (!status.ok())
|
||||
LOG("Canvas toolbar action failed: %s", status.message);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void bind_canvas_tool_toolbar_button(
|
||||
App& app,
|
||||
const pp::app::CanvasToolToolbarBinding& binding,
|
||||
T* button)
|
||||
{
|
||||
button->on_click = [&app, binding, button](Node*) {
|
||||
execute_canvas_tool_toolbar_binding(app, binding, button);
|
||||
};
|
||||
}
|
||||
|
||||
void App::init_toolbar_draw()
|
||||
{
|
||||
const auto toolbar = pp::app::plan_canvas_tool_toolbar();
|
||||
bool apply_default_tool = false;
|
||||
for (const auto& binding : toolbar.bindings) {
|
||||
if (binding.custom_button) {
|
||||
if (auto* button = layout[main_id]->find<NodeButtonCustom>(binding.button_id.data())) {
|
||||
bind_canvas_tool_toolbar_button(*this, binding, button);
|
||||
apply_default_tool = apply_default_tool || binding.applies_default_on_init;
|
||||
}
|
||||
} else {
|
||||
if (auto* button = layout[main_id]->find<NodeButton>(binding.button_id.data())) {
|
||||
bind_canvas_tool_toolbar_button(*this, binding, button);
|
||||
apply_default_tool = apply_default_tool || binding.applies_default_on_init;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (apply_default_tool) {
|
||||
const auto default_plan = pp::app::plan_canvas_tool_select(toolbar.default_mode);
|
||||
const auto status = pp::panopainter::execute_legacy_canvas_tool_plan(*this, default_plan);
|
||||
if (!status.ok())
|
||||
LOG("Canvas default tool action failed: %s", status.message);
|
||||
}
|
||||
}
|
||||
|
||||
void App::init_menu_file()
|
||||
{
|
||||
pp::panopainter::bind_legacy_file_menu(*this);
|
||||
|
||||
Reference in New Issue
Block a user