Skip to content

Commit

Permalink
Splitter: fix grabbing offset for reversed direction
Browse files Browse the repository at this point in the history
  • Loading branch information
dhardy committed Dec 20, 2023
1 parent 643fdd6 commit c181c49
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions crates/kas-widgets/src/splitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,16 @@ impl_scope! {
fn handle_messages(&mut self, cx: &mut EventCx, _: &Self::Data) {
if let Some(index) = cx.last_child() {
if (index & 1) == 1 {
if let Some(GripMsg::PressMove(offset)) = cx.try_pop() {
if let Some(GripMsg::PressMove(mut offset)) = cx.try_pop() {
let n = index >> 1;
assert!(n < self.grips.len());
let action = self.grips[n].set_offset(offset).1;
cx.action(&self, action);
if let Some(grip) = self.grips.get_mut(n) {
if self.direction.is_reversed() {
offset = Offset::conv(grip.track().size) - offset;
}
let action = grip.set_offset(offset).1;
cx.action(&self, action);
}
self.adjust_size(&mut cx.config_cx(), n);
}
}
Expand Down

0 comments on commit c181c49

Please sign in to comment.