Skip to content

Commit

Permalink
mark response as changed when one of the two sliders is dragged
Browse files Browse the repository at this point in the history
  • Loading branch information
hacknus committed Nov 1, 2024
1 parent b3c4303 commit 52ca464
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion crates/egui/src/widgets/double_slider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl<'a> Widget for DoubleSlider<'a> {
// calculate height
let height = 2.0 * self.control_point_radius + 2.0 * OFFSET;

let (response, painter) =
let (mut response, painter) =
ui.allocate_painter(Vec2::new(self.width, height), Sense::hover());
let mut left_edge = response.rect.left_center();
left_edge.x += self.control_point_radius;
Expand Down Expand Up @@ -152,6 +152,10 @@ impl<'a> Widget for DoubleSlider<'a> {
let point_id = response.id.with(0);
let point_response = ui.interact(point_rect, point_id, Sense::drag());

if point_response.dragged() {
response.mark_changed();
}

// handle logic
*self.left_slider += self.x_to_val(point_response.drag_delta().x);
if *self.right_slider < *self.left_slider + self.separation_distance {
Expand Down Expand Up @@ -186,6 +190,10 @@ impl<'a> Widget for DoubleSlider<'a> {
let point_id = response.id.with(1);
let point_response = ui.interact(point_rect, point_id, Sense::drag());

if point_response.dragged() {
response.mark_changed();
}

// handle logic
*self.right_slider += self.x_to_val(point_response.drag_delta().x);
if *self.left_slider > *self.right_slider - self.separation_distance {
Expand Down

0 comments on commit 52ca464

Please sign in to comment.