Added new icon for "collapse sidebar"

+ The tooltip for a "Collapse" button is updated according to the collapse state
This commit is contained in:
YuSanka 2020-03-30 11:53:58 +02:00
parent ab02d344e4
commit abad9133eb
4 changed files with 38 additions and 3 deletions

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 23.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
<g id="cross">
<g><line fill="none" stroke="#ED6B21" stroke-width="1" stroke-linecap="round" stroke-miterlimit="10" x1="12" y1="1" x2="15" y2="4"/></g>
<g><line fill="none" stroke="#ED6B21" stroke-width="1" stroke-linecap="round" stroke-miterlimit="10" x1="12" y1="7" x2="15" y2="4"/></g>
<g><line fill="none" stroke="#ED6B21" stroke-width="1" stroke-linecap="round" stroke-miterlimit="10" x1="8" y1="1" x2="11" y2="4"/></g>
<g><line fill="none" stroke="#ED6B21" stroke-width="1" stroke-linecap="round" stroke-miterlimit="10" x1="8" y1="7" x2="11" y2="4"/></g>
<g><line fill="none" stroke="#ED6B21" stroke-width="1" stroke-linecap="round" stroke-miterlimit="10" x1="4" y1="9" x2="1" y2="12"/></g>
<g><line fill="none" stroke="#ED6B21" stroke-width="1" stroke-linecap="round" stroke-miterlimit="10" x1="4" y1="15" x2="1" y2="12"/></g>
<g><line fill="none" stroke="#ED6B21" stroke-width="1" stroke-linecap="round" stroke-miterlimit="10" x1="8" y1="9" x2="5" y2="12"/></g>
<g><line fill="none" stroke="#ED6B21" stroke-width="1" stroke-linecap="round" stroke-miterlimit="10" x1="8" y1="15" x2="5" y2="12"/></g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -5161,10 +5161,21 @@ bool GLCanvas3D::_init_undoredo_toolbar()
return false; return false;
item.name = "collapse_sidebar"; item.name = "collapse_sidebar";
item.icon_filename = "cross.svg"; item.icon_filename = "collapse.svg";
item.tooltip = _utf8(L("Collapse right panel")); item.tooltip = wxGetApp().plater()->is_sidebar_collapsed() ?
_utf8(L("Expand right panel")) : _utf8(L("Collapse right panel"));
item.sprite_id = 2; item.sprite_id = 2;
item.left.action_callback = [this]() { post_event(SimpleEvent(EVT_GLCANVAS_COLLAPSE_SIDEBAR)); }; item.left.action_callback = [this, item]() {
std::string new_tooltip = wxGetApp().plater()->is_sidebar_collapsed() ?
_utf8(L("Collapse right panel")) : _utf8(L("Expand right panel"));
int id = m_undoredo_toolbar.get_item_id("collapse_sidebar");
m_undoredo_toolbar.set_tooltip(id, new_tooltip);
set_tooltip("");
post_event(SimpleEvent(EVT_GLCANVAS_COLLAPSE_SIDEBAR));
};
item.enabling_callback = []()->bool { return true; }; item.enabling_callback = []()->bool { return true; };
if (!m_undoredo_toolbar.add_item(item)) if (!m_undoredo_toolbar.add_item(item))
return false; return false;

View File

@ -406,6 +406,12 @@ void GLToolbar::set_additional_tooltip(int item_id, const std::string& text)
m_items[item_id]->set_additional_tooltip(text); m_items[item_id]->set_additional_tooltip(text);
} }
void GLToolbar::set_tooltip(int item_id, const std::string& text)
{
if (0 <= item_id && item_id < (int)m_items.size())
m_items[item_id]->set_tooltip(text);
}
bool GLToolbar::update_items_state() bool GLToolbar::update_items_state()
{ {
bool ret = false; bool ret = false;

View File

@ -118,6 +118,7 @@ public:
const std::string& get_tooltip() const { return m_data.tooltip; } const std::string& get_tooltip() const { return m_data.tooltip; }
const std::string& get_additional_tooltip() const { return m_data.additional_tooltip; } const std::string& get_additional_tooltip() const { return m_data.additional_tooltip; }
void set_additional_tooltip(const std::string& text) { m_data.additional_tooltip = text; } void set_additional_tooltip(const std::string& text) { m_data.additional_tooltip = text; }
void set_tooltip(const std::string& text) { m_data.tooltip = text; }
void do_left_action() { m_last_action_type = Left; m_data.left.action_callback(); } void do_left_action() { m_last_action_type = Left; m_data.left.action_callback(); }
void do_right_action() { m_last_action_type = Right; m_data.right.action_callback(); } void do_right_action() { m_last_action_type = Right; m_data.right.action_callback(); }
@ -317,6 +318,7 @@ public:
void get_additional_tooltip(int item_id, std::string& text); void get_additional_tooltip(int item_id, std::string& text);
void set_additional_tooltip(int item_id, const std::string& text); void set_additional_tooltip(int item_id, const std::string& text);
void set_tooltip(int item_id, const std::string& text);
// returns true if any item changed its state // returns true if any item changed its state
bool update_items_state(); bool update_items_state();