pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Brown <gkbr...@mac.com>
Subject Re: Making a org.apache.pivot.wtk.Dialog resizable
Date Wed, 26 May 2010 21:50:27 GMT
I like the idea of a warning, but I'm not sure it would work well in practice. Specifically,
it's not always clear when/if it should be displayed - what if the user sets the "resizable"
style before setting the preferred size? You could theoretically show the warning when either
the resizable flag or the preferred size changes to an incompatible state, but that seems
like overkill. Also, the caller may be in the process of setting all the values to a compatible
state, so the warning would be invalid in this case. Finally, the preferred size values are
set at the component level, not in the skin, so the check would have to be done in the event
listeners for preferred size changes. That seems a bit ugly.

Styles are definitely not hints - they are the bean properties of the skin. If a skin exposes
a style, it should respect it. However, style behaviors could probably be better documented,
especially in cases like this where the behavior may not be clear. Apologies for the confusion.

G

On May 26, 2010, at 3:55 PM, Chris Bartlett wrote:

> Thanks for the detailed response, Greg.
> 
> As this is by design, it would be helpful if the WTKX serializer could spit out a warning
that the supplied style will be fully or partially ignored due to the absence of preferred
widths/heights.
> 
> > This would invalidate the caller's presumed intention to have the dialog sized automatically.
> If the code is making assumptions about the caller's intention, which override explicitly
provided styling information, then I really think that a warning of some sort should be given.
> 
> Perhaps I should be thinking of styles more as hints?
> 
> Chris
> 
> 
> On Thu, May 27, 2010 at 2:43 AM, Greg Brown <gkbrown@mac.com> wrote:
> Just a little more detail - when no explicit size is set, the assumption is that the
caller wants the dialog to be sized automatically based on the preferred size of its content.
Allowing the dialog to be resized in this case would require applying an explicit preferred
size to the dialog such that further calls to layout() would use the explicitly-set size rather
than the default reported by the window's skin. This would invalidate the caller's presumed
intention to have the dialog sized automatically.
> 
> So, if you want your dialog to be resizable, you just need to set an explicit preferred
size yourself (since this makes it clear that you do not want the dialog to be sized automatically).
If you want your dialog to open at its default size, you could potentially override open()
to clear any previously explicitly set preferred size and then set it to the value returned
by getPreferredSize().
> 
> Again, hope this helps.
> 
> Greg
> 
> 
> On May 26, 2010, at 3:20 PM, Greg Brown wrote:
> 
> > Correct - this is by design. In Pivot, a window's size is defined by its preferred
width and height properties rather than the actual width and height properties. This is because,
like all other components, a window relies on its parent container (an instance of Display)
to set its size. During layout, DisplaySkin sets the size of the window to its preferred size,
whether explicitly defined by the caller or determined by the window's skin. When an explicit
preferred size is not set, TerraFrameSkin (which TerraDialogSkin extends) reports a preferred
size based on the size of its content. The "resizable" style is ignored in this case. However,
if either preferred width or height is set, the flag is respected.
> >
> > This is different from AWT/Swing, which uses the pack() method to size a window
to its content. In Pivot, packing happens automatically when one or both preferred dimensions
is not set.
> >
> > Hope this helps.
> >
> > Greg
> >
> >
> > On May 26, 2010, at 12:11 PM, Chris Bartlett wrote:
> >
> >> I've been struggling for a few hours trying to figure out how to make a   org.apache.pivot.wtk.Dialog
  resizable.   (Using a copy of the 1.5 trunk refreshed earlier today)
> >>
> >> Using   org.apache.pivot.tutorials.windows.Windows   as a base, I modified 
 'dialog.wtkx'   to include    styles="{resizable:true}"   in the Dialog element.
> >>
> >> This doesn't have any effect unless the   preferredWidth   and/or  preferredHeight
 properties are also set.
> >> The code in   org.apache.pivot.wtk.skin.terra.TerraFrameSkin.mouseMove()   suggests
this is deliberate.
> >>
> >> Am I missing something here as to why the preferred width & height are relevant,
or should this be classified as a bug?
> >> IMHO settiing the   resizable   style should allow the Frame/Dialog to be resized
(unless it is maximized).
> >>
> >> Regards,
> >>
> >> Chris
> >>
> >>
> >
> 
> 


Mime
View raw message