add shortcuts panel
This commit is contained in:
62
src/node_shorcuts.cpp
Normal file
62
src/node_shorcuts.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
#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("New File", "Ctrl+N");
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user