Add quick panel service boundary
This commit is contained in:
@@ -21,6 +21,8 @@ struct QuickUiPlan {
|
||||
QuickUiSlotKind slot_kind = QuickUiSlotKind::brush;
|
||||
int slot_index = 0;
|
||||
int previous_index = 0;
|
||||
int brush_index = 0;
|
||||
int color_index = 0;
|
||||
int slot_count = 0;
|
||||
bool fire_event = false;
|
||||
bool updates_selection = false;
|
||||
@@ -33,6 +35,16 @@ struct QuickUiPlan {
|
||||
bool mutates_quick_state = false;
|
||||
};
|
||||
|
||||
class QuickUiServices {
|
||||
public:
|
||||
virtual ~QuickUiServices() = default;
|
||||
|
||||
virtual void select_slot(QuickUiSlotKind slot_kind, int slot_index, bool fire_event) = 0;
|
||||
virtual void open_slot_popup(QuickUiSlotKind slot_kind, int slot_index) = 0;
|
||||
virtual void restore_state(int brush_index, int color_index, bool fire_event) = 0;
|
||||
virtual void reset_state(bool fire_event) = 0;
|
||||
};
|
||||
|
||||
[[nodiscard]] inline pp::foundation::Status validate_quick_slot_count(int slot_count) noexcept
|
||||
{
|
||||
if (slot_count <= 0) {
|
||||
@@ -76,6 +88,8 @@ struct QuickUiPlan {
|
||||
plan.slot_kind = slot_kind;
|
||||
plan.slot_index = clicked_index;
|
||||
plan.previous_index = current_index;
|
||||
plan.brush_index = slot_kind == QuickUiSlotKind::brush ? clicked_index : 0;
|
||||
plan.color_index = slot_kind == QuickUiSlotKind::color ? clicked_index : 0;
|
||||
plan.slot_count = slot_count;
|
||||
if (clicked_index != current_index) {
|
||||
plan.operation = QuickUiOperation::select_slot;
|
||||
@@ -109,6 +123,8 @@ struct QuickUiPlan {
|
||||
|
||||
QuickUiPlan plan;
|
||||
plan.operation = QuickUiOperation::restore_state;
|
||||
plan.brush_index = brush_index;
|
||||
plan.color_index = color_index;
|
||||
plan.slot_count = slot_count;
|
||||
plan.fire_event = fire_event;
|
||||
plan.updates_selection = true;
|
||||
@@ -130,6 +146,8 @@ struct QuickUiPlan {
|
||||
|
||||
QuickUiPlan plan;
|
||||
plan.operation = QuickUiOperation::reset_state;
|
||||
plan.brush_index = 0;
|
||||
plan.color_index = 0;
|
||||
plan.slot_count = slot_count;
|
||||
plan.fire_event = fire_event;
|
||||
plan.updates_selection = true;
|
||||
@@ -140,4 +158,72 @@ struct QuickUiPlan {
|
||||
return pp::foundation::Result<QuickUiPlan>::success(plan);
|
||||
}
|
||||
|
||||
[[nodiscard]] inline pp::foundation::Status execute_quick_ui_plan(
|
||||
const QuickUiPlan& plan,
|
||||
QuickUiServices& services)
|
||||
{
|
||||
switch (plan.operation) {
|
||||
case QuickUiOperation::select_slot:
|
||||
if (!plan.updates_selection) {
|
||||
return pp::foundation::Status::invalid_argument("quick select plan must update selection");
|
||||
}
|
||||
{
|
||||
const auto status = validate_quick_slot_index(plan.slot_index, plan.slot_count);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
services.select_slot(plan.slot_kind, plan.slot_index, plan.invokes_change_callback);
|
||||
return pp::foundation::Status::success();
|
||||
|
||||
case QuickUiOperation::open_slot_popup:
|
||||
if (plan.slot_kind == QuickUiSlotKind::brush && !plan.opens_brush_popup) {
|
||||
return pp::foundation::Status::invalid_argument("quick brush popup plan must open brush popup");
|
||||
}
|
||||
if (plan.slot_kind == QuickUiSlotKind::color && !plan.opens_color_picker) {
|
||||
return pp::foundation::Status::invalid_argument("quick color popup plan must open color picker");
|
||||
}
|
||||
{
|
||||
const auto status = validate_quick_slot_index(plan.slot_index, plan.slot_count);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
services.open_slot_popup(plan.slot_kind, plan.slot_index);
|
||||
return pp::foundation::Status::success();
|
||||
|
||||
case QuickUiOperation::restore_state:
|
||||
if (!plan.restores_slots) {
|
||||
return pp::foundation::Status::invalid_argument("quick restore plan must restore slots");
|
||||
}
|
||||
{
|
||||
const auto brush_status = validate_quick_slot_index(plan.brush_index, plan.slot_count);
|
||||
if (!brush_status.ok()) {
|
||||
return brush_status;
|
||||
}
|
||||
const auto color_status = validate_quick_slot_index(plan.color_index, plan.slot_count);
|
||||
if (!color_status.ok()) {
|
||||
return color_status;
|
||||
}
|
||||
}
|
||||
services.restore_state(plan.brush_index, plan.color_index, plan.fire_event);
|
||||
return pp::foundation::Status::success();
|
||||
|
||||
case QuickUiOperation::reset_state:
|
||||
if (!plan.resets_slots) {
|
||||
return pp::foundation::Status::invalid_argument("quick reset plan must reset slots");
|
||||
}
|
||||
{
|
||||
const auto status = validate_quick_slot_count(plan.slot_count);
|
||||
if (!status.ok()) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
services.reset_state(plan.fire_event);
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
return pp::foundation::Status::invalid_argument("unknown quick UI operation");
|
||||
}
|
||||
|
||||
} // namespace pp::app
|
||||
|
||||
@@ -5,6 +5,194 @@
|
||||
#include "node_image.h"
|
||||
#include "app.h"
|
||||
|
||||
namespace {
|
||||
|
||||
class LegacyQuickUiServices final : public pp::app::QuickUiServices {
|
||||
public:
|
||||
LegacyQuickUiServices(NodePanelQuick& panel, const NodePanelQuick::MiniState* restore_state = nullptr) noexcept
|
||||
: panel_(panel)
|
||||
, restore_state_(restore_state)
|
||||
{
|
||||
}
|
||||
|
||||
void select_slot(pp::app::QuickUiSlotKind slot_kind, int slot_index, bool fire_event) override
|
||||
{
|
||||
if (slot_kind == pp::app::QuickUiSlotKind::brush) {
|
||||
panel_.set_selected_brush_index(slot_index, fire_event);
|
||||
return;
|
||||
}
|
||||
|
||||
panel_.set_selected_color_index(slot_index, fire_event);
|
||||
}
|
||||
|
||||
void open_slot_popup(pp::app::QuickUiSlotKind slot_kind, int slot_index) override
|
||||
{
|
||||
if (slot_kind == pp::app::QuickUiSlotKind::brush) {
|
||||
open_brush_popup(slot_index);
|
||||
return;
|
||||
}
|
||||
|
||||
open_color_picker(slot_index);
|
||||
}
|
||||
|
||||
void restore_state(int brush_index, int color_index, bool fire_event) override
|
||||
{
|
||||
if (!restore_state_)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < static_cast<int>(panel_.m_button_brushes.size()); i++)
|
||||
{
|
||||
auto b = static_cast<NodeStrokePreview*>(panel_.m_button_brushes[i]->m_children[0].get());
|
||||
b->m_brush = restore_state_->brushes[i];
|
||||
b->draw_stroke();
|
||||
auto c = static_cast<NodeBorder*>(panel_.m_button_colors[i]->m_children[0].get());
|
||||
c->m_color = restore_state_->colors[i];
|
||||
}
|
||||
panel_.set_selected_color_index(color_index, fire_event);
|
||||
panel_.set_selected_brush_index(brush_index, fire_event);
|
||||
}
|
||||
|
||||
void reset_state(bool fire_event) override
|
||||
{
|
||||
for (int i = 0; i < static_cast<int>(panel_.m_button_brushes.size()); i++)
|
||||
{
|
||||
auto b = static_cast<NodeStrokePreview*>(panel_.m_button_brushes[i]->m_children[0].get());
|
||||
b->m_brush = std::make_shared<Brush>();
|
||||
b->m_brush->load_tip("data/brushes/Round-Hard.png", "data/brushes/thumbs/Round-Hard.png");
|
||||
b->draw_stroke();
|
||||
}
|
||||
static_cast<NodeBorder*>(panel_.m_button_colors[0]->m_children[0].get())->m_color = glm::vec4(0, 0, 0, 1);
|
||||
static_cast<NodeBorder*>(panel_.m_button_colors[1]->m_children[0].get())->m_color = glm::vec4(.5, .5, .5, 1);
|
||||
static_cast<NodeBorder*>(panel_.m_button_colors[2]->m_children[0].get())->m_color = glm::vec4(1, 1, 1, 1);
|
||||
panel_.set_selected_brush_index(0, fire_event);
|
||||
panel_.set_selected_color_index(0, fire_event);
|
||||
}
|
||||
|
||||
private:
|
||||
void open_brush_popup(int slot_index)
|
||||
{
|
||||
auto button = panel_.m_button_brushes[slot_index];
|
||||
if (!button)
|
||||
return;
|
||||
|
||||
auto popup = App::I->presets;
|
||||
auto screen = panel_.root()->m_size;
|
||||
glm::vec2 tick_sz = { 16, 32 };
|
||||
glm::vec2 tick_pos = button->m_pos + glm::vec2(button->m_size.x, 0);
|
||||
glm::vec2 popup_pos = { tick_pos.x + tick_sz.x, tick_pos.y };
|
||||
|
||||
auto tick = panel_.root()->add_child<NodeImage>();
|
||||
tick->SetPositioning(YGPositionTypeAbsolute);
|
||||
tick->SetPosition(tick_pos.x, tick_pos.y + (button->m_size.y - tick_sz.y) * 0.5f);
|
||||
tick->SetSize(tick_sz);
|
||||
tick->set_image("data/ui/popup-tick.png");
|
||||
tick->m_scale = { 1, 1 };
|
||||
|
||||
float hh = popup->m_container->m_children.size() > 10 ? (screen.y - 90.f) : 400.f;
|
||||
popup->SetWidth(350);
|
||||
popup->SetHeight(glm::max(hh, 400.f));
|
||||
popup->SetPositioning(YGPositionTypeAbsolute);
|
||||
popup->SetPosition(popup_pos);
|
||||
panel_.root()->add_child(popup);
|
||||
|
||||
panel_.root()->update();
|
||||
popup->tick(0);
|
||||
popup->update();
|
||||
|
||||
if (tick_pos.x + popup->m_size.x > screen.x)
|
||||
{
|
||||
tick_pos = button->m_pos - glm::vec2(tick_sz.x, 0);
|
||||
popup_pos = { tick_pos.x - popup->GetWidth(), tick_pos.y };
|
||||
tick->m_scale.x = -1.f;
|
||||
}
|
||||
popup_pos = glm::clamp(popup_pos, { 0, 0 }, screen - popup->m_size);
|
||||
popup->SetPosition(popup_pos);
|
||||
tick->SetPosition(tick_pos.x, tick_pos.y + (button->m_size.y - tick_sz.y) * 0.5f);
|
||||
popup->update();
|
||||
|
||||
popup->m_mouse_ignore = false;
|
||||
popup->m_flood_events = true;
|
||||
popup->m_capture_children = false;
|
||||
popup->mouse_capture();
|
||||
|
||||
popup->on_popup_close = [tick](Node*) {
|
||||
tick->destroy();
|
||||
};
|
||||
|
||||
auto* panel = &panel_;
|
||||
popup->on_brush_changed = [panel, button](Node*, std::shared_ptr<Brush>& b) {
|
||||
auto pr = static_cast<NodeStrokePreview*>(button->m_children[0].get());
|
||||
*pr->m_brush = *b;
|
||||
pr->m_brush->load();
|
||||
pr->draw_stroke();
|
||||
if (panel->on_brush_change)
|
||||
panel->on_brush_change(button, pr->m_brush);
|
||||
};
|
||||
}
|
||||
|
||||
void open_color_picker(int slot_index)
|
||||
{
|
||||
auto target = panel_.m_button_colors[slot_index];
|
||||
if (!target)
|
||||
return;
|
||||
|
||||
auto popup = panel_.m_picker;
|
||||
auto screen = panel_.root()->m_size;
|
||||
glm::vec2 tick_sz = { 16, 32 };
|
||||
glm::vec2 tick_pos = target->m_pos + glm::vec2(target->m_size.x, 0);
|
||||
glm::vec2 popup_pos = { tick_pos.x + tick_sz.x, tick_pos.y - 140.f };
|
||||
|
||||
auto tick = panel_.root()->add_child<NodeImage>();
|
||||
tick->SetPositioning(YGPositionTypeAbsolute);
|
||||
tick->SetPosition(tick_pos.x, tick_pos.y + (target->m_size.y - tick_sz.y) * 0.5f);
|
||||
tick->SetSize(tick_sz);
|
||||
tick->set_image("data/ui/popup-tick.png");
|
||||
tick->m_scale = { 1, 1 };
|
||||
|
||||
popup->SetPositioning(YGPositionTypeAbsolute);
|
||||
popup->SetPosition(popup_pos);
|
||||
panel_.root()->add_child(popup);
|
||||
|
||||
panel_.root()->update();
|
||||
popup->tick(0);
|
||||
popup->update();
|
||||
|
||||
if (tick_pos.x + popup->m_size.x > screen.x)
|
||||
{
|
||||
tick_pos = target->m_pos - glm::vec2(tick_sz.x, 0);
|
||||
popup_pos = { tick_pos.x - popup->GetWidth(), tick_pos.y - 140.f };
|
||||
tick->m_scale.x = -1.f;
|
||||
}
|
||||
popup_pos = glm::clamp(popup_pos, { 0, 0 }, screen - popup->m_size);
|
||||
popup->SetPosition(popup_pos);
|
||||
tick->SetPosition(tick_pos.x, tick_pos.y + (target->m_size.y - tick_sz.y) * 0.5f);
|
||||
popup->update();
|
||||
|
||||
popup->m_mouse_ignore = false;
|
||||
popup->m_flood_events = true;
|
||||
popup->m_capture_children = false;
|
||||
popup->mouse_capture();
|
||||
|
||||
auto c = static_cast<NodeBorder*>(target->m_children[0].get());
|
||||
panel_.m_picker->set_color(c->m_color);
|
||||
panel_.m_picker->on_popup_close = [tick](Node*) {
|
||||
tick->destroy();
|
||||
};
|
||||
|
||||
auto* panel = &panel_;
|
||||
panel_.m_picker->on_color_change = [panel, c](Node*, glm::vec3 rgb) {
|
||||
c->m_color = glm::vec4(rgb, 1.f);
|
||||
if (panel->on_color_change)
|
||||
panel->on_color_change(panel, rgb);
|
||||
};
|
||||
}
|
||||
|
||||
NodePanelQuick& panel_;
|
||||
const NodePanelQuick::MiniState* restore_state_ = nullptr;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
Node* NodePanelQuick::clone_instantiate() const
|
||||
{
|
||||
return new this_class;
|
||||
@@ -90,16 +278,10 @@ void NodePanelQuick::set_state(const MiniState& state, bool fire_event /*= false
|
||||
if (!plan)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
auto b = static_cast<NodeStrokePreview*>(m_button_brushes[i]->m_children[0].get());
|
||||
b->m_brush = state.brushes[i];
|
||||
b->draw_stroke();
|
||||
auto c = static_cast<NodeBorder*>(m_button_colors[i]->m_children[0].get());
|
||||
c->m_color = state.colors[i];
|
||||
}
|
||||
set_selected_color_index(state.color_index, fire_event);
|
||||
set_selected_brush_index(state.brush_index, fire_event);
|
||||
LegacyQuickUiServices services(*this, &state);
|
||||
const auto status = pp::app::execute_quick_ui_plan(plan.value(), services);
|
||||
if (!status.ok())
|
||||
LOG("Quick restore action failed: %s", status.message);
|
||||
}
|
||||
|
||||
void NodePanelQuick::reset_state(bool fire_event /*= false*/)
|
||||
@@ -108,18 +290,10 @@ void NodePanelQuick::reset_state(bool fire_event /*= false*/)
|
||||
if (!plan)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
auto b = static_cast<NodeStrokePreview*>(m_button_brushes[i]->m_children[0].get());
|
||||
b->m_brush = std::make_shared<Brush>();
|
||||
b->m_brush->load_tip("data/brushes/Round-Hard.png", "data/brushes/thumbs/Round-Hard.png");
|
||||
b->draw_stroke();
|
||||
}
|
||||
static_cast<NodeBorder*>(m_button_colors[0]->m_children[0].get())->m_color = glm::vec4(0, 0, 0, 1);
|
||||
static_cast<NodeBorder*>(m_button_colors[1]->m_children[0].get())->m_color = glm::vec4(.5, .5, .5, 1);
|
||||
static_cast<NodeBorder*>(m_button_colors[2]->m_children[0].get())->m_color = glm::vec4(1, 1, 1, 1);
|
||||
set_selected_brush_index(0, fire_event);
|
||||
set_selected_color_index(0, fire_event);
|
||||
LegacyQuickUiServices services(*this);
|
||||
const auto status = pp::app::execute_quick_ui_plan(plan.value(), services);
|
||||
if (!status.ok())
|
||||
LOG("Quick reset action failed: %s", status.message);
|
||||
}
|
||||
|
||||
void NodePanelQuick::init_controls()
|
||||
@@ -226,73 +400,10 @@ void NodePanelQuick::handle_button_brush_click(Node* button)
|
||||
if (!plan)
|
||||
return;
|
||||
|
||||
if (plan.value().updates_selection)
|
||||
{
|
||||
auto b = static_cast<NodeButtonCustom*>(button);
|
||||
b->set_active(true);
|
||||
m_button_brush_current->set_active(false);
|
||||
m_button_brush_current = b;
|
||||
m_button_brush_current_preview = static_cast<NodeStrokePreview*>(button->m_children[0].get());
|
||||
if (on_brush_change)
|
||||
on_brush_change(this, m_button_brush_current_preview->m_brush);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!plan.value().opens_brush_popup)
|
||||
return;
|
||||
|
||||
auto popup = App::I->presets;
|
||||
auto screen = root()->m_size;
|
||||
glm::vec2 tick_sz = { 16, 32 };
|
||||
glm::vec2 tick_pos = button->m_pos + glm::vec2(button->m_size.x, 0);
|
||||
glm::vec2 popup_pos = { tick_pos.x + tick_sz.x, tick_pos.y };
|
||||
|
||||
auto tick = root()->add_child<NodeImage>();
|
||||
tick->SetPositioning(YGPositionTypeAbsolute);
|
||||
tick->SetPosition(tick_pos.x, tick_pos.y + (button->m_size.y - tick_sz.y) * 0.5f);
|
||||
tick->SetSize(tick_sz);
|
||||
tick->set_image("data/ui/popup-tick.png");
|
||||
tick->m_scale = { 1, 1 };
|
||||
|
||||
float hh = popup->m_container->m_children.size() > 10 ? (screen.y - 90.f) : 400.f;
|
||||
popup->SetWidth(350);
|
||||
popup->SetHeight(glm::max(hh, 400.f));
|
||||
popup->SetPositioning(YGPositionTypeAbsolute);
|
||||
popup->SetPosition(popup_pos);
|
||||
root()->add_child(popup);
|
||||
|
||||
root()->update();
|
||||
popup->tick(0);
|
||||
popup->update();
|
||||
|
||||
if (tick_pos.x + popup->m_size.x > screen.x)
|
||||
{
|
||||
tick_pos = button->m_pos - glm::vec2(tick_sz.x, 0);
|
||||
popup_pos = { tick_pos.x - popup->GetWidth(), tick_pos.y };
|
||||
tick->m_scale.x = -1.f;
|
||||
}
|
||||
popup_pos = glm::clamp(popup_pos, { 0, 0 }, screen - popup->m_size);
|
||||
popup->SetPosition(popup_pos);
|
||||
tick->SetPosition(tick_pos.x, tick_pos.y + (button->m_size.y - tick_sz.y) * 0.5f);
|
||||
popup->update();
|
||||
|
||||
popup->m_mouse_ignore = false;
|
||||
popup->m_flood_events = true;
|
||||
popup->m_capture_children = false;
|
||||
popup->mouse_capture();
|
||||
|
||||
popup->on_popup_close = [this, tick](Node*) {
|
||||
tick->destroy();
|
||||
};
|
||||
|
||||
popup->on_brush_changed = [this, button](Node* target, std::shared_ptr<Brush>& b) {
|
||||
auto pr = static_cast<NodeStrokePreview*>(button->m_children[0].get());
|
||||
*pr->m_brush = *b;
|
||||
pr->m_brush->load();
|
||||
pr->draw_stroke();
|
||||
if (on_brush_change)
|
||||
on_brush_change(button, pr->m_brush);
|
||||
};
|
||||
LegacyQuickUiServices services(*this);
|
||||
const auto status = pp::app::execute_quick_ui_plan(plan.value(), services);
|
||||
if (!status.ok())
|
||||
LOG("Quick brush action failed: %s", status.message);
|
||||
}
|
||||
|
||||
void NodePanelQuick::handle_button_color_click(Node* target)
|
||||
@@ -307,68 +418,8 @@ void NodePanelQuick::handle_button_color_click(Node* target)
|
||||
if (!plan)
|
||||
return;
|
||||
|
||||
if (plan.value().updates_selection)
|
||||
{
|
||||
auto button = static_cast<NodeButtonCustom*>(target);
|
||||
button->set_active(true);
|
||||
m_button_color_current->set_active(false);
|
||||
m_button_color_current = button;
|
||||
m_button_color_current_inner = static_cast<NodeBorder*>(m_button_color_current->m_children[0].get());
|
||||
if (on_color_change)
|
||||
on_color_change(this, m_button_color_current_inner->m_color);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!plan.value().opens_color_picker)
|
||||
return;
|
||||
|
||||
auto popup = m_picker;
|
||||
auto screen = root()->m_size;
|
||||
glm::vec2 tick_sz = { 16, 32 };
|
||||
glm::vec2 tick_pos = target->m_pos + glm::vec2(target->m_size.x, 0);
|
||||
glm::vec2 popup_pos = { tick_pos.x + tick_sz.x, tick_pos.y - 140.f };
|
||||
|
||||
auto tick = root()->add_child<NodeImage>();
|
||||
tick->SetPositioning(YGPositionTypeAbsolute);
|
||||
tick->SetPosition(tick_pos.x, tick_pos.y + (target->m_size.y - tick_sz.y) * 0.5f);
|
||||
tick->SetSize(tick_sz);
|
||||
tick->set_image("data/ui/popup-tick.png");
|
||||
tick->m_scale = { 1, 1 };
|
||||
|
||||
//float hh = popup->m_container->m_children.size() > 10 ? (screen.y / App::I->zoom - 90.f) : 400.f;
|
||||
//popup->SetHeight(glm::max(hh, 400.f));
|
||||
popup->SetPositioning(YGPositionTypeAbsolute);
|
||||
popup->SetPosition(popup_pos);
|
||||
root()->add_child(popup);
|
||||
|
||||
root()->update();
|
||||
popup->tick(0);
|
||||
popup->update();
|
||||
|
||||
if (tick_pos.x + popup->m_size.x > screen.x)
|
||||
{
|
||||
tick_pos = target->m_pos - glm::vec2(tick_sz.x, 0);
|
||||
popup_pos = { tick_pos.x - popup->GetWidth(), tick_pos.y - 140.f };
|
||||
tick->m_scale.x = -1.f;
|
||||
}
|
||||
popup_pos = glm::clamp(popup_pos, { 0, 0 }, screen - popup->m_size);
|
||||
popup->SetPosition(popup_pos);
|
||||
tick->SetPosition(tick_pos.x, tick_pos.y + (target->m_size.y - tick_sz.y) * 0.5f);
|
||||
popup->update();
|
||||
|
||||
popup->m_mouse_ignore = false;
|
||||
popup->m_flood_events = true;
|
||||
popup->m_capture_children = false;
|
||||
popup->mouse_capture();
|
||||
|
||||
auto c = static_cast<NodeBorder*>(target->m_children[0].get());
|
||||
m_picker->set_color(c->m_color);
|
||||
m_picker->on_popup_close = [this, tick](Node*) {
|
||||
tick->destroy();
|
||||
};
|
||||
m_picker->on_color_change = [this, c](Node*, glm::vec3 rgb) {
|
||||
c->m_color = glm::vec4(rgb, 1.f);
|
||||
if (on_color_change)
|
||||
on_color_change(this, rgb);
|
||||
};
|
||||
LegacyQuickUiServices services(*this);
|
||||
const auto status = pp::app::execute_quick_ui_plan(plan.value(), services);
|
||||
if (!status.ok())
|
||||
LOG("Quick color action failed: %s", status.message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user