Skip to content

web/gui: add an option for arrow keys scroll acceleration - #10983

Draft
SquareRobin wants to merge 5 commits into
The-OpenROAD-Project:masterfrom
SquareRobin:arrow-scroll-accel-option
Draft

web/gui: add an option for arrow keys scroll acceleration#10983
SquareRobin wants to merge 5 commits into
The-OpenROAD-Project:masterfrom
SquareRobin:arrow-scroll-accel-option

Conversation

@SquareRobin

@SquareRobin SquareRobin commented Jul 24, 2026

Copy link
Copy Markdown

Summary

Scrolling with the arrow keys is convenient, but the acceleration is controlled only by the system. Adding an option for acceleration does not overcomplicate the settings and makes arrow keys scrolling a bit more practical.
Testing with different key repeat settings did not reveal any problems related to different auto-repeat frequencies and delays.

Type of Change

  • New feature

Impact

Adds a checkbox to the "Options" menu.

Verification

  • I have verified that the local build succeeds (./etc/Build.sh).
  • I have run the relevant tests and they pass.
  • My code follows the repository's formatting guidelines.
  • I have signed my commits (DCO).

Signed-off-by: Igor Sokolov <disk.destroyer@yahoo.com>
@SquareRobin
SquareRobin requested a review from a team as a code owner July 24, 2026 14:50
@SquareRobin
SquareRobin requested a review from gadfort July 24, 2026 14:50

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces an option to enable scroll acceleration when using arrow keys in the GUI layout viewer. It propagates the new configuration option through the MainWindow, LayoutTabs, and LayoutScroll classes, and implements the acceleration logic in LayoutScroll's key press event handler. The review feedback suggests aligning the newly added member variables and constants with the project's naming conventions (using snake_case_ and kCamelCase). Additionally, it recommends refining the acceleration logic by using floating-point division with rounding to prevent abrupt jumps caused by integer division, and resetting the acceleration counter when the active scroll key changes.

Comment thread src/gui/src/layoutViewer.h Outdated
Comment thread src/gui/src/layoutViewer.cpp
Igor Sokolov added 4 commits July 24, 2026 17:53
Signed-off-by: Igor Sokolov <disk.destroyer@yahoo.com>
switch to float with static_cast to int in the multiplier calculation

Signed-off-by: Igor Sokolov <disk.destroyer@yahoo.com>
Signed-off-by: Igor Sokolov <disk.destroyer@yahoo.com>
Signed-off-by: Igor Sokolov <disk.destroyer@yahoo.com>

@gadfort gadfort left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that the scrolling seems to exceed the speed of the rendering in the GUI, probably not a huge problem, but odd.
Also, we are moving away from the GUI into the web viewer, would you want to try and port these changes over there as well?

int accel_counter_ = 0;
static constexpr int kAccelLutSize = 20;
static constexpr int kAccelCounterMax = kAccelLutSize - 1;
static std::array<int, kAccelLutSize> accel_lut_;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how much this being static saves, is there is a way to mark is const that would make it clear that this is not going to change.

static constexpr int kAccelLutSize = 20;
static constexpr int kAccelCounterMax = kAccelLutSize - 1;
static std::array<int, kAccelLutSize> accel_lut_;
int getScrollAcceleration() const { return accel_lut_[accel_counter_]; };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe use std::clamp() to ensure accel_counter is inside the array

void LayoutScroll::keyPressEvent(QKeyEvent* event)
{
switch (event->key()) {
Qt::Key key = static_cast<Qt::Key>(event->key());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const?

Comment on lines +2766 to +2768
if (accel_counter_ < kAccelCounterMax) {
accel_counter_++;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this go after getScollAcceleration? It seems like you would ways get index 1 and index 0 is doing nothing.

@SquareRobin

Copy link
Copy Markdown
Author

I'll look into porting this to the web interface.

As for the slow rendering, making the acceleration curve proportionate to the viewer zoom factor and size should help.

@SquareRobin
SquareRobin marked this pull request as draft August 3, 2026 09:04
@SquareRobin SquareRobin changed the title gui: add an option for arrow keys scroll acceleration web/gui: add an option for arrow keys scroll acceleration Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants