Ramming config improvements to enable support for Prusa MMU3 (#9935)

* Ported ramming configuration improvements from prusa slicer: Hold cmd to move all values, more granular time settings and higher maximum values.

* improve variable name, change space

* Move the label under the ramming chart

* Experimenting with values label for ramming chart

* Fix the label position and make the background 20% transparent

* update the way the multiline label is done

* reorder commands

---------

Co-authored-by: Noisyfox <timemanager.rick@gmail.com>
This commit is contained in:
Michele Stefanelli 2025-07-13 13:10:42 +01:00 committed by GitHub
parent b410154cb3
commit 686a9bd44a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 151 additions and 6 deletions

View file

@ -95,6 +95,40 @@ void Chart::draw() {
label = _(L("Volumetric speed")) + " (" + _("mm³/s") + ")";
dc.GetTextExtent(label,&text_width,&text_height);
dc.DrawRotatedText(label,wxPoint(0,0.5*(m_rect.GetBottom()+m_rect.GetTop())+text_width/2.f),90);
// draw a label with the value above each button
for (auto& button : m_buttons) {
if (!visible_area.Contains(button.get_pos()))
continue;
wxPoint button_screen_pos = math_to_screen(button.get_pos());
wxString value_label = wxString().Format(wxT("%.1f"), button.get_pos().m_y);
int label_width, label_height;
dc.GetTextExtent(value_label, &label_width, &label_height);
const int padding = 4;
// Calculate label x position
int label_x = button_screen_pos.x - (label_width/2); // centered with button
label_x = std::clamp(label_x, m_rect.GetLeft() + (padding*2), m_rect.GetRight() - label_width - (padding*2)); // adjust to fit within chart bounds
// Calculate label y position
int label_y = button_screen_pos.y - (side/2) - label_height - (padding*2); // above button
if (label_y - (padding*2) < m_rect.GetTop()) { // move below the button if there isn't enough space
label_y = button_screen_pos.y + (side/2) + (padding*2);
}
// Draw label background
dc.SetPen(wxPen(StateColor::darkModeColorFor(wxColour("#DBDBDB")), 1));
wxColour bg_color = StateColor::darkModeColorFor(wxColour("#F1F1F1"));
dc.SetBrush(wxBrush(wxColour(bg_color.Red(), bg_color.Green(), bg_color.Blue(), 204))); // 80% opacity
wxRect label_rect(label_x - padding, label_y - padding, label_width + (2*padding), label_height + (2*padding));
dc.DrawRoundedRectangle(label_rect, 2);
// Draw the label text
dc.SetTextForeground(StateColor::darkModeColorFor("#363636"));
dc.DrawText(value_label, wxPoint(label_x, label_y));
}
}
void Chart::mouse_right_button_clicked(wxMouseEvent& event) {
@ -111,6 +145,7 @@ void Chart::mouse_right_button_clicked(wxMouseEvent& event) {
void Chart::mouse_clicked(wxMouseEvent& event) {
m_uniform = (event.GetModifiers() == wxMOD_CONTROL);
wxPoint point = event.GetPosition();
int button_index = which_button_is_clicked(point);
if ( button_index != -1) {
@ -136,7 +171,15 @@ void Chart::mouse_moved(wxMouseEvent& event) {
}
int delta_x = pos.x - m_previous_mouse.x;
int delta_y = pos.y - m_previous_mouse.y;
m_dragged->move(fixed_x?0:double(delta_x)/m_rect.GetWidth() * visible_area.m_width,-double(delta_y)/m_rect.GetHeight() * visible_area.m_height);
double new_y = m_dragged->get_pos().m_y - double(delta_y) / m_rect.GetHeight() * visible_area.m_height;
if (m_uniform)
for (ButtonToDrag& b : m_buttons)
b.move(fixed_x?0:double(delta_x)/m_rect.GetWidth() * visible_area.m_width, new_y - b.get_pos().m_y);
else
m_dragged->move(fixed_x?0:double(delta_x)/m_rect.GetWidth() * visible_area.m_width, new_y - m_dragged->get_pos().m_y);
m_previous_mouse = pos;
recalculate_line();
}