Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(editor/#1408): Smooth scroll w/ mousewheel #2880

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Components/Accordion/Component_Accordion.re
Original file line number Diff line number Diff line change
@@ -135,6 +135,7 @@ module Common = {
module VimList = {
let make =
(
~config,
~showCount=true,
~title,
~expanded,
@@ -150,6 +151,7 @@ module VimList = {
let count = Component_VimList.count(model);
let contents =
<Component_VimList.View
config
font=uiFont
isActive=isFocused
focusedIndex=None
2 changes: 2 additions & 0 deletions src/Components/Output/Component_Output.re
Original file line number Diff line number Diff line change
@@ -66,6 +66,7 @@ module View = {

let make =
(
~config,
~isActive,
~editorFont: Service_Font.font,
~uiFont: UiFont.t,
@@ -78,6 +79,7 @@ module View = {
let fg = Feature_Theme.Colors.Terminal.foreground.from(theme);
<View style=Style.[backgroundColor(bg), flexGrow(1)]>
<Component_VimList.View
config
isActive
font=uiFont
focusedIndex=None
1 change: 1 addition & 0 deletions src/Components/Output/Component_Output.rei
Original file line number Diff line number Diff line change
@@ -41,6 +41,7 @@ module Contributions: {
module View: {
let make:
(
~config: Config.resolver,
~isActive: bool,
~editorFont: Service_Font.font,
~uiFont: UiFont.t,
22 changes: 18 additions & 4 deletions src/Components/VimList/Component_VimList.re
Original file line number Diff line number Diff line change
@@ -790,7 +790,6 @@ module View = {
module Colors = Feature_Theme.Colors;

module Constants = {
let scrollWheelMultiplier = 25;
let additionalRowsToRender = 1;
let scrollBarThickness = 6;
let minimumThumbSize = 4;
@@ -969,6 +968,7 @@ module View = {
let component = React.Expert.component("Component_VimList");
let make:
(
~config: Config.resolver,
~isActive: bool,
~font: UiFont.t,
~focusedIndex: option(int),
@@ -986,7 +986,17 @@ module View = {
unit
) =>
_ =
(~isActive, ~font, ~focusedIndex, ~theme, ~model, ~dispatch, ~render, ()) => {
(
~config,
~isActive,
~font,
~focusedIndex,
~theme,
~model,
~dispatch,
~render,
(),
) => {
component(hooks => {
let {rowHeight, viewportWidth, viewportHeight, _} = model;

@@ -1005,8 +1015,12 @@ module View = {
hooks,
);
let scroll = (wheelEvent: NodeEvents.mouseWheelEventParams) => {
let delta =
wheelEvent.deltaY *. float(- Constants.scrollWheelMultiplier);
let mouseWheelPixels =
Feature_Configuration.GlobalConfiguration.Editor.mouseWheelScrollPixels.
get(
config,
);
let delta = wheelEvent.deltaY *. (-1.) *. mouseWheelPixels;

dispatch(MouseWheelScrolled({delta: delta}));
};
1 change: 1 addition & 0 deletions src/Components/VimList/dune
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
(public_name Oni2.component.vimList)
(inline_tests)
(libraries Oni2.core Oni2.component.inputText Oni2.components Revery
Oni2.feature.configuration
isolinear Oni2.feature.commands Oni2.feature.sneak)
(preprocess
(pps ppx_inline_test ppx_let ppx_deriving.show brisk-reconciler.ppx)))
1 change: 1 addition & 0 deletions src/Components/VimTree/Component_VimTree.re
Original file line number Diff line number Diff line change
@@ -529,6 +529,7 @@ module View = {
};

<Component_VimList.View
config
isActive
font
focusedIndex
3 changes: 3 additions & 0 deletions src/Feature/Configuration/GlobalConfiguration.re
Original file line number Diff line number Diff line change
@@ -225,6 +225,8 @@ module Editor = {
~default=true,
);

let mouseWheelScrollPixels =
setting("editor.mouseWheelScrollPixels", float, ~default=50.);
let lineHeight =
setting(
~vim=VimSettings.lineSpace,
@@ -312,6 +314,7 @@ let contributions = [
Editor.codeLensEnabled.spec,
Editor.largeFileOptimizations.spec,
Editor.lineHeight.spec,
Editor.mouseWheelScrollPixels.spec,
Editor.snippetSuggestions.spec,
Files.exclude.spec,
Explorer.autoReveal.spec,
38 changes: 25 additions & 13 deletions src/Feature/Editor/Feature_Editor.re
Original file line number Diff line number Diff line change
@@ -35,12 +35,16 @@ type outmsg =
type model = Editor.t;

module Constants = {
let editorWheelMultiplier = 50.;
let minimapWheelMultiplier = 150.;
let scrollbarWheelMultiplier = 300.;
let editorWheelMultiplier = 1.;
let minimapWheelMultiplier = 3.;
let scrollbarWheelMultiplier = 6.;
};

let update = (editor, msg) => {
let update = (~config, editor, msg) => {
let mouseWheelScroll =
Feature_Configuration.GlobalConfiguration.Editor.mouseWheelScrollPixels.get(
config,
);
switch (msg) {
| VerticalScrollbarAfterTrackClicked({newPixelScrollY})
| VerticalScrollbarBeforeTrackClicked({newPixelScrollY})
@@ -50,8 +54,9 @@ let update = (editor, msg) => {
)
| MinimapMouseWheel({deltaWheel}) => (
Editor.scrollDeltaPixelY(
~animated=false,
~pixelY=deltaWheel *. Constants.minimapWheelMultiplier,
~animated=true,
~pixelY=
deltaWheel *. mouseWheelScroll *. Constants.minimapWheelMultiplier,
editor,
),
Nothing,
@@ -66,18 +71,24 @@ let update = (editor, msg) => {
)
| EditorMouseWheel({deltaX, deltaY, shiftKey}) => (
Editor.scrollDeltaPixelXY(
~animated=false,
~animated=true,
~pixelX=
(shiftKey ? deltaY : deltaX) *. Constants.editorWheelMultiplier,
~pixelY=(shiftKey ? 0. : deltaY) *. Constants.editorWheelMultiplier,
(shiftKey ? deltaY : deltaX)
*. mouseWheelScroll
*. Constants.editorWheelMultiplier,
~pixelY=
(shiftKey ? 0. : deltaY)
*. mouseWheelScroll
*. Constants.editorWheelMultiplier,
editor,
),
Nothing,
)
| VerticalScrollbarMouseWheel({deltaWheel}) => (
Editor.scrollDeltaPixelY(
~animated=false,
~pixelY=deltaWheel *. Constants.scrollbarWheelMultiplier,
~animated=true,
~pixelY=
deltaWheel *. mouseWheelScroll *. Constants.scrollbarWheelMultiplier,
editor,
),
Nothing,
@@ -90,8 +101,9 @@ let update = (editor, msg) => {
)
| HorizontalScrollbarMouseWheel({deltaWheel}) => (
Editor.scrollDeltaPixelX(
~animated=false,
~pixelX=deltaWheel *. Constants.scrollbarWheelMultiplier,
~animated=true,
~pixelX=
deltaWheel *. mouseWheelScroll *. Constants.scrollbarWheelMultiplier,
editor,
),
Nothing,
1 change: 1 addition & 0 deletions src/Feature/Extensions/Feature_Extensions.rei
Original file line number Diff line number Diff line change
@@ -99,6 +99,7 @@ module ListView: {
let make:
(
~key: Brisk_reconciler.Key.t=?,
~config: Config.resolver,
~model: model,
~proxy: Service_Net.Proxy.t,
~theme: ColorTheme.Colors.t,
4 changes: 4 additions & 0 deletions src/Feature/Extensions/ListView.re
Original file line number Diff line number Diff line change
@@ -123,6 +123,7 @@ let versionToString: option(Semver.t) => string =

let%component make =
(
~config,
~model,
~proxy,
~theme,
@@ -220,6 +221,7 @@ let%component make =
[
<Component_Accordion.VimList
title="Installed"
config
expanded={installedExpanded || isInstalledFocused}
model={Model.ViewModel.installed(model.viewModel)}
uiFont=font
@@ -233,6 +235,7 @@ let%component make =
/>,
<Component_Accordion.VimList
title="Bundled"
config
expanded={bundledExpanded || isBundledFocused}
model={Model.ViewModel.bundled(model.viewModel)}
uiFont=font
@@ -249,6 +252,7 @@ let%component make =
} else {
let resultsList =
<Component_VimList.View
config
isActive={isInstalledFocused || isBundledFocused}
font
focusedIndex=None
3 changes: 2 additions & 1 deletion src/Feature/Notification/Feature_Notification.re
Original file line number Diff line number Diff line change
@@ -483,7 +483,7 @@ module Contributions = {
~sub=(~isFocused as _, _model) => Isolinear.Sub.none,
~view=
(
~config as _,
~config,
~editorFont as _,
~font,
~isFocused,
@@ -495,6 +495,7 @@ module Contributions = {
~model,
) =>
<Pane.View
config
uiFont=font
isFocused
theme
11 changes: 10 additions & 1 deletion src/Feature/Notification/Pane.re
Original file line number Diff line number Diff line change
@@ -162,7 +162,15 @@ module View = {
];
};
let make =
(~isFocused: bool, ~model: t, ~theme, ~uiFont: UiFont.t, ~dispatch, ()) => {
(
~config,
~isFocused: bool,
~model: t,
~theme,
~uiFont: UiFont.t,
~dispatch,
(),
) => {
let innerElement =
if (Component_VimList.count(model.notificationsView) == 0) {
<View style=Styles.noResultsContainer>
@@ -175,6 +183,7 @@ module View = {
</View>;
} else {
<Component_VimList.View
config
font=uiFont
isActive=isFocused
focusedIndex=None
16 changes: 14 additions & 2 deletions src/Feature/Output/Pane.re
Original file line number Diff line number Diff line change
@@ -55,10 +55,21 @@ let update = (msg, model) => {

module View = {
open Revery.UI;
let make = (~model, ~isActive, ~editorFont, ~uiFont, ~theme, ~dispatch, ()) => {
let make =
(
~config,
~model,
~isActive,
~editorFont,
~uiFont,
~theme,
~dispatch,
(),
) => {
model.output
|> Option.map(model => {
<Component_Output.View
config
model
isActive
editorFont
@@ -84,7 +95,7 @@ let pane = {
~sub=(~isFocused as _, _model) => Isolinear.Sub.none,
~view=
(
~config as _,
~config,
~editorFont,
~font,
~isFocused,
@@ -96,6 +107,7 @@ let pane = {
~model,
) =>
<View
config
editorFont
uiFont=font
isActive=isFocused
4 changes: 4 additions & 0 deletions src/Feature/SCM/Feature_SCM.re
Original file line number Diff line number Diff line change
@@ -1037,6 +1037,7 @@ module Pane = {

let groupView =
(
~config,
~provider,
~group: ResourceGroup.t,
~iconTheme,
@@ -1070,6 +1071,7 @@ module Pane = {
/>;
};
<Component_Accordion.VimList
config
title=label
expanded
uiFont=font
@@ -1087,6 +1089,7 @@ module Pane = {

let%component make =
(
~config,
~model,
~workingDirectory,
~isFocused,
@@ -1129,6 +1132,7 @@ module Pane = {
|> Option.value(~default=true);

<groupView
config
provider
expanded
group
1 change: 1 addition & 0 deletions src/Feature/SCM/Feature_SCM.rei
Original file line number Diff line number Diff line change
@@ -100,6 +100,7 @@ module Pane: {
let make:
(
~key: Brisk_reconciler.Key.t=?,
~config: Oni_Core.Config.resolver,
~model: model,
~workingDirectory: string,
~isFocused: bool,
Loading