Refactoring of toolbars' tooltip generation
This commit is contained in:
parent
a1ec38a7fb
commit
c6d5ad1517
5 changed files with 185 additions and 19 deletions
|
@ -3341,6 +3341,11 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
Point pos(evt.GetX(), evt.GetY());
|
Point pos(evt.GetX(), evt.GetY());
|
||||||
|
|
||||||
ImGuiWrapper* imgui = wxGetApp().imgui();
|
ImGuiWrapper* imgui = wxGetApp().imgui();
|
||||||
|
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
|
if (m_tooltip.is_in_imgui() && evt.LeftUp())
|
||||||
|
// ignore left up events coming from imgui windows and not processed by them
|
||||||
|
m_mouse.ignore_left_up = true;
|
||||||
|
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
m_tooltip.set_in_imgui(false);
|
m_tooltip.set_in_imgui(false);
|
||||||
if (imgui->update_mouse_data(evt)) {
|
if (imgui->update_mouse_data(evt)) {
|
||||||
m_mouse.position = evt.Leaving() ? Vec2d(-1.0, -1.0) : pos.cast<double>();
|
m_mouse.position = evt.Leaving() ? Vec2d(-1.0, -1.0) : pos.cast<double>();
|
||||||
|
@ -3352,10 +3357,11 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
// do not return if dragging or tooltip not empty to allow for tooltip update
|
// do not return if dragging or tooltip not empty to allow for tooltip update
|
||||||
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
if (!m_mouse.dragging && m_tooltip.is_empty())
|
if (!m_mouse.dragging && m_tooltip.is_empty())
|
||||||
|
return;
|
||||||
#else
|
#else
|
||||||
if (!m_mouse.dragging && m_canvas->GetToolTipText().empty())
|
if (!m_mouse.dragging && m_canvas->GetToolTipText().empty())
|
||||||
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
|
||||||
return;
|
return;
|
||||||
|
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
|
|
|
@ -413,6 +413,7 @@ private:
|
||||||
#endif // ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI
|
#endif // ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI
|
||||||
// Indicates that the mouse is inside an ImGUI dialog, therefore the tooltip should be suppressed.
|
// Indicates that the mouse is inside an ImGUI dialog, therefore the tooltip should be suppressed.
|
||||||
void set_in_imgui(bool b) { m_in_imgui = b; }
|
void set_in_imgui(bool b) { m_in_imgui = b; }
|
||||||
|
bool is_in_imgui() const { return m_in_imgui; }
|
||||||
};
|
};
|
||||||
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ bool GLToolbarItem::update_enabled_state()
|
||||||
|
|
||||||
void GLToolbarItem::render(unsigned int tex_id, float left, float right, float bottom, float top, unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) const
|
void GLToolbarItem::render(unsigned int tex_id, float left, float right, float bottom, float top, unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) const
|
||||||
{
|
{
|
||||||
auto uvs = [this](unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) ->GLTexture::Quad_UVs
|
auto uvs = [this](unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) -> GLTexture::Quad_UVs
|
||||||
{
|
{
|
||||||
assert((tex_width != 0) && (tex_height != 0));
|
assert((tex_width != 0) && (tex_height != 0));
|
||||||
GLTexture::Quad_UVs ret;
|
GLTexture::Quad_UVs ret;
|
||||||
|
@ -154,7 +154,9 @@ GLToolbar::GLToolbar(GLToolbar::EType type, const std::string& name)
|
||||||
, m_name(name)
|
, m_name(name)
|
||||||
, m_enabled(false)
|
, m_enabled(false)
|
||||||
, m_icons_texture_dirty(true)
|
, m_icons_texture_dirty(true)
|
||||||
|
#if !ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
, m_tooltip("")
|
, m_tooltip("")
|
||||||
|
#endif // !ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
, m_pressed_toggable_id(-1)
|
, m_pressed_toggable_id(-1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -358,16 +360,37 @@ int GLToolbar::get_item_id(const std::string& name) const
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
|
std::string GLToolbar::get_tooltip() const
|
||||||
|
{
|
||||||
|
std::string tooltip;
|
||||||
|
|
||||||
|
for (GLToolbarItem* item : m_items)
|
||||||
|
{
|
||||||
|
if (item->is_hovered())
|
||||||
|
{
|
||||||
|
tooltip = item->get_tooltip();
|
||||||
|
if (!item->is_pressed())
|
||||||
|
{
|
||||||
|
const std::string& additional_tooltip = item->get_additional_tooltip();
|
||||||
|
if (!additional_tooltip.empty())
|
||||||
|
tooltip += "\n" + additional_tooltip;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return tooltip;
|
||||||
|
}
|
||||||
|
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
|
|
||||||
void GLToolbar::get_additional_tooltip(int item_id, std::string& text)
|
void GLToolbar::get_additional_tooltip(int item_id, std::string& text)
|
||||||
{
|
{
|
||||||
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];
|
text = m_items[item_id]->get_additional_tooltip();
|
||||||
if (item != nullptr)
|
return;
|
||||||
{
|
|
||||||
text = item->get_additional_tooltip();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
text.clear();
|
text.clear();
|
||||||
|
@ -375,12 +398,8 @@ void GLToolbar::get_additional_tooltip(int item_id, std::string& text)
|
||||||
|
|
||||||
void GLToolbar::set_additional_tooltip(int item_id, const std::string& text)
|
void GLToolbar::set_additional_tooltip(int item_id, const std::string& text)
|
||||||
{
|
{
|
||||||
if ((0 <= item_id) && (item_id < (int)m_items.size()))
|
if (0 <= item_id && item_id < (int)m_items.size())
|
||||||
{
|
m_items[item_id]->set_additional_tooltip(text);
|
||||||
GLToolbarItem* item = m_items[item_id];
|
|
||||||
if (item != nullptr)
|
|
||||||
item->set_additional_tooltip(text);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GLToolbar::update_items_state()
|
bool GLToolbar::update_items_state()
|
||||||
|
@ -425,9 +444,11 @@ bool GLToolbar::on_mouse(wxMouseEvent& evt, GLCanvas3D& parent)
|
||||||
// prevents loosing selection into the scene if mouse down was done inside the toolbar and mouse up was down outside it,
|
// prevents loosing selection into the scene if mouse down was done inside the toolbar and mouse up was down outside it,
|
||||||
// as when switching between views
|
// as when switching between views
|
||||||
m_mouse_capture.reset();
|
m_mouse_capture.reset();
|
||||||
|
#if !ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
if (contains_mouse(mouse_pos, parent) == -1)
|
if (contains_mouse(mouse_pos, parent) == -1)
|
||||||
// mouse is outside the toolbar
|
// mouse is outside the toolbar
|
||||||
m_tooltip.clear();
|
m_tooltip.clear();
|
||||||
|
#endif // !ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
m_mouse_capture.reset();
|
m_mouse_capture.reset();
|
||||||
|
@ -435,7 +456,7 @@ bool GLToolbar::on_mouse(wxMouseEvent& evt, GLCanvas3D& parent)
|
||||||
|
|
||||||
#if ENABLE_MODIFIED_TOOLBAR_MOUSE_EVENT_HANDLING
|
#if ENABLE_MODIFIED_TOOLBAR_MOUSE_EVENT_HANDLING
|
||||||
if (evt.Moving())
|
if (evt.Moving())
|
||||||
m_tooltip = update_hover_state(mouse_pos, parent);
|
update_hover_state(mouse_pos, parent);
|
||||||
else if (evt.LeftUp())
|
else if (evt.LeftUp())
|
||||||
{
|
{
|
||||||
if (m_mouse_capture.left)
|
if (m_mouse_capture.left)
|
||||||
|
@ -489,12 +510,16 @@ bool GLToolbar::on_mouse(wxMouseEvent& evt, GLCanvas3D& parent)
|
||||||
#endif // ENABLE_MODIFIED_TOOLBAR_MOUSE_EVENT_HANDLING
|
#endif // ENABLE_MODIFIED_TOOLBAR_MOUSE_EVENT_HANDLING
|
||||||
|
|
||||||
int item_id = contains_mouse(mouse_pos, parent);
|
int item_id = contains_mouse(mouse_pos, parent);
|
||||||
|
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
|
if (item_id != -1)
|
||||||
|
#else
|
||||||
if (item_id == -1)
|
if (item_id == -1)
|
||||||
{
|
{
|
||||||
// mouse is outside the toolbar
|
// mouse is outside the toolbar
|
||||||
m_tooltip.clear();
|
m_tooltip.clear();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
{
|
{
|
||||||
// mouse inside toolbar
|
// mouse inside toolbar
|
||||||
if (evt.LeftDown() || evt.LeftDClick())
|
if (evt.LeftDown() || evt.LeftDClick())
|
||||||
|
@ -658,6 +683,20 @@ void GLToolbar::do_action(GLToolbarItem::EActionType type, int item_id, GLCanvas
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
|
void GLToolbar::update_hover_state(const Vec2d& mouse_pos, GLCanvas3D& parent)
|
||||||
|
{
|
||||||
|
if (!m_enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (m_layout.type)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case Layout::Horizontal: { update_hover_state_horizontal(mouse_pos, parent); break; }
|
||||||
|
case Layout::Vertical: { update_hover_state_vertical(mouse_pos, parent); break; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
std::string GLToolbar::update_hover_state(const Vec2d& mouse_pos, GLCanvas3D& parent)
|
std::string GLToolbar::update_hover_state(const Vec2d& mouse_pos, GLCanvas3D& parent)
|
||||||
{
|
{
|
||||||
if (!m_enabled)
|
if (!m_enabled)
|
||||||
|
@ -670,8 +709,13 @@ std::string GLToolbar::update_hover_state(const Vec2d& mouse_pos, GLCanvas3D& pa
|
||||||
case Layout::Vertical: { return update_hover_state_vertical(mouse_pos, parent); }
|
case Layout::Vertical: { return update_hover_state_vertical(mouse_pos, parent); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
|
|
||||||
|
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
|
void GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos, GLCanvas3D& parent)
|
||||||
|
#else
|
||||||
std::string GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos, GLCanvas3D& parent)
|
std::string GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos, GLCanvas3D& parent)
|
||||||
|
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
{
|
{
|
||||||
// NB: mouse_pos is already scaled appropriately
|
// NB: mouse_pos is already scaled appropriately
|
||||||
|
|
||||||
|
@ -692,8 +736,10 @@ std::string GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos, GLC
|
||||||
float left = m_layout.left + scaled_border;
|
float left = m_layout.left + scaled_border;
|
||||||
float top = m_layout.top - scaled_border;
|
float top = m_layout.top - scaled_border;
|
||||||
|
|
||||||
std::string tooltip = "";
|
#if !ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
|
std::string tooltip;
|
||||||
|
#endif // !ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
|
|
||||||
for (GLToolbarItem* item : m_items)
|
for (GLToolbarItem* item : m_items)
|
||||||
{
|
{
|
||||||
if (!item->is_visible())
|
if (!item->is_visible())
|
||||||
|
@ -708,6 +754,7 @@ std::string GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos, GLC
|
||||||
|
|
||||||
GLToolbarItem::EState state = item->get_state();
|
GLToolbarItem::EState state = item->get_state();
|
||||||
bool inside = (left <= (float)scaled_mouse_pos(0)) && ((float)scaled_mouse_pos(0) <= right) && (bottom <= (float)scaled_mouse_pos(1)) && ((float)scaled_mouse_pos(1) <= top);
|
bool inside = (left <= (float)scaled_mouse_pos(0)) && ((float)scaled_mouse_pos(0) <= right) && (bottom <= (float)scaled_mouse_pos(1)) && ((float)scaled_mouse_pos(1) <= top);
|
||||||
|
#if !ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
if (inside)
|
if (inside)
|
||||||
{
|
{
|
||||||
tooltip = item->get_tooltip();
|
tooltip = item->get_tooltip();
|
||||||
|
@ -718,6 +765,7 @@ std::string GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos, GLC
|
||||||
tooltip += "\n" + additional_tooltip;
|
tooltip += "\n" + additional_tooltip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // !ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
|
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
|
@ -761,21 +809,54 @@ std::string GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos, GLC
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
|
case GLToolbarItem::Disabled:
|
||||||
|
{
|
||||||
|
if (inside)
|
||||||
|
{
|
||||||
|
item->set_state(GLToolbarItem::HoverDisabled);
|
||||||
|
parent.set_as_dirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GLToolbarItem::HoverDisabled:
|
||||||
|
{
|
||||||
|
if (!inside)
|
||||||
|
{
|
||||||
|
item->set_state(GLToolbarItem::Disabled);
|
||||||
|
parent.set_as_dirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#else
|
||||||
default:
|
default:
|
||||||
case GLToolbarItem::Disabled:
|
case GLToolbarItem::Disabled:
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
}
|
}
|
||||||
|
|
||||||
left += icon_stride;
|
left += icon_stride;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
return tooltip;
|
return tooltip;
|
||||||
|
#endif // !ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
|
void GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos, GLCanvas3D& parent)
|
||||||
|
#else
|
||||||
std::string GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos, GLCanvas3D& parent)
|
std::string GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos, GLCanvas3D& parent)
|
||||||
|
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
{
|
{
|
||||||
// NB: mouse_pos is already scaled appropriately
|
// NB: mouse_pos is already scaled appropriately
|
||||||
|
|
||||||
|
@ -795,7 +876,9 @@ std::string GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos, GLCan
|
||||||
float left = m_layout.left + scaled_border;
|
float left = m_layout.left + scaled_border;
|
||||||
float top = m_layout.top - scaled_border;
|
float top = m_layout.top - scaled_border;
|
||||||
|
|
||||||
std::string tooltip = "";
|
#if !ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
|
std::string tooltip;
|
||||||
|
#endif // !ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
|
|
||||||
for (GLToolbarItem* item : m_items)
|
for (GLToolbarItem* item : m_items)
|
||||||
{
|
{
|
||||||
|
@ -811,6 +894,7 @@ std::string GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos, GLCan
|
||||||
|
|
||||||
GLToolbarItem::EState state = item->get_state();
|
GLToolbarItem::EState state = item->get_state();
|
||||||
bool inside = (left <= (float)scaled_mouse_pos(0)) && ((float)scaled_mouse_pos(0) <= right) && (bottom <= (float)scaled_mouse_pos(1)) && ((float)scaled_mouse_pos(1) <= top);
|
bool inside = (left <= (float)scaled_mouse_pos(0)) && ((float)scaled_mouse_pos(0) <= right) && (bottom <= (float)scaled_mouse_pos(1)) && ((float)scaled_mouse_pos(1) <= top);
|
||||||
|
#if !ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
if (inside)
|
if (inside)
|
||||||
{
|
{
|
||||||
tooltip = item->get_tooltip();
|
tooltip = item->get_tooltip();
|
||||||
|
@ -821,6 +905,7 @@ std::string GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos, GLCan
|
||||||
tooltip += "\n" + additional_tooltip;
|
tooltip += "\n" + additional_tooltip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // !ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
|
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
|
@ -864,18 +949,47 @@ std::string GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos, GLCan
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
|
case GLToolbarItem::Disabled:
|
||||||
|
{
|
||||||
|
if (inside)
|
||||||
|
{
|
||||||
|
item->set_state(GLToolbarItem::HoverDisabled);
|
||||||
|
parent.set_as_dirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GLToolbarItem::HoverDisabled:
|
||||||
|
{
|
||||||
|
if (!inside)
|
||||||
|
{
|
||||||
|
item->set_state(GLToolbarItem::Disabled);
|
||||||
|
parent.set_as_dirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#else
|
||||||
default:
|
default:
|
||||||
case GLToolbarItem::Disabled:
|
case GLToolbarItem::Disabled:
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
}
|
}
|
||||||
|
|
||||||
top -= icon_stride;
|
top -= icon_stride;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
return tooltip;
|
return tooltip;
|
||||||
|
#endif // !ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
}
|
}
|
||||||
|
|
||||||
int GLToolbar::contains_mouse(const Vec2d& mouse_pos, const GLCanvas3D& parent) const
|
int GLToolbar::contains_mouse(const Vec2d& mouse_pos, const GLCanvas3D& parent) const
|
||||||
|
@ -1224,19 +1338,37 @@ bool GLToolbar::generate_icons_texture() const
|
||||||
std::vector<std::pair<int, bool>> states;
|
std::vector<std::pair<int, bool>> states;
|
||||||
if (m_name == "Top")
|
if (m_name == "Top")
|
||||||
{
|
{
|
||||||
|
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
|
states.push_back({ 1, false }); // Normal
|
||||||
|
states.push_back({ 0, false }); // Pressed
|
||||||
|
states.push_back({ 2, false }); // Disabled
|
||||||
|
states.push_back({ 0, false }); // Hover
|
||||||
|
states.push_back({ 0, false }); // HoverPressed
|
||||||
|
states.push_back({ 2, false }); // HoverDisabled
|
||||||
|
#else
|
||||||
states.push_back(std::make_pair(1, false));
|
states.push_back(std::make_pair(1, false));
|
||||||
states.push_back(std::make_pair(0, false));
|
states.push_back(std::make_pair(0, false));
|
||||||
states.push_back(std::make_pair(2, false));
|
states.push_back(std::make_pair(2, false));
|
||||||
states.push_back(std::make_pair(0, false));
|
states.push_back(std::make_pair(0, false));
|
||||||
states.push_back(std::make_pair(0, false));
|
states.push_back(std::make_pair(0, false));
|
||||||
|
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
}
|
}
|
||||||
else if (m_name == "View")
|
else if (m_name == "View")
|
||||||
{
|
{
|
||||||
|
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
|
states.push_back({ 1, false }); // Normal
|
||||||
|
states.push_back({ 1, true }); // Pressed
|
||||||
|
states.push_back({ 1, false }); // Disabled
|
||||||
|
states.push_back({ 0, false }); // Hover
|
||||||
|
states.push_back({ 1, true }); // HoverPressed
|
||||||
|
states.push_back({ 1, false }); // HoverDisabled
|
||||||
|
#else
|
||||||
states.push_back(std::make_pair(1, false));
|
states.push_back(std::make_pair(1, false));
|
||||||
states.push_back(std::make_pair(1, true));
|
states.push_back(std::make_pair(1, true));
|
||||||
states.push_back(std::make_pair(1, false));
|
states.push_back(std::make_pair(1, false));
|
||||||
states.push_back(std::make_pair(0, false));
|
states.push_back(std::make_pair(0, false));
|
||||||
states.push_back(std::make_pair(1, true));
|
states.push_back(std::make_pair(1, true));
|
||||||
|
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int sprite_size_px = (unsigned int)(m_layout.icons_size * m_layout.scale);
|
unsigned int sprite_size_px = (unsigned int)(m_layout.icons_size * m_layout.scale);
|
||||||
|
|
|
@ -61,6 +61,9 @@ public:
|
||||||
Disabled,
|
Disabled,
|
||||||
Hover,
|
Hover,
|
||||||
HoverPressed,
|
HoverPressed,
|
||||||
|
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
|
HoverDisabled,
|
||||||
|
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
Num_States
|
Num_States
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -119,9 +122,15 @@ public:
|
||||||
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(); }
|
||||||
|
|
||||||
|
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
|
bool is_enabled() const { return (m_state != Disabled) && (m_state != HoverDisabled); }
|
||||||
|
bool is_disabled() const { return (m_state == Disabled) || (m_state == HoverDisabled); }
|
||||||
|
bool is_hovered() const { return (m_state == Hover) || (m_state == HoverPressed) || (m_state == HoverDisabled); }
|
||||||
|
#else
|
||||||
bool is_enabled() const { return m_state != Disabled; }
|
bool is_enabled() const { return m_state != Disabled; }
|
||||||
bool is_disabled() const { return m_state == Disabled; }
|
bool is_disabled() const { return m_state == Disabled; }
|
||||||
bool is_hovered() const { return (m_state == Hover) || (m_state == HoverPressed); }
|
bool is_hovered() const { return (m_state == Hover) || (m_state == HoverPressed); }
|
||||||
|
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
bool is_pressed() const { return (m_state == Pressed) || (m_state == HoverPressed); }
|
bool is_pressed() const { return (m_state == Pressed) || (m_state == HoverPressed); }
|
||||||
bool is_visible() const { return m_data.visible; }
|
bool is_visible() const { return m_data.visible; }
|
||||||
bool is_separator() const { return m_type == Separator; }
|
bool is_separator() const { return m_type == Separator; }
|
||||||
|
@ -252,7 +261,9 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
MouseCapture m_mouse_capture;
|
MouseCapture m_mouse_capture;
|
||||||
|
#if !ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
std::string m_tooltip;
|
std::string m_tooltip;
|
||||||
|
#endif // !ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
int m_pressed_toggable_id;
|
int m_pressed_toggable_id;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -298,7 +309,11 @@ public:
|
||||||
void force_left_action(int item_id, GLCanvas3D& parent) { do_action(GLToolbarItem::Left, item_id, parent, false); }
|
void force_left_action(int item_id, GLCanvas3D& parent) { do_action(GLToolbarItem::Left, item_id, parent, false); }
|
||||||
void force_right_action(int item_id, GLCanvas3D& parent) { do_action(GLToolbarItem::Right, item_id, parent, false); }
|
void force_right_action(int item_id, GLCanvas3D& parent) { do_action(GLToolbarItem::Right, item_id, parent, false); }
|
||||||
|
|
||||||
|
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
|
std::string get_tooltip() const;
|
||||||
|
#else
|
||||||
const std::string& get_tooltip() const { return m_tooltip; }
|
const std::string& get_tooltip() const { return m_tooltip; }
|
||||||
|
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
|
|
||||||
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);
|
||||||
|
@ -318,9 +333,15 @@ private:
|
||||||
float get_height_vertical() const;
|
float get_height_vertical() const;
|
||||||
float get_main_size() const;
|
float get_main_size() const;
|
||||||
void do_action(GLToolbarItem::EActionType type, int item_id, GLCanvas3D& parent, bool check_hover);
|
void do_action(GLToolbarItem::EActionType type, int item_id, GLCanvas3D& parent, bool check_hover);
|
||||||
|
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
|
void update_hover_state(const Vec2d& mouse_pos, GLCanvas3D& parent);
|
||||||
|
void update_hover_state_horizontal(const Vec2d& mouse_pos, GLCanvas3D& parent);
|
||||||
|
void update_hover_state_vertical(const Vec2d& mouse_pos, GLCanvas3D& parent);
|
||||||
|
#else
|
||||||
std::string update_hover_state(const Vec2d& mouse_pos, GLCanvas3D& parent);
|
std::string update_hover_state(const Vec2d& mouse_pos, GLCanvas3D& parent);
|
||||||
std::string update_hover_state_horizontal(const Vec2d& mouse_pos, GLCanvas3D& parent);
|
std::string update_hover_state_horizontal(const Vec2d& mouse_pos, GLCanvas3D& parent);
|
||||||
std::string update_hover_state_vertical(const Vec2d& mouse_pos, GLCanvas3D& parent);
|
std::string update_hover_state_vertical(const Vec2d& mouse_pos, GLCanvas3D& parent);
|
||||||
|
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
// returns the id of the item under the given mouse position or -1 if none
|
// returns the id of the item under the given mouse position or -1 if none
|
||||||
int contains_mouse(const Vec2d& mouse_pos, const GLCanvas3D& parent) const;
|
int contains_mouse(const Vec2d& mouse_pos, const GLCanvas3D& parent) const;
|
||||||
int contains_mouse_horizontal(const Vec2d& mouse_pos, const GLCanvas3D& parent) const;
|
int contains_mouse_horizontal(const Vec2d& mouse_pos, const GLCanvas3D& parent) const;
|
||||||
|
|
|
@ -594,6 +594,12 @@ void GUI_App::load_project(wxWindow *parent, wxString& input_file) const
|
||||||
|
|
||||||
void GUI_App::import_model(wxWindow *parent, wxArrayString& input_files) const
|
void GUI_App::import_model(wxWindow *parent, wxArrayString& input_files) const
|
||||||
{
|
{
|
||||||
|
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
|
if (this->plater_ != nullptr)
|
||||||
|
// hides the tooltip
|
||||||
|
plater_->get_current_canvas3D()->set_tooltip("");
|
||||||
|
#endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||||
|
|
||||||
input_files.Clear();
|
input_files.Clear();
|
||||||
wxFileDialog dialog(parent ? parent : GetTopWindow(),
|
wxFileDialog dialog(parent ? parent : GetTopWindow(),
|
||||||
_(L("Choose one or more files (STL/OBJ/AMF/3MF/PRUSA):")),
|
_(L("Choose one or more files (STL/OBJ/AMF/3MF/PRUSA):")),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue