Fixed toolbar items reacting when disabled

This commit is contained in:
enricoturri1966 2020-05-13 12:30:09 +02:00
parent 07f419f62b
commit 79101d6e54

View File

@ -532,7 +532,12 @@ bool GLToolbar::on_mouse(wxMouseEvent& evt, GLCanvas3D& parent)
m_mouse_capture.left = true; m_mouse_capture.left = true;
m_mouse_capture.parent = &parent; m_mouse_capture.parent = &parent;
processed = true; processed = true;
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
if ((item_id != -2) && !m_items[item_id]->is_separator() && !m_items[item_id]->is_disabled() &&
((m_pressed_toggable_id == -1) || (m_items[item_id]->get_last_action_type() == GLToolbarItem::Left)))
#else
if ((item_id != -2) && !m_items[item_id]->is_separator() && ((m_pressed_toggable_id == -1) || (m_items[item_id]->get_last_action_type() == GLToolbarItem::Left))) if ((item_id != -2) && !m_items[item_id]->is_separator() && ((m_pressed_toggable_id == -1) || (m_items[item_id]->get_last_action_type() == GLToolbarItem::Left)))
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
{ {
// mouse is inside an icon // mouse is inside an icon
do_action(GLToolbarItem::Left, item_id, parent, true); do_action(GLToolbarItem::Left, item_id, parent, true);
@ -549,7 +554,12 @@ bool GLToolbar::on_mouse(wxMouseEvent& evt, GLCanvas3D& parent)
m_mouse_capture.right = true; m_mouse_capture.right = true;
m_mouse_capture.parent = &parent; m_mouse_capture.parent = &parent;
processed = true; processed = true;
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
if ((item_id != -2) && !m_items[item_id]->is_separator() && !m_items[item_id]->is_disabled() &&
((m_pressed_toggable_id == -1) || (m_items[item_id]->get_last_action_type() == GLToolbarItem::Right)))
#else
if ((item_id != -2) && !m_items[item_id]->is_separator() && ((m_pressed_toggable_id == -1) || (m_items[item_id]->get_last_action_type() == GLToolbarItem::Right))) if ((item_id != -2) && !m_items[item_id]->is_separator() && ((m_pressed_toggable_id == -1) || (m_items[item_id]->get_last_action_type() == GLToolbarItem::Right)))
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
{ {
// mouse is inside an icon // mouse is inside an icon
do_action(GLToolbarItem::Right, item_id, parent, true); do_action(GLToolbarItem::Right, item_id, parent, true);
@ -644,7 +654,11 @@ void GLToolbar::do_action(GLToolbarItem::EActionType type, int item_id, GLCanvas
if ((0 <= item_id) && (item_id < (int)m_items.size())) if ((0 <= item_id) && (item_id < (int)m_items.size()))
{ {
GLToolbarItem* item = m_items[item_id]; GLToolbarItem* item = m_items[item_id];
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
if ((item != nullptr) && !item->is_separator() && !item->is_disabled() && (!check_hover || item->is_hovered()))
#else
if ((item != nullptr) && !item->is_separator() && (!check_hover || item->is_hovered())) if ((item != nullptr) && !item->is_separator() && (!check_hover || item->is_hovered()))
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
{ {
if (((type == GLToolbarItem::Right) && item->is_right_toggable()) || if (((type == GLToolbarItem::Right) && item->is_right_toggable()) ||
((type == GLToolbarItem::Left) && item->is_left_toggable())) ((type == GLToolbarItem::Left) && item->is_left_toggable()))