Fixing a glitch in the data mapping widget (when editing the value, the node got deselected, but the colors boxes were still enabled)

This commit is contained in:
Matthias Koefferlein 2026-05-09 23:09:11 +02:00
parent 17f5b4f2da
commit 5c9ccf34f7
2 changed files with 41 additions and 37 deletions

View File

@ -314,46 +314,48 @@ PropertiesPage::min_max_value_changed ()
emit edited ();
}
bool
PropertiesPage::update_controls ()
{
bool has_error = false;
value_le->setText (QString ());
value_le->setEnabled (false);
colors->setEnabled (false_color_control->has_selection ());
colors->set_single_mode (false);
if (false_color_control->has_selection () && false_color_control->selected_node () > 0 && false_color_control->selected_node () < int (false_color_control->nodes ().size ()) - 1) {
double xmin, xmax;
get_xmin_xmax (xmin, xmax, has_error);
if (! has_error) {
double x = false_color_control->nodes () [false_color_control->selected_node ()].first;
double xx = x * (xmax - xmin) + xmin;
value_le->setText (tl::to_qstring (tl::sprintf ("%.4g", xx)));
value_le->setEnabled (true);
}
} else if (false_color_control->has_selection ()) {
colors->set_single_mode (true);
}
return has_error;
}
void
PropertiesPage::color_mapping_changed ()
{
if (! m_no_signals) {
bool has_error = false;
value_le->setText (QString ());
value_le->setEnabled (false);
colors->setEnabled (false_color_control->has_selection ());
colors->set_single_mode (false);
if (false_color_control->has_selection () && false_color_control->selected_node () > 0 && false_color_control->selected_node () < int (false_color_control->nodes ().size ()) - 1) {
double xmin, xmax;
get_xmin_xmax (xmin, xmax, has_error);
if (! has_error) {
double x = false_color_control->nodes () [false_color_control->selected_node ()].first;
double xx = x * (xmax - xmin) + xmin;
value_le->setText (tl::to_qstring (tl::sprintf ("%.4g", xx)));
value_le->setEnabled (true);
}
} else if (false_color_control->has_selection ()) {
colors->set_single_mode (true);
}
if (! has_error) {
m_in_color_mapping_signal = true;
emit edited ();
m_in_color_mapping_signal = false;
}
if (! m_no_signals && ! update_controls ()) {
m_in_color_mapping_signal = true;
emit edited ();
m_in_color_mapping_signal = false;
}
}
@ -509,6 +511,7 @@ PropertiesPage::update ()
m_no_signals = false;
update_controls ();
recompute_histogram ();
}

View File

@ -101,6 +101,7 @@ private:
void invalidate ();
void init ();
void get_xmin_xmax (double &xmin, double &xmax, bool &has_error_out);
bool update_controls ();
};
}