add shortcuts panel

This commit is contained in:
2019-11-30 18:17:54 +01:00
parent 22de2dedc4
commit 0ee3f1d125
9 changed files with 166 additions and 18 deletions

62
src/node_shorcuts.cpp Normal file
View 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);
}