Improved mask also work on erase. Improved shaders for layer opacity, now when drawing doesn't change opacity. Improved layers panel layout to be similar to PS. Added layer blending option and visibility. Added custom icons to checkboxes and fixed the combobox items.

This commit is contained in:
2019-01-05 12:41:21 +01:00
parent f823451546
commit e4fe0cffed
23 changed files with 255 additions and 93 deletions

View File

@@ -1,6 +1,7 @@
#include "pch.h"
#include "log.h"
#include "node_checkbox.h"
#include "texture.h"
Node* NodeCheckBox::clone_instantiate() const
{
@@ -13,7 +14,9 @@ void NodeCheckBox::clone_children(Node* dest) const
NodeCheckBox* n = static_cast<NodeCheckBox*>(dest);
n->m_outer = (NodeBorder*)n->m_children[0].get();
n->m_inner = (NodeBorder*)n->m_outer->m_children[0].get();
n->m_icon = n->m_inner->m_children.empty() ? nullptr : (NodeImage*)n->m_inner->m_children[0].get();
n->m_mouse_ignore = false;
n->m_icon_path = m_icon_path;
}
void NodeCheckBox::init()
@@ -43,6 +46,8 @@ void NodeCheckBox::create()
{
m_outer->create();
m_inner->create();
if (!m_icon_path.empty())
set_icon(m_icon_path);
}
kEventResult NodeCheckBox::handle_event(Event* e)
@@ -58,6 +63,7 @@ kEventResult NodeCheckBox::handle_event(Event* e)
break;
case kEventType::MouseUpL:
checked = !checked;
update_icon();
if (on_value_changed)
on_value_changed(this, checked);
break;
@@ -73,3 +79,42 @@ void NodeCheckBox::draw()
m_inner->m_color = checked ? glm::vec4(.4, .4, .4, 1) : glm::vec4(.8, .8, .8, 1);
Node::draw();
}
void NodeCheckBox::parse_attributes(kAttribute ka, const tinyxml2::XMLAttribute* attr)
{
switch (ka)
{
case kAttribute::Icon:
m_icon_path = attr->Value();
break;
default:
Node::parse_attributes(ka, attr);
break;
}
}
void NodeCheckBox::set_icon(const std::string& icon_path)
{
if (icon_path.empty() || !TextureManager::load(icon_path.c_str()))
{
if (m_icon)
m_icon->destroy();
m_icon = nullptr;
return;
}
m_icon_path = icon_path;
update_icon();
}
void NodeCheckBox::update_icon()
{
auto& t = TextureManager::get(const_hash(m_icon_path.c_str()));
if (!m_icon)
m_icon = m_inner->add_child<NodeImage>();
auto region = checked ? glm::vec4(.5f, 0, 1, 1) : glm::vec4(0, 0, .5f, 1);
m_icon->m_region = region * glm::vec4(t.size(), t.size());
m_icon->m_use_atlas = true;
m_icon->set_image(m_icon_path);
m_icon->SetWidthP(100);
m_icon->SetHeightP(100);
}