test floating some panels

This commit is contained in:
2019-03-24 01:43:13 +01:00
parent 929e80a218
commit a50654d8b7
7 changed files with 57 additions and 5 deletions

View File

@@ -124,11 +124,11 @@
<!-- PANEL COLOR PICKER -->
<layout id="tpl-panel-color">
<node width="350" margin="0 0 10 0" rtl="ltr">
<border height="30" color=".4" align="center" justify="center">
<node width="350" height="350" margin="0 0 10 0" rtl="ltr">
<border id="title" height="30" color=".4" align="center" justify="center">
<text text="Colors" color="1 1 1 1"/>
</border>
<border color=".4" pad="5" dir="row" height="350">
<border color=".4" pad="5" dir="row">
<color-quad id="quad" color="1 0 0 1" height="100%" grow="1"/>
<node width="30" dir="col" pad="0 0 0 5"><slider-hue id="hue"/></node>
</border>
@@ -1280,7 +1280,7 @@ Here's a list of what's available in this release.
<text text="Floating Panel"/>
</node>
</border>
<border id="container" height="400" color="0 0 0 .9" pad="10" dir="col">
<border id="container" height="400" color="0 0 0 .9" dir="col">
</border>
</border>
</layout>

View File

@@ -594,6 +594,8 @@ void App::update(float dt)
}
//auto box = n->m_clip;
//glm::ivec4 c = glm::vec4((int)box.x - 1, (int)(height / zoom - box.y - box.w) - 1, (int)box.z + 2, (int)box.w + 2) * zoom;
if (box.z <= 0.f || box.w <= 0.f)
return false;
glm::ivec4 c = glm::vec4((int)box.x, (int)(height / zoom - box.y - box.w), (int)box.z, (int)box.w) * zoom;
glScissor(c.x + off_x, c.y + off_y, c.z, c.w);
n->draw();

View File

@@ -64,6 +64,9 @@ public:
std::shared_ptr<NodePanelGrid> grid;
std::shared_ptr<NodePanelBrushPreset> presets;
NodePanelQuick* quick;
NodePanelColor* floating_color;
NodeColorPicker* floating_picker;
NodePanelBrushPreset* floating_presets;
NodeCanvas* canvas;
const uint16_t main_id = const_hash("main");
const std::array<int, 6> res_map{ 512, 1024, 1536, 2048, 4096, 8192 };

View File

@@ -5,6 +5,7 @@
#include "node_text.h"
#include "node_progress_bar.h"
#include "node_dialog_picker.h"
#include "node_panel_floating.h"
void App::title_update()
{
@@ -872,6 +873,10 @@ void App::brush_update()
*quick->m_button_brush_current_preview->m_brush = *Canvas::I->m_current_brush;
quick->m_button_brush_current_preview->draw_stroke();
quick->m_button_color_current_inner->m_color = Canvas::I->m_current_brush->m_tip_color;
if (floating_picker)
floating_picker->set_color(Canvas::I->m_current_brush->m_tip_color);
if (floating_color)
floating_color->set_color(Canvas::I->m_current_brush->m_tip_color);
}
void App::init_menu_layer()
@@ -1080,8 +1085,41 @@ void App::initLayout()
};
}
// test floating panel
auto fp_presets = layout[main_id]->add_child<NodePanelFloating>();
floating_presets = fp_presets->m_container->add_child<NodePanelBrushPreset>();
floating_presets->SetHeightP(100);
floating_presets->on_brush_changed = [this](Node* target, std::shared_ptr<Brush>& b) {
auto c = Canvas::I->m_current_brush->m_tip_color;
*Canvas::I->m_current_brush = *b;
Canvas::I->m_current_brush->m_tip_color = c;
Canvas::I->m_current_brush->load();
brush_update();
};
auto fp_color = layout[main_id]->add_child<NodePanelFloating>();
floating_color = fp_color->m_container->add_child<NodePanelColor>();
floating_color->SetHeightP(100);
floating_color->find("title")->destroy();
floating_color->on_color_changed = [this](Node* target, glm::vec4 color) {
Canvas::I->m_current_brush->m_tip_color = color;
brush_update();
};
auto fp_picker = layout[main_id]->add_child<NodePanelFloating>();
fp_picker->m_container->SetSize(300, 500);
floating_picker = fp_picker->m_container->add_child<NodeColorPicker>();
floating_picker->m_autohide = false;
floating_picker->on_color_change = [this](Node* target, glm::vec3 color) {
Canvas::I->m_current_brush->m_tip_color = glm::vec4(color, 1.f);
brush_update();
};
//picker->SetHeightP(100);
//color->find("title")->destroy();
App::I.redraw = true;
};
LOG("initializing layout xml");
if (layout.m_loaded)
{

View File

@@ -302,6 +302,8 @@ const Node* Node::init_template(const char* id)
void Node::add_child(Node* n)
{
if (n->m_parent)
n->m_parent->remove_child(n);
m_children.emplace_back(n);
n->m_parent = this;
n->m_manager = m_manager;
@@ -312,6 +314,8 @@ void Node::add_child(Node* n)
void Node::add_child(Node* n, int index)
{
if (n->m_parent)
n->m_parent->remove_child(n);
m_children.emplace_back(n);
n->m_parent = this;
n->m_manager = m_manager;
@@ -322,6 +326,8 @@ void Node::add_child(Node* n, int index)
void Node::add_child(std::shared_ptr<Node> n)
{
if (n->m_parent)
n->m_parent->remove_child(n.get());
m_children.push_back(n);
n->m_parent = this;
n->m_manager = m_manager;
@@ -332,6 +338,8 @@ void Node::add_child(std::shared_ptr<Node> n)
void Node::add_child(std::shared_ptr<Node> n, int index)
{
if (n->m_parent)
n->m_parent->remove_child(n.get());
m_children.insert(m_children.begin() + index, n);
n->m_parent = this;
n->m_manager = m_manager;

View File

@@ -46,7 +46,7 @@ kEventResult NodeColorPicker::handle_event(Event* e)
switch (e->m_type)
{
case kEventType::MouseLeave:
if (!m_interacted)
if (!m_interacted || !m_autohide)
break;
// else fall through
case kEventType::MouseUpL:

View File

@@ -12,6 +12,7 @@ public:
std::function<void(Node* target, glm::vec3 rgb)> on_color_change;
bool m_interacted = false;
bool m_autohide = true;
NodeSliderH* m_slider_h;
NodeSliderH* m_slider_s;
NodeSliderH* m_slider_v;