Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScrollView in Qt - setting visibleOrigin doesn't work unless deferred #823

Closed
txmod opened this issue Apr 20, 2013 · 0 comments
Closed

ScrollView in Qt - setting visibleOrigin doesn't work unless deferred #823

txmod opened this issue Apr 20, 2013 · 0 comments
Labels
bug Issues that relate to unexpected/unwanted behavior. Don't use for PRs. comp: Qt GUI sclang Qt components -- for IDE tickets, use "env: SCIDE" instead fix proposed
Milestone

Comments

@txmod
Copy link

txmod commented Apr 20, 2013

(Found using SC 3.6.3 with Qt on OS X 10.7.4.)

Setting visibleOrigin doesn't work unless you defer a bit after the view is created .

EXAMPLE CODE:

(
// Window 1 -
w = Window.new("visibleOrigin not updated", Rect(10, 700, 400, 400)).front;

b = ScrollView(w, Rect(0, 0, 300, 300)).hasBorder_(true);
c = CompositeView(b, Rect(0, 0, 500, 500)); // 'canvas' is this big
c.decorator = FlowLayout(c.bounds); // now we can use a decorator

Slider2D(c, Rect(0, 0, 240, 240));
Slider2D(c, Rect(0, 0, 240, 240));
Slider2D(c, Rect(0, 0, 240, 240));

c.decorator.nextLine;
w.front;

b.visibleOrigin = Point(50,50);

// Window 2 -
w = Window.new("visibleOrigin is updated", Rect(610, 700, 400, 400)).front;

b = ScrollView(w, Rect(0, 0, 300, 300)).hasBorder_(true);
c = CompositeView(b, Rect(0, 0, 500, 500)); // 'canvas' is this big
c.decorator = FlowLayout(c.bounds); // now we can use a decorator

Slider2D(c, Rect(0, 0, 240, 240));
Slider2D(c, Rect(0, 0, 240, 240));
Slider2D(c, Rect(0, 0, 240, 240));

c.decorator.nextLine;
w.front;

{b.visibleOrigin = Point(50,50);}.defer(0.01);
)

@scztt scztt modified the milestone: 3.7 Apr 18, 2015
scztt added a commit that referenced this issue May 24, 2015
Setting some geometry-related properties at view creation time gets a bit weird, because layout is often not calculated immediately. In case of #823, the initial layout of the view gets calculated in a slightly deferred event fired in response to .front(), meaning that when visibleOrigin_ is called, the scrollbars still haven't been adjusted according to the layed-out window contents (specifically, at creation time the max scroll value is 0). Fixing this by getting layout to happen at the right time is hard - fortunately, it looks like scrollbar behavior is smart enough that, when we request a specific visibleOrigin, we can simply increase the scrollbar max value as needed - even when manually setting a max, the scrollbars seem to re-adjust properly as the contents of the scroll area are sized.
@telephon telephon closed this as completed Jun 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues that relate to unexpected/unwanted behavior. Don't use for PRs. comp: Qt GUI sclang Qt components -- for IDE tickets, use "env: SCIDE" instead fix proposed
Projects
None yet
Development

No branches or pull requests

3 participants