diff --git a/package.json b/package.json index 61bb75dff..d6054a613 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "reason-harfbuzz": "^1.91.5004", "rench": "^1.9.1", "rebez": "github:jchavarri/rebez#03fa3b7", - "reason-sdl2": "^2.10.3016", + "reason-sdl2": "*", "reason-skia": "github:revery-ui/reason-skia#69743dc", "revery-text-wrap": "github:revery-ui/revery-text-wrap#005385c", "timber": "*", @@ -64,7 +64,8 @@ "esy-cmake": "prometheansacrifice/esy-cmake#2a47392def755", "@opam/cmdliner": "1.0.2", "timber": "glennsl/timber#ae065bb", - "libscroll": "link:../libscroll-re" + "libscroll": "link:../libscroll-re", + "reason-sdl2": "link:../../revery-bryphe/reason-sdl2" }, "devDependencies": { "ocaml": "~4.8", diff --git a/src/UI/NodeEvents.re b/src/UI/NodeEvents.re index de8e14ffa..2621d0fb2 100644 --- a/src/UI/NodeEvents.re +++ b/src/UI/NodeEvents.re @@ -21,6 +21,12 @@ type mouseButtonEventParams = { type mouseWheelEventParams = { deltaX: float, deltaY: float, + containsX: bool, + containsY: bool, + isFling: bool, + isInterrupt: bool, + source: Sdl2.WheelType.t, + timestamp: int, }; [@deriving show({with_path: false})] @@ -83,6 +89,7 @@ type mouseMoveHandler = mouseMoveEventParams => unit; type mouseOverHandler = mouseMoveEventParams => unit; type mouseOutHandler = mouseMoveEventParams => unit; type mouseWheelHandler = mouseWheelEventParams => unit; +type panHandler = panEventParams => unit; type mouseWindowHandler = Window.t => unit; type focusHandler = focusEventParams => unit; type keyDownHandler = keyEventParams => unit; diff --git a/src/UI_Components/ScrollView.re b/src/UI_Components/ScrollView.re index 35ce76d55..854b93013 100644 --- a/src/UI_Components/ScrollView.re +++ b/src/UI_Components/ScrollView.re @@ -57,8 +57,18 @@ let%component make = let%hook (actualScrollLeft, setScrollLeft) = Hooks.state(scrollLeft); let%hook (bouncingState, setBouncingState) = Hooks.state(Idle); - let%hook (scrollview, setScrollview) = Hooks.state(() => Libscroll.scrollview_new()); + //let%hook (scrollview, setScrollview) = Hooks.state(() => Libscroll.scrollview_new()); //setScrollview(_ => scrollview); + let%hook (scrollViewRef) = Hooks.ref(None); + let%hook () = Hooks.effect(OnMount, () => { + let scrollView = Libscroll.scrollview_new(); + scrollViewRef := Some(scrollView); + + let dispose = () => { + scrollViewRef := None; + }; + Some(dispose); + }); let%hook (actualScrollTop, _bounceAnimationState, resetBouncingAnimation) = switch (bouncingState) { @@ -157,8 +167,22 @@ let%component make = thumbColor=scrollThumbColor /> : empty; + + /*let pan = (panEvent: NodeEvents.panEventParams) => { + switch (scrollViewRef^) { + | None => () + | Some(scrollview) => { + let timestamp = wheelEvent.timestamp; + let delta = wheelEvent.delta; + let axis = wheelEvent.axis; + } + }*/ let scroll = (wheelEvent: NodeEvents.mouseWheelEventParams) => { + switch (scrollViewRef^) { + | Some(scrollview) => Libscroll.push_pan(scrollview, Libscroll.Vertical, 10.0) + | None => () + } let delta = int_of_float(wheelEvent.deltaY *. 25.); let newScrollTop = actualScrollTop - delta;