Commit d0568dd Swagtoy
committed
1 parent fb1b987 commit d0568dd Copy full SHA for d0568dd
File tree 3 files changed +16
-3
lines changed
3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -703,6 +703,14 @@ gui_scaling (GUI scaling) float 1.0 0.5 20
703
703
# Enables smooth scrolling.
704
704
smooth_scrolling (Smooth scrolling) bool true
705
705
706
+ # Enables elastic smooth scrolling.
707
+ elastic_smooth_scrolling (Elastic smooth scrolling) bool true
708
+
709
+ # Enables precise scrolling.
710
+ # Helpful for most modern trackpads that have pixel-perfect scroll precision. (and even some mice)
711
+ # Keep this disabled if your trackpad is scrolling too slowly.
712
+ precision_scrolling (Precision scrolling) bool false
713
+
706
714
# Enables animation of inventory items.
707
715
inventory_items_animations (Inventory items animations) bool false
708
716
Original file line number Diff line number Diff line change @@ -295,6 +295,8 @@ void set_default_settings()
295
295
settings->setDefault (" gui_scaling_filter" , " false" );
296
296
settings->setDefault (" gui_scaling_filter_txr2img" , " true" );
297
297
settings->setDefault (" smooth_scrolling" , " true" );
298
+ settings->setDefault (" elastic_smooth_scrolling" , " true" );
299
+ settings->setDefault (" precision_scrolling" , " false" );
298
300
settings->setDefault (" desynchronize_mapblock_texture_animation" , " false" );
299
301
settings->setDefault (" hud_hotbar_max_width" , " 1.0" );
300
302
settings->setDefault (" enable_local_map_saving" , " false" );
Original file line number Diff line number Diff line change @@ -263,15 +263,17 @@ void GUIScrollBar::setPosRaw(const s32 &pos)
263
263
thumb_size = (s32)std::fmin (S32_MAX,
264
264
thumb_area / (f32 (page_size) / f32 (thumb_area + border_size * 2 )));
265
265
266
+ bool is_elastic = g_settings->getBool (" elastic_smooth_scrolling" );
267
+ int elastic_amount = is_elastic ? 20 : 0 ;
266
268
thumb_size = core::s32_clamp (thumb_size, thumb_min, thumb_area);
267
- scroll_pos = core::s32_clamp (pos, min_pos-20 , max_pos+20 );
269
+ scroll_pos = core::s32_clamp (pos, min_pos-elastic_amount , max_pos+elastic_amount );
268
270
// scroll_pos = pos;
269
271
270
272
if (!is_dragging)
271
273
{
272
274
// TODO support deltatime
273
275
if (scroll_pos < 0 ) {
274
- target_pos = (target_pos * 0.9 );
276
+ target_pos = is_elastic ? (target_pos * 0.9 ) : min_pos ;
275
277
}
276
278
else if (scroll_pos > max_pos) {
277
279
target_pos += (target_pos - max_pos) * -0.3 ;
@@ -306,12 +308,13 @@ void GUIScrollBar::setPosAndSend(const s32 &pos)
306
308
307
309
void GUIScrollBar::setPosInterpolated (const s32 &pos)
308
310
{
311
+ bool is_elastic = g_settings->getBool (" elastic_smooth_scrolling" );
309
312
if (!g_settings->getBool (" smooth_scrolling" )) {
310
313
setPosAndSend (pos);
311
314
return ;
312
315
}
313
316
314
- target_pos = pos;
317
+ target_pos = is_elastic ? pos : core::s32_clamp (pos, min_pos, max_pos) ;
315
318
interpolatePos ();
316
319
}
317
320
You can’t perform that action at this time.
0 commit comments