Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnrico Turri <enricoturri@seznam.cz>2019-07-11 08:46:40 +0300
committerEnrico Turri <enricoturri@seznam.cz>2019-07-11 08:46:40 +0300
commitdbf0eacfa7c0ac05183dbee54e003ce0c517fbd1 (patch)
tree4e25775fa59657a31130351cc859a5e46fd709aa /src/slic3r/GUI/GLToolbar.cpp
parent1b5ab100bd685d5cf4e77d0b653b864562f9932b (diff)
Deactivate undo/redo toolbar items when leaving the 3D scene or clicking into it
Diffstat (limited to 'src/slic3r/GUI/GLToolbar.cpp')
-rw-r--r--src/slic3r/GUI/GLToolbar.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/slic3r/GUI/GLToolbar.cpp b/src/slic3r/GUI/GLToolbar.cpp
index 8c9751086..45e427522 100644
--- a/src/slic3r/GUI/GLToolbar.cpp
+++ b/src/slic3r/GUI/GLToolbar.cpp
@@ -389,6 +389,22 @@ bool GLToolbar::is_any_item_pressed() const
return false;
}
+unsigned int GLToolbar::get_item_id(const std::string& name) const
+{
+ for (unsigned int i = 0; i < (unsigned int)m_items.size(); ++i)
+ {
+ if (m_items[i]->get_name() == name)
+ return i;
+ }
+
+ return -1;
+}
+
+void GLToolbar::force_action(unsigned int item_id, GLCanvas3D& parent)
+{
+ do_action(item_id, parent, false);
+}
+
bool GLToolbar::update_items_state()
{
bool ret = false;
@@ -461,10 +477,8 @@ bool GLToolbar::on_mouse(wxMouseEvent& evt, GLCanvas3D& parent)
m_mouse_capture.parent = &parent;
processed = true;
if ((item_id != -2) && !m_items[item_id]->is_separator())
- {
// mouse is inside an icon
- do_action((unsigned int)item_id, parent);
- }
+ do_action((unsigned int)item_id, parent, true);
}
else if (evt.MiddleDown())
{
@@ -572,14 +586,14 @@ float GLToolbar::get_main_size() const
return size;
}
-void GLToolbar::do_action(unsigned int item_id, GLCanvas3D& parent)
+void GLToolbar::do_action(unsigned int item_id, GLCanvas3D& parent, bool check_hover)
{
if ((m_pressed_toggable_id == -1) || (m_pressed_toggable_id == item_id))
{
if (item_id < (unsigned int)m_items.size())
{
GLToolbarItem* item = m_items[item_id];
- if ((item != nullptr) && !item->is_separator() && item->is_hovered())
+ if ((item != nullptr) && !item->is_separator() && (!check_hover || item->is_hovered()))
{
if (item->is_toggable())
{
@@ -588,6 +602,10 @@ void GLToolbar::do_action(unsigned int item_id, GLCanvas3D& parent)
item->set_state(GLToolbarItem::HoverPressed);
else if (state == GLToolbarItem::HoverPressed)
item->set_state(GLToolbarItem::Hover);
+ else if (state == GLToolbarItem::Pressed)
+ item->set_state(GLToolbarItem::Normal);
+ else if (state == GLToolbarItem::Normal)
+ item->set_state(GLToolbarItem::Pressed);
m_pressed_toggable_id = item->is_pressed() ? item_id : -1;
@@ -599,7 +617,7 @@ void GLToolbar::do_action(unsigned int item_id, GLCanvas3D& parent)
if (m_type == Radio)
select_item(item->get_name());
else
- item->set_state(GLToolbarItem::HoverPressed);
+ item->set_state(item->is_hovered() ? GLToolbarItem::HoverPressed : GLToolbarItem::Pressed);
parent.render();
item->do_action();