Show tooltip for all hovered ticks, not just for a selected one

This commit is contained in:
YuSanka 2020-02-04 14:53:17 +01:00
parent 0da4cb29b5
commit 49c5822be4
2 changed files with 98 additions and 79 deletions

View file

@ -875,28 +875,24 @@ void Control::correct_higher_value()
m_lower_value = m_higher_value;
}
wxString Control::get_tooltip(IconFocus icon_focus)
wxString Control::get_tooltip(FocusItem focused_item, int tick/*=-1*/)
{
wxString tooltip(wxEmptyString);
if (m_is_one_layer_icon_focesed)
tooltip = _(L("One layer mode"));
if (focused_item == fiNone)
return "";
if (focused_item == fiOneLayerIcon)
return _(L("One layer mode"));
if (focused_item == fiRevertIcon)
return _(L("Discard all custom changes"));
if (focused_item == fiCogIcon)
return _(L("Set extruder sequence for whole print"));
if (focused_item == fiColorBand)
return m_mode != t_mode::SingleExtruder ? "" :
_(L("For edit current color use Right(Double) mouse click on colored band"));
if (icon_focus == ifRevert)
tooltip = _(L("Discard all custom changes"));
if (icon_focus == ifCog)
tooltip = _(L("Set extruder sequence for whole print"));
else if (m_is_action_icon_focesed)
{
const int tick = m_selection == ssLower ? m_lower_value : m_higher_value;
wxString tooltip;
const auto tick_code_it = m_ticks.ticks.find(TickCode{tick});
/* Note: just on OSX!!!
* Right click event causes a little scrolling.
* So, as a workaround we use Ctrl+LeftMouseClick instead of RightMouseClick
* Show this information in tooltip
* */
if (tick_code_it == m_ticks.ticks.end()) // tick doesn't exist
if (tick_code_it == m_ticks.ticks.end() && focused_item == fiActionIcon) // tick doesn't exist
{
// Show mode as a first string of tooltop
tooltip = " " + _(L("Slider(print) mode")) + ": ";
@ -905,6 +901,12 @@ wxString Control::get_tooltip(IconFocus icon_focus)
CustomGCode::MultiExtruderMode );
tooltip += "\n\n";
/* Note: just on OSX!!!
* Right click event causes a little scrolling.
* So, as a workaround we use Ctrl+LeftMouseClick instead of RightMouseClick
* Show this information in tooltip
* */
// Show list of actions with new tick
tooltip += ( m_mode == t_mode::MultiAsSingle ?
_(L("For add change extruder use left mouse button click")) :
@ -914,7 +916,8 @@ wxString Control::get_tooltip(IconFocus icon_focus)
_(L("For add another code use Ctrl + Left mouse button click")) :
_(L("For add another code use right mouse button click")) );
}
else // tick exists
if (tick_code_it != m_ticks.ticks.end()) // tick exists
{
// Show custom Gcode as a first string of tooltop
tooltip = " ";
@ -948,14 +951,14 @@ wxString Control::get_tooltip(IconFocus icon_focus)
"Check your choice to avoid redundant color changes."));
// Show list of actions with existing tick
if (focused_item == fiActionIcon)
tooltip += "\n\n" + _(L("For Delete tick use left mouse button click OR pres \"-\" key")) + "\n" + (
is_osx ?
_(L("For Edit tick use Ctrl + Left mouse button click")) :
_(L("For Edit tick use right mouse button click")) );
}
}
return tooltip;
}
void Control::OnMotion(wxMouseEvent& event)
@ -966,14 +969,26 @@ void Control::OnMotion(wxMouseEvent& event)
const wxPoint pos = event.GetLogicalPosition(dc);
m_is_one_layer_icon_focesed = is_point_in_rect(pos, m_rect_one_layer_icon);
IconFocus icon_focus = ifNone;
FocusItem focused_item = fiNone;
int tick = -1;
if (!m_is_left_down && !m_is_one_layer) {
m_is_action_icon_focesed = is_point_in_rect(pos, m_rect_tick_action);
if (!m_ticks.empty() && is_point_in_rect(pos, m_rect_revert_icon))
icon_focus = ifRevert;
if (m_is_one_layer_icon_focesed)
focused_item = fiOneLayerIcon;
else if (m_is_action_icon_focesed) {
focused_item = fiActionIcon;
tick = m_selection == ssLower ? m_lower_value : m_higher_value;
}
else if (!m_ticks.empty() && is_point_in_rect(pos, m_rect_revert_icon))
focused_item = fiRevertIcon;
else if (is_point_in_rect(pos, m_rect_cog_icon))
icon_focus = ifCog;
focused_item = fiCogIcon;
else {
focused_item = fiTick;
tick = get_tick_near_point(pos);
}
}
else if (m_is_left_down || m_is_right_down) {
if (m_selection == ssLower) {
@ -994,7 +1009,7 @@ void Control::OnMotion(wxMouseEvent& event)
event.Skip();
// Set tooltips with information for each icon
this->SetToolTip(get_tooltip(icon_focus));
this->SetToolTip(get_tooltip(focused_item, tick));
if (action)
{

View file

@ -33,10 +33,14 @@ enum SelectedSlider {
ssHigher
};
enum IconFocus {
ifNone,
ifRevert,
ifCog
enum FocusItem {
fiNone,
fiRevertIcon,
fiOneLayerIcon,
fiCogIcon,
fiColorBand,
fiActionIcon,
fiTick
};
enum ConflictType
@ -263,7 +267,7 @@ private:
wxSize get_size();
void get_size(int *w, int *h);
double get_double_value(const SelectedSlider& selection);
wxString get_tooltip(IconFocus icon_focus);
wxString get_tooltip(FocusItem focused_item, int tick = -1);
std::string get_color_for_tool_change_tick(std::set<TickCode>::const_iterator it) const;
std::string get_color_for_color_change_tick(std::set<TickCode>::const_iterator it) const;