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,20 +875,31 @@ 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)
wxString tooltip;
const auto tick_code_it = m_ticks.ticks.find(TickCode{tick});
if (tick_code_it == m_ticks.ticks.end() && focused_item == fiActionIcon) // tick doesn't exist
{
const int tick = m_selection == ssLower ? m_lower_value : m_higher_value;
const auto tick_code_it = m_ticks.ticks.find(TickCode{tick});
// Show mode as a first string of tooltop
tooltip = " " + _(L("Slider(print) mode")) + ": ";
tooltip += (m_mode == t_mode::SingleExtruder ? CustomGCode::SingleExtruderMode :
m_mode == t_mode::MultiAsSingle ? CustomGCode::MultiAsSingleMode :
CustomGCode::MultiExtruderMode );
tooltip += "\n\n";
/* Note: just on OSX!!!
* Right click event causes a little scrolling.
@ -896,66 +907,58 @@ wxString Control::get_tooltip(IconFocus icon_focus)
* Show this information in tooltip
* */
if (tick_code_it == m_ticks.ticks.end()) // tick doesn't exist
{
// Show mode as a first string of tooltop
tooltip = " " + _(L("Slider(print) mode")) + ": ";
tooltip += (m_mode == t_mode::SingleExtruder ? CustomGCode::SingleExtruderMode :
m_mode == t_mode::MultiAsSingle ? CustomGCode::MultiAsSingleMode :
CustomGCode::MultiExtruderMode );
tooltip += "\n\n";
// Show list of actions with new tick
tooltip += ( m_mode == t_mode::MultiAsSingle ?
_(L("For add change extruder use left mouse button click")) :
_(L("For add color change use left mouse button click")) ) + " " +
_(L("OR pres \"+\" key")) + "\n" + (
is_osx ?
_(L("For add another code use Ctrl + Left mouse button click")) :
_(L("For add another code use right mouse button click")) );
}
else // tick exists
{
// Show custom Gcode as a first string of tooltop
tooltip = " ";
tooltip += tick_code_it->gcode == ColorChangeCode ? (
m_mode == t_mode::SingleExtruder ?
from_u8((boost::format(_utf8(L("Color change (\"%1%\")"))) % tick_code_it->gcode ).str()) :
from_u8((boost::format(_utf8(L("Color change (\"%1%\") for Extruder %2%"))) %
tick_code_it->gcode % tick_code_it->extruder).str()) ) :
tick_code_it->gcode == PausePrintCode ?
from_u8((boost::format(_utf8(L("Pause print (\"%1%\")"))) % tick_code_it->gcode ).str()) :
tick_code_it->gcode == ToolChangeCode ?
from_u8((boost::format(_utf8(L("Extruder(tool) is changed to Extruder \"%1%\""))) % tick_code_it->extruder ).str()) :
from_u8((boost::format(_utf8(L("\"%1%\""))) % tick_code_it->gcode ).str()) ;
// If tick is marked as a conflict (exclamation icon),
// we should to explain why
ConflictType conflict = m_ticks.is_conflict_tick(*tick_code_it, m_mode, m_only_extruder, m_values[tick]);
if (conflict != ctNone)
tooltip += "\n\n" + _(L("Note")) + "! ";
if (conflict == ctModeConflict)
tooltip += _(L("G-code of this tick has a conflict with slider(print) mode.\n"
"Any its editing will cause a changes of DoubleSlider data."));
else if (conflict == ctMeaninglessColorChange)
tooltip += _(L("There is a color change for extruder that wouldn't be used till the end of printing.\n"
"This code wouldn't be processed during GCode generation."));
else if (conflict == ctMeaninglessToolChange)
tooltip += _(L("There is a extruder change to the same extruder.\n"
"This code wouldn't be processed during GCode generation."));
else if (conflict == ctRedundant)
tooltip += _(L("There is a color change for extruder that has not been used before.\n"
"Check your choice to avoid redundant color changes."));
// Show list of actions with existing tick
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")) );
}
// Show list of actions with new tick
tooltip += ( m_mode == t_mode::MultiAsSingle ?
_(L("For add change extruder use left mouse button click")) :
_(L("For add color change use left mouse button click")) ) + " " +
_(L("OR pres \"+\" key")) + "\n" + (
is_osx ?
_(L("For add another code use Ctrl + Left mouse button click")) :
_(L("For add another code use right mouse button click")) );
}
if (tick_code_it != m_ticks.ticks.end()) // tick exists
{
// Show custom Gcode as a first string of tooltop
tooltip = " ";
tooltip += tick_code_it->gcode == ColorChangeCode ? (
m_mode == t_mode::SingleExtruder ?
from_u8((boost::format(_utf8(L("Color change (\"%1%\")"))) % tick_code_it->gcode ).str()) :
from_u8((boost::format(_utf8(L("Color change (\"%1%\") for Extruder %2%"))) %
tick_code_it->gcode % tick_code_it->extruder).str()) ) :
tick_code_it->gcode == PausePrintCode ?
from_u8((boost::format(_utf8(L("Pause print (\"%1%\")"))) % tick_code_it->gcode ).str()) :
tick_code_it->gcode == ToolChangeCode ?
from_u8((boost::format(_utf8(L("Extruder(tool) is changed to Extruder \"%1%\""))) % tick_code_it->extruder ).str()) :
from_u8((boost::format(_utf8(L("\"%1%\""))) % tick_code_it->gcode ).str()) ;
// If tick is marked as a conflict (exclamation icon),
// we should to explain why
ConflictType conflict = m_ticks.is_conflict_tick(*tick_code_it, m_mode, m_only_extruder, m_values[tick]);
if (conflict != ctNone)
tooltip += "\n\n" + _(L("Note")) + "! ";
if (conflict == ctModeConflict)
tooltip += _(L("G-code of this tick has a conflict with slider(print) mode.\n"
"Any its editing will cause a changes of DoubleSlider data."));
else if (conflict == ctMeaninglessColorChange)
tooltip += _(L("There is a color change for extruder that wouldn't be used till the end of printing.\n"
"This code wouldn't be processed during GCode generation."));
else if (conflict == ctMeaninglessToolChange)
tooltip += _(L("There is a extruder change to the same extruder.\n"
"This code wouldn't be processed during GCode generation."));
else if (conflict == ctRedundant)
tooltip += _(L("There is a color change for extruder that has not been used before.\n"
"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;