Closed ashbb closed 11 years ago
Here's what happens when I run the snippet
This happens each time I click the button.
I think it would be best if the layout happens automatically, so that every time we add, remove, or change an element that belongs to a layout, the layout does a re-layout. I don't think the user should have to trigger the layout manually, or even know that there is such a thing as a layout. The user should just add a para, and see it appear where it belongs.
I'm with Eric here, that should totally happen automagically :-) Would probably be best if it happens after each executed block of code, don't know how easy that is to achieve. Relayouting after each added element is probably not too feasible, or is it?
After the end of each block sounds like a useful location. It could be called a few times with nested blocks.
Are there any samples that would prove this to be an anti-pattern?
Peter Fitzgibbons (847) 859-9550 Email: peter.fitzgibbons@gmail.com IM GTalk: peter.fitzgibbons IM AOL: peter.fitzgibbons@gmail.com
On Mon, Sep 24, 2012 at 11:26 AM, Tobias Pfeiffer notifications@github.comwrote:
I'm with Eric here, that should totally happen automagically :-) Would probably be best if it happens after each executed block of code, don't know how easy that is to achieve. Relayouting after each added element is probably not too feasible, or is it?
— Reply to this email directly or view it on GitHubhttps://github.com/shoes/shoes4/issues/128#issuecomment-8825021.
I think we could try and go with after every element addition at first... worrying abut performance when it becomes a problem. I don't know too much about gui layouting so if this is doomed to become a problem the more fine grained block approach would be necessary.
However there we'd have to identify all events where this could happen... thinks coming to my mind:
We need to have this behaviour though otherwise we'd break a ton of apps... including hacketyhack.
Recall that layout in Red is completely custom code. If you can read the C-Ruby and understand, not only will we bow to you (I think I speak for the group), we will also be well educated by your experience (when you tell us, that is).
Shoes On!
Peter Fitzgibbons (847) 859-9550 Email: peter.fitzgibbons@gmail.com IM GTalk: peter.fitzgibbons IM AOL: peter.fitzgibbons@gmail.com
On Mon, Sep 24, 2012 at 2:00 PM, Tobias Pfeiffer notifications@github.comwrote:
I think we could try and go with after every element addition at first... worrying abut performance when it becomes a problem. I don't know too much about gui layouting so if this is doomed to become a problem the more fine grained block approach would be necessary.
However there we'd have to identify all events where this could happen... thinks coming to my mind:
- buttons
- link with :click => block parameter
- actually everything with a :click handler
- keypresses
- every/animate
- ... perhaps too many... maybe it should just happen after literally every block? Dunno.. does anyone know how red shoes handles this?
We need to have this behaviour though otherwise we'd break a ton of apps... including hacketyhack.
— Reply to this email directly or view it on GitHubhttps://github.com/shoes/shoes4/issues/128#issuecomment-8830369.
Thanks for the discussion. :)
I think it would be best if the layout happens automatically
I also want to do so. But at least on Windows 7, a stromy flickering happens with this snippet. Watch this. :(
Shoes.app width: 300, height: 400 do
100.times{para 'hello'}
animate{}
end
Because redraw
is called every block (animate loop). Refer to the code.
In Red Shoes, shoes_canvas_repaint_all
is called everywhere. Refer to the code. I'm not sure why the flickering doesn't happen on Windows 7. But on Windows VISTA, it happens.
I know @wilkie had a pretty good understanding of Red Shoes and vista drawing issues.
That flicker is weird. It doesn't happen on OS X.
By my reading of the Swt docs, Swt::Composite#redraw
shouldn't cause extra painting. It should collapse calls so that they are only painted once, "the next time a paint request is processed."
public void redraw()
Causes the entire bounds of the receiver to be marked as needing to be redrawn. The next time a paint request is processed, the control will be completely painted, including the background.
That said, we probably don't need to call redraw on every frame of an animation, as long as elements call for redraw when they need it.
As non-empirical information, windows and Java GUI have been at odds since WinXP. Could one of you start a new ticket for the platform-dependent performance of redraw w/ Windows?
Also could one of you verify redraw performance on other Linux (Ubuntu?). I think with that we can say redraw is ok.
Thoughts?
Peter Fitzgibbons (847) 859-9550 Email: peter.fitzgibbons@gmail.com IM GTalk: peter.fitzgibbons IM AOL: peter.fitzgibbons@gmail.com
On Tue, Sep 25, 2012 at 9:19 AM, Eric Watson notifications@github.comwrote:
That flicker is weird. It doesn't happen on OS Xhttp://vimeo.com/50140598.
By my reading of the Swt docs, Swt::Composite#redraw shouldn't cause extra painting. It should collapse calls so that they are only painted once, "the next time a paint request is processed."
public void redraw()
Causes the entire bounds of the receiver to be marked as needing to be redrawn. The next time a paint request is processed, the control will be completely painted, including the background.
That said, we probably don't need to call redraw on every frame of an animation, as long as elements call for redraw when they need it.
— Reply to this email directly or view it on GitHubhttps://github.com/shoes/shoes4/issues/128#issuecomment-8855816.
Closing this here in favor of the more up to date #209 - the discussion should continue there.
Try out the following snippet with the latest commit.
When you click the button, nothing will happen. But if you resize the window, the message 'hello' will appear.
Okay, then if you add
app.gui.real.getLayout.layout
like this:The message will appear immediately when you click the button.
Now I have a question. Should Shoes 4 call re-layout each time the button is clicked? Or should we add a new method to re-layout by user?
In Green and Purple Shoes, I added the
flush
method.