add shortcuts, node text font attributes
This commit is contained in:
@@ -4,12 +4,12 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
>
|
>
|
||||||
<layout id="item">
|
<layout id="item">
|
||||||
<border color="1 0 0 1" dir="row">
|
<border dir="row" pad="5">
|
||||||
<node grow="1">
|
<node grow="1">
|
||||||
<text id="descr" font-size="30">New File</text>
|
<text id="descr" size="20">New File</text>
|
||||||
</node>
|
</node>
|
||||||
<node width="100">
|
<node width="200" margin="0 5 0 0">
|
||||||
<text id="shortcut" font-size="30">Ctrl + N</text>
|
<text id="shortcut" size="20" weight="black">Ctrl + N</text>
|
||||||
</node>
|
</node>
|
||||||
</border>
|
</border>
|
||||||
</layout>
|
</layout>
|
||||||
|
|||||||
@@ -226,6 +226,9 @@
|
|||||||
<icon icon="resultset_next" width="20"/>
|
<icon icon="resultset_next" width="20"/>
|
||||||
</button-custom>
|
</button-custom>
|
||||||
</border>
|
</border>
|
||||||
|
<button-custom id="shortcuts" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
||||||
|
<text id="menu-label" text="Shortcuts" margin="0 0 0 5"/>
|
||||||
|
</button-custom>
|
||||||
<button-custom id="clear-grids" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
<button-custom id="clear-grids" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
||||||
<icon icon="bin" width="20"/>
|
<icon icon="bin" width="20"/>
|
||||||
<text text="Clear Guides" margin="0 0 0 5"/>
|
<text text="Clear Guides" margin="0 0 0 5"/>
|
||||||
@@ -234,10 +237,6 @@
|
|||||||
<icon icon="arrow_rotate_clockwise" width="20"/>
|
<icon icon="arrow_rotate_clockwise" width="20"/>
|
||||||
<text id="menu-label" text="Reset Camera" margin="0 0 0 5"/>
|
<text id="menu-label" text="Reset Camera" margin="0 0 0 5"/>
|
||||||
</button-custom>
|
</button-custom>
|
||||||
<button-custom id="shortcuts" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
|
||||||
<icon icon="arrow_rotate_clockwise" width="20"/>
|
|
||||||
<text id="menu-label" text="Shortcuts" margin="0 0 0 5"/>
|
|
||||||
</button-custom>
|
|
||||||
<button-custom os="ios" id="sonarpen" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
<button-custom os="ios" id="sonarpen" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
|
||||||
<icon icon="pencil" width="20"/>
|
<icon icon="pencil" width="20"/>
|
||||||
<text id="menu-label" text="Start SonarPen" margin="0 0 0 5"/>
|
<text id="menu-label" text="Start SonarPen" margin="0 0 0 5"/>
|
||||||
|
|||||||
@@ -862,15 +862,17 @@ void App::dialog_whatsnew(bool force_show)
|
|||||||
});
|
});
|
||||||
whatsnew->add_button("Reload", 120, [this, whatsnew](Node*) {
|
whatsnew->add_button("Reload", 120, [this, whatsnew](Node*) {
|
||||||
whatsnew->reload();
|
whatsnew->reload();
|
||||||
});
|
});
|
||||||
whatsnew->add_button("Read Later", 120, [this, whatsnew](Node*) {
|
whatsnew->add_button("Read Later", 120, [this, whatsnew](Node*) {
|
||||||
|
Settings::unset("whatsnew-id");
|
||||||
|
Settings::save();
|
||||||
whatsnew->destroy();
|
whatsnew->destroy();
|
||||||
});
|
});
|
||||||
whatsnew->add_button("Close", 100, [this, whatsnew](Node*) {
|
whatsnew->add_button("Close", 100, [this, whatsnew](Node*) {
|
||||||
Settings::set<Serializer::Integer>("whatsnew-id", whatsnew->m_page_id);
|
Settings::set<Serializer::Integer>("whatsnew-id", whatsnew->m_page_id);
|
||||||
Settings::save();
|
Settings::save();
|
||||||
whatsnew->destroy();
|
whatsnew->destroy();
|
||||||
});
|
});
|
||||||
if (force_show)
|
if (force_show)
|
||||||
layout[main_id]->add_child(whatsnew);
|
layout[main_id]->add_child(whatsnew);
|
||||||
}
|
}
|
||||||
|
|||||||
51
src/keymap.h
51
src/keymap.h
@@ -1,3 +1,5 @@
|
|||||||
|
#define CASE(K,V) case K: return V;
|
||||||
|
#if __APPLE__
|
||||||
enum {
|
enum {
|
||||||
kVK_ANSI_A = 0x00,
|
kVK_ANSI_A = 0x00,
|
||||||
kVK_ANSI_S = 0x01,
|
kVK_ANSI_S = 0x01,
|
||||||
@@ -119,10 +121,8 @@ enum {
|
|||||||
|
|
||||||
kKey convert_key(int key)
|
kKey convert_key(int key)
|
||||||
{
|
{
|
||||||
#define CASE(K,V) case K: return V;
|
|
||||||
switch(key)
|
switch(key)
|
||||||
{
|
{
|
||||||
#ifdef __APPLE__
|
|
||||||
CASE(kVK_ANSI_A, kKey::KeyA);
|
CASE(kVK_ANSI_A, kKey::KeyA);
|
||||||
CASE(kVK_ANSI_S, kKey::KeyS);
|
CASE(kVK_ANSI_S, kKey::KeyS);
|
||||||
CASE(kVK_ANSI_D, kKey::KeyD);
|
CASE(kVK_ANSI_D, kKey::KeyD);
|
||||||
@@ -235,7 +235,20 @@ kKey convert_key(int key)
|
|||||||
CASE(kVK_RightArrow, kKey::Unknown);
|
CASE(kVK_RightArrow, kKey::Unknown);
|
||||||
CASE(kVK_DownArrow, kKey::Unknown);
|
CASE(kVK_DownArrow, kKey::Unknown);
|
||||||
CASE(kVK_UpArrow, kKey::Unknown);
|
CASE(kVK_UpArrow, kKey::Unknown);
|
||||||
#elif defined(_WIN32)
|
default:
|
||||||
|
return kKey::Unknown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#elif __WIN__
|
||||||
|
kKey convert_key(int key)
|
||||||
|
{
|
||||||
|
static auto KL = GetKeyboardLayout(0);
|
||||||
|
if (key == (VkKeyScanA('[') & 0xFF))
|
||||||
|
return kKey::KeyBracketLeft;
|
||||||
|
if (key == (VkKeyScanA(']') & 0xFF))
|
||||||
|
return kKey::KeyBracketRight;
|
||||||
|
switch(key)
|
||||||
|
{
|
||||||
CASE(VK_LBUTTON, kKey::Unknown);
|
CASE(VK_LBUTTON, kKey::Unknown);
|
||||||
CASE(VK_RBUTTON, kKey::Unknown);
|
CASE(VK_RBUTTON, kKey::Unknown);
|
||||||
CASE(VK_CANCEL, kKey::Unknown);
|
CASE(VK_CANCEL, kKey::Unknown);
|
||||||
@@ -432,7 +445,15 @@ kKey convert_key(int key)
|
|||||||
CASE(VK_NONAME, kKey::Unknown);
|
CASE(VK_NONAME, kKey::Unknown);
|
||||||
CASE(VK_PA1, kKey::Unknown);
|
CASE(VK_PA1, kKey::Unknown);
|
||||||
CASE(VK_OEM_CLEAR, kKey::Unknown);
|
CASE(VK_OEM_CLEAR, kKey::Unknown);
|
||||||
#elif defined(__ANDROID__)
|
default:
|
||||||
|
return kKey::Unknown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#elif __ANDROID__
|
||||||
|
kKey convert_key(int key)
|
||||||
|
{
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
CASE(AKEYCODE_UNKNOWN, kKey::Unknown);
|
CASE(AKEYCODE_UNKNOWN, kKey::Unknown);
|
||||||
CASE(AKEYCODE_SOFT_LEFT, kKey::Unknown);
|
CASE(AKEYCODE_SOFT_LEFT, kKey::Unknown);
|
||||||
CASE(AKEYCODE_SOFT_RIGHT, kKey::Unknown);
|
CASE(AKEYCODE_SOFT_RIGHT, kKey::Unknown);
|
||||||
@@ -656,7 +677,15 @@ kKey convert_key(int key)
|
|||||||
CASE(AKEYCODE_BRIGHTNESS_DOWN, kKey::Unknown);
|
CASE(AKEYCODE_BRIGHTNESS_DOWN, kKey::Unknown);
|
||||||
CASE(AKEYCODE_BRIGHTNESS_UP, kKey::Unknown);
|
CASE(AKEYCODE_BRIGHTNESS_UP, kKey::Unknown);
|
||||||
CASE(AKEYCODE_MEDIA_AUDIO_TRACK, kKey::Unknown);
|
CASE(AKEYCODE_MEDIA_AUDIO_TRACK, kKey::Unknown);
|
||||||
|
default:
|
||||||
|
return kKey::Unknown;
|
||||||
|
}
|
||||||
|
}
|
||||||
#elif __WEB__
|
#elif __WEB__
|
||||||
|
kKey convert_key(int key)
|
||||||
|
{
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
CASE(GLFW_KEY_UNKNOWN, kKey::Unknown);
|
CASE(GLFW_KEY_UNKNOWN, kKey::Unknown);
|
||||||
CASE(GLFW_KEY_SPACE, kKey::KeySpacebar);
|
CASE(GLFW_KEY_SPACE, kKey::KeySpacebar);
|
||||||
CASE(GLFW_KEY_APOSTROPHE, kKey::Unknown);
|
CASE(GLFW_KEY_APOSTROPHE, kKey::Unknown);
|
||||||
@@ -778,8 +807,18 @@ kKey convert_key(int key)
|
|||||||
CASE(GLFW_KEY_RIGHT_ALT, kKey::Unknown);
|
CASE(GLFW_KEY_RIGHT_ALT, kKey::Unknown);
|
||||||
CASE(GLFW_KEY_RIGHT_SUPER, kKey::Unknown);
|
CASE(GLFW_KEY_RIGHT_SUPER, kKey::Unknown);
|
||||||
CASE(GLFW_KEY_MENU, kKey::Unknown);
|
CASE(GLFW_KEY_MENU, kKey::Unknown);
|
||||||
#endif
|
default:
|
||||||
default:
|
|
||||||
return kKey::Unknown;
|
return kKey::Unknown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//#elif __XXX__
|
||||||
|
//kKey convert_key(int key)
|
||||||
|
//{
|
||||||
|
// switch (key)
|
||||||
|
// {
|
||||||
|
// default:
|
||||||
|
// return kKey::Unknown;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
#endif
|
||||||
|
#undef CASE
|
||||||
|
|||||||
@@ -22,7 +22,12 @@ void NodeShortcuts::init_controls()
|
|||||||
m_btn_close->on_click = [this](Node*) {
|
m_btn_close->on_click = [this](Node*) {
|
||||||
destroy();
|
destroy();
|
||||||
};
|
};
|
||||||
add_shortcut("New File", "Ctrl+N");
|
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
|
void NodeShortcuts::add_shortcut(const std::string& descr, const std::string& shortcut) noexcept
|
||||||
@@ -30,6 +35,7 @@ void NodeShortcuts::add_shortcut(const std::string& descr, const std::string& sh
|
|||||||
auto item = m_content->add_child<NodeShortcutsItem>();
|
auto item = m_content->add_child<NodeShortcutsItem>();
|
||||||
item->set_descr(descr);
|
item->set_descr(descr);
|
||||||
item->set_shortcut(shortcut);
|
item->set_shortcut(shortcut);
|
||||||
|
item->m_color = glm::vec4(glm::vec3(m_content->get_child_index(item) % 2 == 0 ? .1f : .0f), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ void NodeText::set_font_size(int size)
|
|||||||
void NodeText::parse_attributes(kAttribute ka, const tinyxml2::XMLAttribute* attr)
|
void NodeText::parse_attributes(kAttribute ka, const tinyxml2::XMLAttribute* attr)
|
||||||
{
|
{
|
||||||
Node::parse_attributes(ka, attr);
|
Node::parse_attributes(ka, attr);
|
||||||
|
std::string id = attr->Name();
|
||||||
switch (ka)
|
switch (ka)
|
||||||
{
|
{
|
||||||
case kAttribute::Multiline:
|
case kAttribute::Multiline:
|
||||||
@@ -106,6 +107,12 @@ void NodeText::parse_attributes(kAttribute ka, const tinyxml2::XMLAttribute* att
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (id == "size")
|
||||||
|
m_font_size = attr->IntValue();
|
||||||
|
else if (id == "weight")
|
||||||
|
m_font_weight = attr->Value();
|
||||||
|
else if (id == "italic")
|
||||||
|
m_font_italic = attr->BoolValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeText::set_text(const std::string& s)
|
void NodeText::set_text(const std::string& s)
|
||||||
|
|||||||
@@ -456,6 +456,11 @@ public:
|
|||||||
{
|
{
|
||||||
return has(key) ? std::dynamic_pointer_cast<T>(props.at(key)) : nullptr;
|
return has(key) ? std::dynamic_pointer_cast<T>(props.at(key)) : nullptr;
|
||||||
}
|
}
|
||||||
|
void unset(const std::string& key)
|
||||||
|
{
|
||||||
|
if (has(key))
|
||||||
|
props.erase(key);
|
||||||
|
}
|
||||||
template<typename T> std::shared_ptr<T> set(const std::string& key, const T value)
|
template<typename T> std::shared_ptr<T> set(const std::string& key, const T value)
|
||||||
{
|
{
|
||||||
if (auto ptr = get<T>(key))
|
if (auto ptr = get<T>(key))
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ public:
|
|||||||
{
|
{
|
||||||
I.Descriptor::set(key, value);
|
I.Descriptor::set(key, value);
|
||||||
}
|
}
|
||||||
|
static void unset(const std::string& key)
|
||||||
|
{
|
||||||
|
I.Descriptor::unset(key);
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static std::shared_ptr<T> get(const std::string& key)
|
static std::shared_ptr<T> get(const std::string& key)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user