Popup presets panel, fix padding scissor, stacked mouse capture

This commit is contained in:
2019-01-26 00:55:57 +01:00
parent 79e4777f77
commit 14b26c8902
11 changed files with 184 additions and 66 deletions

View File

@@ -116,12 +116,6 @@ int NodePanelBrush::find_brush(const std::string & name) const
return -1;
}
uint16_t NodePanelBrush::get_texture_id(int index) const
{
TextureManager::load(m_brushes[index]->high_path.c_str(), true);
return m_brushes[index]->high_id;
}
std::string NodePanelBrush::get_texture_path(int index) const
{
return m_brushes[index]->high_path;
@@ -132,11 +126,6 @@ std::string NodePanelBrush::get_thumb_path(int index) const
return m_brushes[index]->thumb_path;
}
int NodePanelBrush::get_brush_id(int index) const
{
return m_brushes[index]->m_brushID;
}
// select the current brush based on the texture id
void NodePanelBrush::select_brush(int brush_id)
{
@@ -167,8 +156,8 @@ void NodeBrushPresetItem::init()
color_hover = glm::vec4(.7, .7, .7, 1);
color_normal = glm::vec4(.3, .3, .3, 1);
m_color = color_normal;
m_thumb = (NodeImage*)m_children[0].get();
m_preview = (NodeStrokePreview*)m_children[1].get();
m_thumb = find<NodeImage>("thumb");
m_preview = find<NodeStrokePreview>("canvas");
}
void NodeBrushPresetItem::draw()
@@ -193,7 +182,7 @@ Node* NodePanelBrushPreset::clone_instantiate() const
void NodePanelBrushPreset::init()
{
init_template("tpl-panel-brush-preset");
m_container = find<NodeBorder>("brushes");
m_container = find<Node>("brushes");
m_btn_add = find<NodeButtonCustom>("btn-add");
m_btn_add->on_click = [this] (Node*) {
NodeBrushPresetItem* brush = new NodeBrushPresetItem;
@@ -233,6 +222,24 @@ void NodePanelBrushPreset::init()
restore();
}
kEventResult NodePanelBrushPreset::handle_event(Event* e)
{
switch (e->m_type)
{
case kEventType::MouseUpL:
if (!m_mouse_inside)
{
mouse_release();
parent->remove_child(this);
}
break;
default:
return kEventResult::Available;
break;
}
return kEventResult::Consumed;
}
void NodePanelBrushPreset::handle_click(Node* target)
{
if (target == m_current)