shpaass / yafc-ce

Powerful Factorio calculator/analyser that works with mods
GNU General Public License v3.0
40 stars 15 forks source link

Fix horizontal scrollbar #161

Closed veger closed 1 month ago

veger commented 1 month ago

I figured out that clicking the horizontal scrollbar was not possible because the 'click test' area did not match the actual drawn rectangle. This got fixed by d9f815158b71bb8aaab387600220a8281709e821.

In order to figure this out, I did some major documenting/cleanup to get an understanding of what Scrollable class was (intending) to do.

I hope that all new variable/field names make more sense now, if not let me know and we can figure out how to further improve them.

While I was at it I found some other 'oddities' that I fixed/improved:

I assume it would be easiest to review ecah commit separately, as the cleanup shuffled/renames quite come code. Which is much more apparent when reviewing the separate commits.

DaleStan commented 1 month ago

I'm still seeing a .5f vertical offset in the hit testing for both scrollbars. Is that just a me thing?

Good work on all the documentation and renaming

veger commented 1 month ago

I cannot reproduce the .5f offset. I tried with both a 1f and a 4f scrollbar sizes, and with either size clicks that are just outside of the 'scroller' are not registered and you cannot drag it.

I see only two (visual) glitches:

  1. Sometimes the scrollbars are drawn in the wrong place, triggering a UI (re)build (by clicking something for example) puts the bars to the correct places. I think it is because the UI contents is repositioned by the Scrollable cause the scrollarea dimensions to change. A followup rebuild uses the new dimensions, causing the bars to move to the correct places. (Fixing this would mean a complete overhaul of the UI system, as there is no way to find the bottom (height)/right (width) of the 'left over' area where the scrollable component needs to be placed. (The UI is 'fluid' and is build from the top/left)
  2. The vertical scrollbar is one ScrollbarSize from the window border. This is because the MainScreen is also has a scrollable (vertical only) for pages/tabs whose content does not fit. The UI system reserves this space for a scrollbar, even if it is hidden.