Fix #117572: Top vertical scrollbar tool not working properly #117685

Closed
Philipp Oeser wants to merge 3 commits from lichtwerk/blender:117572 into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Member

Followup to ed556113ce

The issue ed556113ce was trying to solve was that custom masks for
scrollers were used for drawing but not for mouse interaction (so
interaction was not matching drawing in some cases, namely the File
Browser and Spreadsheet).

This was done by "re-using" what was written to v2d->hor & v2d->vert (in
drawing) as a new mask (in interaction). This caused a problem since
this already includes not only those custom masks but other stuff, too.
For example, view2d_masks shrinks the rect when
V2D_SCROLL_VERTICAL_HANDLES is used, after ed556113ce this was
effectively done twice.

To resolve, revert the way ed556113ce was "re-using" what was written to
v2d->hor & v2d->vert and instead use the exact same masks that the
FileBrowser and the Spreadsheet set up for drawing in mouse interaction
as well. This way the masks match perfectly for both cases (and we can
fully recalculate all v2d extends without reusing anything that we
shouldnt).

Followup to ed556113ce The issue ed556113ce was trying to solve was that custom masks for scrollers were used for drawing but not for mouse interaction (so interaction was not matching drawing in some cases, namely the File Browser and Spreadsheet). This was done by "re-using" what was written to v2d->hor & v2d->vert (in drawing) as a new mask (in interaction). This caused a problem since this already includes not only those custom masks but other stuff, too. For example, `view2d_masks` shrinks the rect when V2D_SCROLL_VERTICAL_HANDLES is used, after ed556113ce this was effectively done twice. To resolve, revert the way ed556113ce was "re-using" what was written to v2d->hor & v2d->vert and instead use the exact same masks that the FileBrowser and the Spreadsheet set up for drawing in mouse interaction as well. This way the masks match perfectly for both cases (and we can fully recalculate all v2d extends without reusing anything that we shouldnt).
Philipp Oeser added 1 commit 2024-01-31 09:22:13 +01:00
e48f52c43b Fix #117572: Top vertical scrollbar tool not working properly
Followup to ed556113ce

The issue ed556113ce was trying to solve was that custom masks for
scrollers were used for drawing but not for mouse interaction (so
interaction was not matching drawing in some cases, namely the File
Browser and Spreadsheet).

This was done by "re-using" what was written to v2d->hor & v2d->vert (in
drawing) as a new mask (in interaction). This caused a problem since
this already includes not only those custom masks but other stuff, too.
For example, `view2d_masks` shrinks the rect when
V2D_SCROLL_VERTICAL_HANDLES is used, after ed556113ce this was
effectively done twice.

To resolve, revert the way ed556113ce was "re-using" what was written to
v2d->hor & v2d->vert and instead use the exact same masks that the
FileBrowser and the Spreadsheet set up for drawing in mouse interaction
as well. This way the masks match perfectly for both cases (and we can
fully recalculate all v2d extends without reusing anything that we
shouldnt).
Philipp Oeser added this to the User Interface project 2024-01-31 09:22:33 +01:00
Philipp Oeser added the
Interest
Animation & Rigging
label 2024-01-31 09:22:42 +01:00
Philipp Oeser requested review from Harley Acheson 2024-01-31 09:23:04 +01:00
Philipp Oeser requested review from Julian Eisel 2024-01-31 09:23:12 +01:00
Philipp Oeser requested review from Hans Goudey 2024-01-31 09:23:18 +01:00
Hans Goudey requested changes 2024-01-31 22:16:12 +01:00
Hans Goudey left a comment
Member

I'm not familiar with this area, just trying to come up with something helpful to say. Mainly it seems nice to avoid checking for specific editor types in scroller_activate_init

I'm not familiar with this area, just trying to come up with something helpful to say. Mainly it seems nice to avoid checking for specific editor types in `scroller_activate_init`
@ -1917,0 +1916,4 @@
ScrArea *area = CTX_wm_area(C);
rcti scroller_mask;
bool use_scroller_mask = false;
if (area->spacetype == SPACE_FILE) {
Member

Putting checks for specific space types in the 2D view code is a bit hacky/ugly. It's a leaky abstraction that would be nice to avoid.

Putting checks for specific space types in the 2D view code is a bit hacky/ugly. It's a leaky abstraction that would be nice to avoid.
Author
Member

Hm, if an editor can mess with v2d data on its own behalf (without letting a trace that it did), I am not sure how this could be handled better? But if it did, we have to make sure we can repeat the same modifications it did for drawing for mouse interaction as well, no?

Maybe @ideasman42 has a better idea?

Hm, if an editor can mess with v2d data on its own behalf (without letting a trace that it did), I am not sure how this could be handled better? But if it did, we have to make sure we can repeat the same modifications it did for drawing for mouse interaction as well, no? Maybe @ideasman42 has a better idea?
Member

Hmm, okay. Thanks for bearing with me. Would an alternative be storing information in the View2D that told it enough information about the scrollers? I guess scrolling (part of?) scroller_mask there? I'd usually try not to store things that can just be computed from scratch, but these are two very different code paths. I'm basically just trying to think of a way to make this not add complexity long term.

Hmm, okay. Thanks for bearing with me. Would an alternative be storing information in the View2D that told it enough information about the scrollers? I guess scrolling (part of?) `scroller_mask` there? I'd usually try not to store things that can just be computed from scratch, but these are two very different code paths. I'm basically just trying to think of a way to make this not add complexity long term.
Author
Member

guess this could be done, would appreciate feedback from others if putting additional stuff into View2D is preferred

guess this could be done, would appreciate feedback from others if putting additional stuff into View2D is preferred
Member

Maybe I am misunderstanding, but would this be helped with an optional SpaceType callback that returns this rect? Then instead of testing for a specific spacetype just check for the callback?

Maybe I am misunderstanding, but would this be helped with an optional SpaceType callback that returns this rect? Then instead of testing for a specific spacetype just check for the callback?
Author
Member

@Harley : think a spacetype callback is too general, this (at least in theory) could have multiple regions with scrollers (each could have set up own masks)

@Harley : think a spacetype callback is too general, this (at least in theory) could have multiple regions with scrollers (each could have set up own masks)
Author
Member

Would an alternative be storing information in the View2D that told it enough information about the scrollers? I guess scrolling (part of?) scroller_mask there? I'd usually try not to store things that can just be computed from scratch, but these are two very different code paths. I'm basically just trying to think of a way to make this not add complexity long term.

For reference, rcti vert, hor is already for scrollbars, it is just that these are set from one place for drawing and recalculated for interaction. ed556113ce reused those rects, but then again there is this case of V2D_SCROLL_VERTICAL_HANDLES in view2d_masks which does not fit the current approach (but I think I already explained that?).

> Would an alternative be storing information in the View2D that told it enough information about the scrollers? I guess scrolling (part of?) `scroller_mask` there? I'd usually try not to store things that can just be computed from scratch, but these are two very different code paths. I'm basically just trying to think of a way to make this not add complexity long term. For reference, `rcti vert, hor` is already for scrollbars, it is just that these are set from one place for drawing and recalculated for interaction. ed556113ce reused those rects, but then again there is this case of `V2D_SCROLL_VERTICAL_HANDLES` in `view2d_masks` which does not fit the current approach (but I think I already explained that?).
@ -462,7 +473,6 @@ static void spreadsheet_main_region_draw(const bContext *C, ARegion *region)
spreadsheet_layout.index_column_width = get_index_column_width(tot_rows);
spreadsheet_layout.row_indices = spreadsheet_filter_rows(
*sspreadsheet, spreadsheet_layout, *data_source, scope);
Member

Unrelated change

Unrelated change
lichtwerk marked this conversation as resolved
@ -431,6 +431,17 @@ static void update_visible_columns(ListBase &columns, DataSource &data_source)
});
}
void ED_spreadsheet_layout_maskrect(const SpaceSpreadsheet *sspreadsheet,
Member

Return rcti by value, make pointers into references

Return `rcti` by value, make pointers into references
lichtwerk marked this conversation as resolved
@ -16,13 +20,14 @@
#include "spreadsheet_draw.hh"
#define CELL_RIGHT_PADDING (2.0f * UI_SCALE_FAC)
#define TOP_ROW_HEIGHT (UI_UNIT_Y * 1.1f)
Member

Unnecessary change moving this to a define? Or sort of seems like this is conflicting with the one in ED_spreadsheet.hh

Unnecessary change moving this to a define? Or sort of seems like this is conflicting with the one in `ED_spreadsheet.hh`
lichtwerk marked this conversation as resolved
Philipp Oeser added 2 commits 2024-02-01 14:08:17 +01:00
Philipp Oeser requested review from Hans Goudey 2024-02-01 14:17:24 +01:00
Author
Member

I can think of other approaches as well:

  • [1] move the following code out of view2d_masks and into respective editors drawing code (make a maskrect there)
    -- it is a bit of a weak assumption anyways (should depend more on the editor itself, not only the fact that V2D_SCROLL_VERTICAL_HANDLES is used
    -- this way it would only be done once, not twice
    -- (I dont like this solution much since it still reuse previously calculated rects for View2D vert / hor when re-calculating them from scratch [the weak hack from ed556113ce])
/* Currently, all regions that have vertical scale handles,
  * also have the scrubbing area at the top.
  * So the scroll-bar has to move down a bit. */
 if (scroll & V2D_SCROLL_VERTICAL_HANDLES) {
   v2d->vert.ymax -= UI_TIME_SCRUB_MARGIN_Y;
}
  • [2] remove the ability to pass in a custom mask into UI_view2d_scrollers_draw and do all specific editor cases inside view2d_scrollers_calc
    -- ensures this is consistent across drawing and interaction code
I can think of other approaches as well: - [1] move the following code out of `view2d_masks` and into respective editors drawing code (make a maskrect there) -- it is a bit of a weak assumption anyways (should depend more on the editor itself, not only the fact that `V2D_SCROLL_VERTICAL_HANDLES` is used -- this way it would only be done once, not twice -- (I dont like this solution much since it still reuse previously calculated rects for `View2D` `vert` / `hor` when re-calculating them from scratch [the weak hack from ed556113ce]) ``` /* Currently, all regions that have vertical scale handles, * also have the scrubbing area at the top. * So the scroll-bar has to move down a bit. */ if (scroll & V2D_SCROLL_VERTICAL_HANDLES) { v2d->vert.ymax -= UI_TIME_SCRUB_MARGIN_Y; } ``` - [2] remove the ability to pass in a custom mask into `UI_view2d_scrollers_draw` and do all specific editor cases inside `view2d_scrollers_calc` -- ensures this is consistent across drawing and interaction code
Member

Submitted !117984 as an alternative. It avoids & removes special handling inside View2D and lets editors control the scroller masks fully. The way we reconstruct the custom scroller mask inside scroller_activate_init() seems reliable to me. If it causes issues we can still store the custom mask (noted in comment).

Submitted !117984 as an alternative. It avoids & removes special handling inside `View2D` and lets editors control the scroller masks fully. The way we reconstruct the custom scroller mask inside `scroller_activate_init()` seems reliable to me. If it causes issues we can still store the custom mask (noted in comment).
Author
Member

Submitted !117984 as an alternative. It avoids & removes special handling inside View2D and let's editors control the scroller masks fully. The way we reconstruct the custom scroller mask inside scroller_activate_init() seems reliable to me. If it causes issues we can still store the custom mask (noted in comment).

OK, that is basically what I suggested in my previous comment in [1], fine with that as well (and thx putting the PR up), will leave a comment in !117984

Think we can close this one already then.

> Submitted !117984 as an alternative. It avoids & removes special handling inside `View2D` and let's editors control the scroller masks fully. The way we reconstruct the custom scroller mask inside `scroller_activate_init()` seems reliable to me. If it causes issues we can still store the custom mask (noted in comment). OK, that is basically what I suggested in my previous comment in [1], fine with that as well (and thx putting the PR up), will leave a comment in !117984 Think we can close this one already then.
Philipp Oeser closed this pull request 2024-02-08 13:19:34 +01:00

Pull request closed

Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#117685
No description provided.