idk work (r + h)

This commit is contained in:
2025-12-11 23:05:27 -05:00
parent a70d09e162
commit a708813ce7
11 changed files with 152 additions and 102 deletions

View File

@@ -6,7 +6,7 @@ use std::{
};
#[derive(Clone, Copy, PartialEq)]
pub enum Button {
pub enum CursorButton {
Left,
Right,
Middle,
@@ -14,9 +14,9 @@ pub enum Button {
#[derive(Clone, Copy, PartialEq)]
pub enum CursorSense {
PressStart(Button),
Pressing(Button),
PressEnd(Button),
PressStart(CursorButton),
Pressing(CursorButton),
PressEnd(CursorButton),
HoverStart,
Hovering,
HoverEnd,
@@ -27,16 +27,16 @@ pub struct CursorSenses(Vec<CursorSense>);
impl CursorSense {
pub fn click() -> Self {
Self::PressStart(Button::Left)
Self::PressStart(CursorButton::Left)
}
pub fn click_or_drag() -> CursorSenses {
Self::click() | Self::Pressing(Button::Left)
Self::click() | Self::Pressing(CursorButton::Left)
}
pub fn unclick() -> Self {
Self::PressEnd(Button::Left)
Self::PressEnd(CursorButton::Left)
}
pub fn is_dragging(&self) -> bool {
matches!(self, CursorSense::Pressing(Button::Left))
matches!(self, CursorSense::Pressing(CursorButton::Left))
}
}
@@ -56,11 +56,11 @@ pub struct CursorButtons {
}
impl CursorButtons {
pub fn select(&self, button: &Button) -> &ActivationState {
pub fn select(&self, button: &CursorButton) -> &ActivationState {
match button {
Button::Left => &self.left,
Button::Right => &self.right,
Button::Middle => &self.middle,
CursorButton::Left => &self.left,
CursorButton::Right => &self.right,
CursorButton::Middle => &self.middle,
}
}

View File

@@ -89,7 +89,7 @@ widget_trait! {
move |ui| {
Scroll::new(self.add(ui), Axis::Y)
.on(CursorSense::Scroll, |ctx| {
let s = &mut ctx.ui[ctx.id];
let s = &mut ctx.ui[ctx.widget];
s.scroll(ctx.data.scroll_delta.y * 50.0);
})
.add(ui)