refactor layout.h into single file per Node* classes
This commit is contained in:
73
engine/node_button_custom.cpp
Normal file
73
engine/node_button_custom.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
#include "pch.h"
|
||||
#include "log.h"
|
||||
#include "node_button_custom.h"
|
||||
|
||||
Node* NodeButtonCustom::clone_instantiate() const
|
||||
{
|
||||
return new NodeButtonCustom();
|
||||
}
|
||||
|
||||
void NodeButtonCustom::clone_copy(Node* dest) const
|
||||
{
|
||||
NodeBorder::clone_copy(dest);
|
||||
NodeButtonCustom* n = static_cast<NodeButtonCustom*>(dest);
|
||||
n->color_normal = color_normal;
|
||||
n->color_hover = color_hover;
|
||||
n->color_down = color_down;
|
||||
n->m_mouse_ignore = false;
|
||||
n->m_color = color_normal;
|
||||
}
|
||||
|
||||
void NodeButtonCustom::loaded()
|
||||
{
|
||||
NodeBorder::loaded();
|
||||
//m_thinkness = 1;
|
||||
//m_border_color = glm::vec4(0, 0, 0, 1);
|
||||
m_color = color_normal;
|
||||
m_mouse_ignore = false;
|
||||
}
|
||||
|
||||
void NodeButtonCustom::set_color(const glm::vec4& c)
|
||||
{
|
||||
color_normal = c;
|
||||
m_color = color_normal;
|
||||
}
|
||||
|
||||
kEventResult NodeButtonCustom::handle_event(Event* e)
|
||||
{
|
||||
NodeBorder::handle_event(e);
|
||||
switch (e->m_type)
|
||||
{
|
||||
case kEventType::MouseEnter:
|
||||
m_color = color_hover;
|
||||
break;
|
||||
case kEventType::MouseLeave:
|
||||
m_color = color_normal;
|
||||
break;
|
||||
case kEventType::MouseDownL:
|
||||
m_color = color_down;
|
||||
break;
|
||||
case kEventType::MouseUpL:
|
||||
m_color = m_mouse_inside ? color_hover : color_normal;
|
||||
if (m_mouse_inside && on_click != nullptr)
|
||||
on_click(this);
|
||||
break;
|
||||
default:
|
||||
return kEventResult::Available;
|
||||
break;
|
||||
}
|
||||
return kEventResult::Consumed;
|
||||
}
|
||||
|
||||
void NodeButtonCustom::parse_attributes(kAttribute ka, const tinyxml2::XMLAttribute* attr)
|
||||
{
|
||||
NodeBorder::parse_attributes(ka, attr);
|
||||
switch (ka)
|
||||
{
|
||||
case kAttribute::Color:
|
||||
color_normal = m_color;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user