testing color picker

This commit is contained in:
2019-03-03 23:09:43 +01:00
parent 91ce555c0a
commit 312cfe1ee2
10 changed files with 78 additions and 10 deletions

View File

@@ -1,6 +1,7 @@
#include "pch.h"
#include "node_panel_quick.h"
#include "node_stroke_preview.h"
#include "node_image.h"
Node* NodePanelQuick::clone_instantiate() const
{
@@ -25,7 +26,45 @@ void NodePanelQuick::init_controls()
{
auto s = find<NodeStrokePreview>("quick-brush1");
s->m_brush = std::make_shared<Brush>();
s->m_brush->m_tip_size = 10;
s->m_max_size = 10;
s->m_brush->load_tip("data/brushes/Round-Hard.png", "data/brushes/thumbs/Round-Hard.png");
s->draw_stroke();
m_picker = std::make_shared<NodeColorPicker>();
m_picker->m_manager = m_manager;
m_picker->init();
m_picker->create();
m_picker->loaded();
m_picker->m_mouse_ignore = false;
m_picker->m_flood_events = true;
m_picker->m_capture_children = false;
if (auto b = find<NodeButtonCustom>("quick-color1"))
{
b->on_click = [this,b](Node*) {
auto screen = root()->m_size;
glm::vec2 pos = b->m_pos + glm::vec2(b->m_size.x, 0);
root()->add_child(m_picker);
auto tick = root()->add_child<NodeImage>();
tick->SetPositioning(YGPositionTypeAbsolute);
tick->SetSize(16, 32);
tick->SetPosition(pos.x, pos.y + (b->m_size.y - 32) * 0.5f);
tick->set_image("data/ui/popup-tick.png");
//float hh = m_picker->m_container->m_children.size() > 10 ? App::I.height / App::I.zoom * .75f : 400.f;
//m_picker->SetHeight(4);
root()->update();
pos.y -= 130;
if ((pos.y + m_picker->m_size.y) > screen.y)
pos.y = screen.y - m_picker->m_size.y;
if (pos.y < 0)
pos.y = 0;
m_picker->SetPosition(pos.x + 16, pos.y);
m_picker->mouse_capture();
root()->update();
m_picker->on_popup_close = [this, tick](Node*) {
tick->destroy();
};
};
}
}