Skip to content

Commit

Permalink
Disable smooth scrolling in terminal
Browse files Browse the repository at this point in the history
Merge pull request directvt#442 from o-sdn-o/vt-input-mode
  • Loading branch information
o-sdn-o authored Oct 20, 2023
2 parents 5327b3c + 7e7eac8 commit b2f073b
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/netxs/apps/term.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ namespace netxs::app::term
auto term_stat_area = object->attach(slot::_2, ui::fork::ctor(axis::Y));
auto layers = term_stat_area->attach(slot::_1, ui::cake::ctor())
->limits(dot_11, { 400,200 });
auto scroll = layers->attach(ui::rail::ctor());
auto scroll = layers->attach(ui::rail::ctor()->smooth(faux));
auto min_size = twod{ 12,1 }; // mc crashes when window is too small
auto max_size = -dot_11;
scroll->limits(min_size, max_size)
Expand Down
1 change: 1 addition & 0 deletions src/netxs/desktopio/baseui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ namespace netxs::ui
si32 spd_max;
si32 ccl_max;
si32 switching;
si32 wheel_dt;
span deceleration;
span blink_period;
span menu_timeout;
Expand Down
1 change: 1 addition & 0 deletions src/netxs/desktopio/console.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,7 @@ namespace netxs::ui
auto& canal = *server;

auto& g = skin::globals();
g.wheel_dt = config.take("wheel_dt" , 3 );
g.brighter = config.take("brighter" , cell{});//120);
g.kb_focus = config.take("kb_focus" , cell{});//60
g.shadower = config.take("shadower" , cell{});//180);//60);//40);// 20);
Expand Down
51 changes: 35 additions & 16 deletions src/netxs/desktopio/controls.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3078,6 +3078,7 @@ namespace netxs::ui
twod oversc; // rail: Allow overscroll with auto correct.
subs fasten; // rail: Subscriptions on masters to follow they state.
rack scinfo; // rail: Scroll info.
bool animat; // rail: Smooth scrolling.

si32 spd = skin::globals().spd;
si32 pls = skin::globals().pls;
Expand All @@ -3087,6 +3088,7 @@ namespace netxs::ui
si32 spd_max = skin::globals().spd_max;
si32 ccl_max = skin::globals().ccl_max;
si32 switching = skin::globals().switching;
si32 wheel_dt = skin::globals().wheel_dt;

si32 speed{ spd }; // rail: Text auto-scroll initial speed component ΔR.
si32 pulse{ pls }; // rail: Text auto-scroll initial speed component ΔT.
Expand All @@ -3105,12 +3107,13 @@ namespace netxs::ui
}

protected:
rail(axes allow_to_scroll = axes::all, axes allow_to_capture = axes::all, axes allow_overscroll = axes::all)
rail(axes allow_to_scroll = axes::all, axes allow_to_capture = axes::all, axes allow_overscroll = axes::all, bool smooth_scrolling = true)
: permit{ xy(allow_to_scroll) },
siezed{ xy(allow_to_capture) },
oversc{ xy(allow_overscroll) },
strict{ xy(axes::all) },
manual{ xy(axes::all) }
manual{ xy(axes::all) },
animat{ smooth_scrolling }
{
LISTEN(tier::preview, e2::form::upon::scroll::any, info) // Receive scroll parameters from external sources.
{
Expand Down Expand Up @@ -3265,6 +3268,12 @@ namespace netxs::ui
}

public:
// rail: .
auto smooth(bool smooth_scroll = true)
{
animat = smooth_scroll;
return This();
}
// rail: .
template<axis Axis>
auto follow(sptr master = {})
Expand Down Expand Up @@ -3299,25 +3308,35 @@ namespace netxs::ui
template<axis Axis>
void wheels(bool dir)
{
if (robot.active(Axis) && (steer == dir))
if (animat)
{
speed += spd_accel;
cycle += ccl_accel;
speed = std::min(speed, spd_max);
cycle = std::min(cycle, ccl_max);
if (robot.active(Axis) && (steer == dir))
{
speed += spd_accel;
cycle += ccl_accel;
speed = std::min(speed, spd_max);
cycle = std::min(cycle, ccl_max);
}
else
{
steer = dir;
speed = spd;
cycle = ccl;
//todo at least one line should be
//move<Axis>(dir ? 1 : -1);
}
auto start = 0;
auto boost = dir ? speed : -speed;
if constexpr (Axis == X) boost *= 2;
keepon<Axis>(quadratic<si32>(boost, pulse, cycle, start));
}
else
{
steer = dir;
speed = spd;
cycle = ccl;
//todo at least one line should be
//move<Axis>(dir ? 1 : -1);
auto speed = dir ? wheel_dt : -wheel_dt;
auto delta = Axis == X ? twod{ speed * 2, 0 }
: twod{ 0, speed };
scroll(delta);
}
auto start = 0;
auto boost = dir ? speed : -speed;
if constexpr (Axis == X) boost *= 2;
keepon<Axis>(quadratic<si32>(boost, pulse, cycle, start));
}
// rail: .
template<axis Axis, class Fx>
Expand Down
1 change: 1 addition & 0 deletions src/vtm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ R"==(
<appearance>
<defaults>
<fps = 60 />
<wheel_dt = 3 /> <!-- Mouse scrolling wheel step (non-smooth scrolling). -->
<bordersz = 1,1 />
<lucidity = 0xff /> <!-- not implemented -->
<tracking = off /> <!-- Mouse cursor highlighting. -->
Expand Down

0 comments on commit b2f073b

Please sign in to comment.