move presets panel out of stroke panel, implement brush buttons in quick panel
This commit is contained in:
@@ -119,12 +119,11 @@ bool NodePanelStroke::import_abr(const std::string& path)
|
||||
auto brushes = abr.compute_brushes(App::I.data_path);
|
||||
for (const auto& pr : brushes)
|
||||
{
|
||||
auto presets = App::I.stroke->m_presets_popup;
|
||||
async_start();
|
||||
if (pr->valid())
|
||||
{
|
||||
LOG("add preset %s", pr->m_name.c_str());
|
||||
presets->add_brush(pr);
|
||||
App::I.presets->add_brush(pr);
|
||||
}
|
||||
count++;
|
||||
float prog = (float)count / (float)tot;
|
||||
@@ -135,7 +134,7 @@ bool NodePanelStroke::import_abr(const std::string& path)
|
||||
}
|
||||
|
||||
async_start();
|
||||
m_presets_popup->save();
|
||||
App::I.presets->save();
|
||||
pb->destroy();
|
||||
app_redraw();
|
||||
async_update();
|
||||
@@ -265,16 +264,16 @@ void NodePanelStroke::init_controls()
|
||||
m_pattern_popup->m_flood_events = true;
|
||||
m_pattern_popup->m_capture_children = false;
|
||||
|
||||
m_presets_popup = std::make_shared<NodePanelBrushPreset>();
|
||||
m_presets_popup->m_manager = m_manager;
|
||||
m_presets_popup->init();
|
||||
m_presets_popup->create();
|
||||
m_presets_popup->loaded();
|
||||
m_presets_popup->SetPositioning(YGPositionTypeAbsolute);
|
||||
m_presets_popup->SetSize(YGUndefined, 400);
|
||||
m_presets_popup->m_mouse_ignore = false;
|
||||
m_presets_popup->m_flood_events = true;
|
||||
m_presets_popup->m_capture_children = false;
|
||||
//m_presets_popup = std::make_shared<NodePanelBrushPreset>();
|
||||
//m_presets_popup->m_manager = m_manager;
|
||||
//m_presets_popup->init();
|
||||
//m_presets_popup->create();
|
||||
//m_presets_popup->loaded();
|
||||
//m_presets_popup->SetPositioning(YGPositionTypeAbsolute);
|
||||
//m_presets_popup->SetSize(YGUndefined, 400);
|
||||
//m_presets_popup->m_mouse_ignore = false;
|
||||
//m_presets_popup->m_flood_events = true;
|
||||
//m_presets_popup->m_capture_children = false;
|
||||
|
||||
int br_idx = std::max(m_brush_popup->find_brush("Round-Hard"), 0);
|
||||
|
||||
@@ -295,28 +294,32 @@ void NodePanelStroke::init_controls()
|
||||
m_preset_button->on_click = [this](Node*) {
|
||||
auto screen = root()->m_size;
|
||||
glm::vec2 pos = m_preset_button->m_pos + glm::vec2(m_preset_button->m_size.x, 0);
|
||||
root()->add_child(m_presets_popup);
|
||||
root()->add_child(App::I.presets);
|
||||
auto tick = root()->add_child<NodeImage>();
|
||||
tick->SetPositioning(YGPositionTypeAbsolute);
|
||||
tick->SetSize(16, 32);
|
||||
tick->SetPosition(pos.x, pos.y + (m_preset_button->m_size.y - 32) * 0.5f);
|
||||
tick->set_image("data/ui/popup-tick.png");
|
||||
float hh = m_presets_popup->m_container->m_children.size() > 10 ? App::I.height / App::I.zoom * .75f : 400.f;
|
||||
m_presets_popup->SetHeight(glm::max(hh, 400.f));
|
||||
float hh = App::I.presets->m_container->m_children.size() > 10 ? App::I.height / App::I.zoom * .75f : 400.f;
|
||||
App::I.presets->SetHeight(glm::max(hh, 400.f));
|
||||
root()->update();
|
||||
if ((pos.y + m_presets_popup->m_size.y) > screen.y)
|
||||
pos.y = screen.y - m_presets_popup->m_size.y;
|
||||
if ((pos.y + App::I.presets->m_size.y) > screen.y)
|
||||
pos.y = screen.y - App::I.presets->m_size.y;
|
||||
if (pos.y < 0)
|
||||
pos.y = 0;
|
||||
m_presets_popup->SetPosition(pos.x + 16, pos.y);
|
||||
m_presets_popup->mouse_capture();
|
||||
App::I.presets->SetPosition(pos.x + 16, pos.y);
|
||||
App::I.presets->SetPositioning(YGPositionTypeAbsolute);
|
||||
App::I.presets->m_mouse_ignore = false;
|
||||
App::I.presets->m_flood_events = true;
|
||||
App::I.presets->m_capture_children = false;
|
||||
App::I.presets->mouse_capture();
|
||||
root()->update();
|
||||
|
||||
m_presets_popup->on_popup_close = [this, tick](Node*) {
|
||||
App::I.presets->on_popup_close = [this, tick](Node*) {
|
||||
tick->destroy();
|
||||
};
|
||||
|
||||
m_presets_popup->on_brush_changed = [this](Node* target, std::shared_ptr<Brush>& b) {
|
||||
App::I.presets->on_brush_changed = [this](Node* target, std::shared_ptr<Brush>& b) {
|
||||
// don't change some params
|
||||
//b->m_tip_size = Canvas::I->m_current_brush->m_tip_size;
|
||||
auto old_color = Canvas::I->m_current_brush->m_tip_color;
|
||||
|
||||
Reference in New Issue
Block a user