Skip to content

Commit

Permalink
Push temp changes for input
Browse files Browse the repository at this point in the history
  • Loading branch information
szbergeron committed Feb 26, 2020
1 parent 9b80ce6 commit fef8273
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "*",
Expand All @@ -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",
Expand Down
7 changes: 7 additions & 0 deletions src/UI/NodeEvents.re
Original file line number Diff line number Diff line change
Expand Up @@ -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})]
Expand Down Expand Up @@ -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;
Expand Down
26 changes: 25 additions & 1 deletion src/UI_Components/ScrollView.re
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit fef8273

Please sign in to comment.