69 lines
1.7 KiB
C++
69 lines
1.7 KiB
C++
#include "pch.h"
|
|
#include "node_shorcuts.h"
|
|
#include "node_button.h"
|
|
#include "node_text.h"
|
|
#include "node_scroll.h"
|
|
|
|
Node* NodeShortcuts::clone_instantiate() const
|
|
{
|
|
return new NodeShortcuts;
|
|
}
|
|
|
|
void NodeShortcuts::init()
|
|
{
|
|
init_template_file("data/dialogs/shortcuts.xml", "shortcuts");
|
|
init_controls();
|
|
}
|
|
|
|
void NodeShortcuts::init_controls()
|
|
{
|
|
m_content = find<NodeScroll>("content");
|
|
m_btn_close = find<NodeButton>("btn-ok");
|
|
m_btn_close->on_click = [this](Node*) {
|
|
destroy();
|
|
};
|
|
add_shortcut("Quick switch to Erase", "Hold E");
|
|
add_shortcut("Brush Size Keyboard", "[ and ]");
|
|
add_shortcut("Brush Size", "Alt + Right Mouse Button");
|
|
add_shortcut("Color picker", "Alt + Left Mouse Button");
|
|
add_shortcut("Zoom", "Ctrl + Right Mouse Button");
|
|
//add_shortcut("", "");
|
|
}
|
|
|
|
void NodeShortcuts::add_shortcut(const std::string& descr, const std::string& shortcut) noexcept
|
|
{
|
|
auto item = m_content->add_child<NodeShortcutsItem>();
|
|
item->set_descr(descr);
|
|
item->set_shortcut(shortcut);
|
|
item->m_color = glm::vec4(glm::vec3(m_content->get_child_index(item) % 2 == 0 ? .1f : .0f), 1);
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
Node* NodeShortcutsItem::clone_instantiate() const
|
|
{
|
|
return new NodeShortcutsItem;
|
|
}
|
|
|
|
void NodeShortcutsItem::init()
|
|
{
|
|
init_template_file("data/dialogs/shortcuts.xml", "item");
|
|
init_controls();
|
|
}
|
|
|
|
void NodeShortcutsItem::init_controls()
|
|
{
|
|
m_descr = find<NodeText>("descr");
|
|
m_shortcut = find<NodeText>("shortcut");
|
|
}
|
|
|
|
void NodeShortcutsItem::set_descr(const std::string& str) noexcept
|
|
{
|
|
m_descr->set_text(str);
|
|
}
|
|
|
|
void NodeShortcutsItem::set_shortcut(const std::string& str) noexcept
|
|
{
|
|
m_shortcut->set_text(str);
|
|
}
|