You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pivot.apache.org by Greg Brown <gk...@mac.com> on 2009/08/07 06:36:40 UTC

Re: Square PushButton

OK, I just reverted my earlier change and renamed the style to  
"minimumPreferredAspectRatio". Unfortunately, this means that we can't  
automatically create square buttons, but it sounds like it might have  
been a stretch to use this feature to meet your use case anyways.  :-(

Thanks again for the input - I apologize for the confusion.

G


On Aug 7, 2009, at 12:10 AM, Greg Brown wrote:

> You know...now that I think about it, perhaps my most recent change  
> was misguided. The term "preferredAspectRatio" may have been  
> misleading. The use case we were originally trying to address was  
> "minimum preferred aspect ratio". We didn't use the term "minimum"  
> because we thought it might be confusing, but that's kinda what it  
> was supposed to be.
>
> Our use case was this: we want push buttons in a dialog to be a  
> consistent (minimum) width. If they exceed that width, that's OK -  
> but we want them to at least *try* to be the same size.
>
> My recent change would break that behavior if the button data (e.g.  
> text) required more space than the aspect ratio allowed. So I  
> actually think I need to revert it, and probably rename the style to  
> "minimumPreferredAspectRatio".
>
> G
>
>
> On Aug 6, 2009, at 11:13 PM, Scott Lanham wrote:
>
>> Attached is my wtkx file. For one button the aspect ratio worked  
>> great, but for
>> two and three buttons they get progressively smaller.
>>
>> On Fri, 7 Aug 2009 12:41:01 pm Greg Brown wrote:
>>> For an example, see:
>>>
>>> http://svn.apache.org/repos/asf/incubator/pivot/trunk/wtk/test/org/apache/p
>>> ivot/wtk/test/preferred_aspect_ratio_test.wtkx
>>>
>>> G
>>>
>>> On Aug 6, 2009, at 10:36 PM, Greg Brown wrote:
>>>> OK, TerraPushButtonSkin now properly respects the
>>>> "preferredAspectRatio" style. If you set it to 1 (and the parent
>>>> container respects the button's preferred size), you'll get a  
>>>> square
>>>> button.
>>>>
>>>> However, you won't be able to simply rely on the box pane for
>>>> calculating the correct preferred height for all of the buttons.  
>>>> The
>>>> (unconstrained) preferred height of the box pane is still going to
>>>> be determined as the sum of the unconstrained preferred heights of
>>>> the buttons. Only when the width of the box pane is constrained can
>>>> we determine the actual button heights (since they depend on the
>>>> max. button width, which isn't known until layout - it is not, and
>>>> cannot be, known at preferred size calculation time).
>>>>
>>>> So, you identified a valid issue - thank you! But in order to meet
>>>> your use case, you'll need to ensure that the box pane is given
>>>> enough vertical height to accommodate all the buttons - that height
>>>> can't be determined automatically. Even a scroll pane or panorama
>>>> can't help here - your box pane must simply be given enough  
>>>> vertical
>>>> screen real estate to display all of the buttons.
>>>>
>>>> Hope this helps.
>>>>
>>>> G
>>>>
>>>> On Aug 6, 2009, at 9:47 PM, Greg Brown wrote:
>>>>> I understand your use case. I think that a vertical box pane with
>>>>> fill set to true would meet your needs, if we can get PushButton  
>>>>> to
>>>>> behave correctly with respect to preferred aspect ratio.  :-)  I'm
>>>>> looking into it right now.
>>>>>
>>>>> On Aug 6, 2009, at 9:42 PM, Scott Lanham wrote:
>>>>>> Thanks Greg,
>>>>>>
>>>>>> What I originally expected aspect ratio to do is to increase the
>>>>>> smallest of
>>>>>> either height or width to keep the ratio constant. But my focus  
>>>>>> is
>>>>>> only on my
>>>>>> own needs so it is hard to see the big picture. It turns out a
>>>>>> square button
>>>>>> looks terrible when I did get it working and I ended up using an
>>>>>> aspect ratio
>>>>>> of 1.2. To get that ratio to work I had to set preferred height
>>>>>> but I don't
>>>>>> like setting explicit dimensions if it can be avoided though.
>>>>>>
>>>>>> What I am ultimately trying to do at the moment is create a
>>>>>> vertical "toolbar"
>>>>>> that keeps all buttons the same size. The size of the buttons are
>>>>>> dictated by
>>>>>> the button with the largest content and the aspect ratio is to
>>>>>> keep all the
>>>>>> buttons at a nice shape. One of the apps I work on is touch  
>>>>>> screen
>>>>>> based so
>>>>>> keeping the buttons large and a nice shape is important.
>>>>>>
>>>>>> On Fri, 7 Aug 2009 11:21:22 am Greg Brown wrote:
>>>>>>> Preferred aspect ratio currently affects the height if it is  
>>>>>>> less
>>>>>>> than
>>>>>>> 1, and the width if it is greater than or equal to 1. However, I
>>>>>>> can
>>>>>>> see why you might expect that setting it to a value of 1 would
>>>>>>> produce
>>>>>>> a square button. I'll look into that.
>>>>>>>
>>>>>>> In the meantime, your best bet is to either a) use square  
>>>>>>> content
>>>>>>> (such as an icon whose width and height are equal) or b)  
>>>>>>> manually
>>>>>>> set
>>>>>>> the preferred width and height to the same value.
>>>>>>>
>>>>>>> G
>>>>>>>
>>>>>>> On Aug 6, 2009, at 8:44 PM, Scott Lanham wrote:
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> I would like to create a PushButton that stays square no matter
>>>>>>>> what
>>>>>>>> its
>>>>>>>> button data contains. I have tried to set preferredAspectRatio
>>>>>>>> to 1
>>>>>>>> but it
>>>>>>>> only appears to affect the button width. Is there any way I can
>>>>>>>> keep
>>>>>>>> a button
>>>>>>>> square besides setting the preferred height and width to be the
>>>>>>>> same?
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>>
>>>>>>>> Scott.
>>
>> <applicationUi.xml>
>


Re: Square PushButton

Posted by Greg Brown <gk...@mac.com>.
> Would be nice if we could play nice with the individual platforms,
> trying to respect their UI conventions where it's not too
> inconvenient.

Yeah. I think this is a must for things like Control vs. Command for  
multi-select and accelerator key combinations. So, whatever solution  
we come up with for that may also be applicable to button ordering.



Re: Square PushButton

Posted by Noel Grandin <no...@gmail.com>.
>> Which would make a good place to put things like the logic for
>> determining the correct platform order of OK and CANCEL buttons.
>
> I'm not sure how (or if) we'll try to tackle that. Alerts and Prompts don't
> have any built-in buttons - they are all user-specified. The file dialog I'm
> working on right now does have OK and Cancel buttons, but I'm planning (for
> now) to use Windows conventions.
>
> Pivot is a UI toolkit unto itself, after all, so we can theoretically
> dispense with platform considerations here. But it is definitely worth
> thinking about some more.

Would be nice if we could play nice with the individual platforms,
trying to respect their UI conventions where it's not too
inconvenient.
But I agree, it's not high priority.

-- Noel.

Re: Square PushButton

Posted by Greg Brown <gk...@mac.com>.
> Surely this would be better achieved with some kind of custom
> container for buttons?

Possibly. But what if you want to create a button that has the "right"  
minimum dimensions and you want to put it in a container with other  
non-button components? I think this is a pretty valid use case - the  
current approach supports it, whereas a custom button container would  
not.

Also, as you have probably seen, we try very hard to stay away from  
"special case" scenarios like this. That makes me even more reluctant  
to consider adding such a container.

> Which would make a good place to put things like the logic for
> determining the correct platform order of OK and CANCEL buttons.

I'm not sure how (or if) we'll try to tackle that. Alerts and Prompts  
don't have any built-in buttons - they are all user-specified. The  
file dialog I'm working on right now does have OK and Cancel buttons,  
but I'm planning (for now) to use Windows conventions.

Pivot is a UI toolkit unto itself, after all, so we can theoretically  
dispense with platform considerations here. But it is definitely worth  
thinking about some more.

G



Re: Square PushButton

Posted by Noel Grandin <no...@gmail.com>.
Hi

Surely this would be better achieved with some kind of custom
container for buttons?

Which would make a good place to put things like the logic for
determining the correct platform order of OK and CANCEL buttons.

Regards, Noel.


On Fri, Aug 7, 2009 at 06:36, Greg Brown<gk...@mac.com> wrote:
> OK, I just reverted my earlier change and renamed the style to
> "minimumPreferredAspectRatio". Unfortunately, this means that we can't
> automatically create square buttons, but it sounds like it might have been a
> stretch to use this feature to meet your use case anyways.  :-(
>
> Thanks again for the input - I apologize for the confusion.
>
> G
>
>
> On Aug 7, 2009, at 12:10 AM, Greg Brown wrote:
>
>> You know...now that I think about it, perhaps my most recent change was
>> misguided. The term "preferredAspectRatio" may have been misleading. The use
>> case we were originally trying to address was "minimum preferred aspect
>> ratio". We didn't use the term "minimum" because we thought it might be
>> confusing, but that's kinda what it was supposed to be.
>>
>> Our use case was this: we want push buttons in a dialog to be a consistent
>> (minimum) width. If they exceed that width, that's OK - but we want them to
>> at least *try* to be the same size.
>>
>> My recent change would break that behavior if the button data (e.g. text)
>> required more space than the aspect ratio allowed. So I actually think I
>> need to revert it, and probably rename the style to
>> "minimumPreferredAspectRatio".
>>
>> G
>>
>>
>> On Aug 6, 2009, at 11:13 PM, Scott Lanham wrote:
>>
>>> Attached is my wtkx file. For one button the aspect ratio worked great,
>>> but for
>>> two and three buttons they get progressively smaller.
>>>
>>> On Fri, 7 Aug 2009 12:41:01 pm Greg Brown wrote:
>>>>
>>>> For an example, see:
>>>>
>>>>
>>>> http://svn.apache.org/repos/asf/incubator/pivot/trunk/wtk/test/org/apache/p
>>>> ivot/wtk/test/preferred_aspect_ratio_test.wtkx
>>>>
>>>> G
>>>>
>>>> On Aug 6, 2009, at 10:36 PM, Greg Brown wrote:
>>>>>
>>>>> OK, TerraPushButtonSkin now properly respects the
>>>>> "preferredAspectRatio" style. If you set it to 1 (and the parent
>>>>> container respects the button's preferred size), you'll get a square
>>>>> button.
>>>>>
>>>>> However, you won't be able to simply rely on the box pane for
>>>>> calculating the correct preferred height for all of the buttons. The
>>>>> (unconstrained) preferred height of the box pane is still going to
>>>>> be determined as the sum of the unconstrained preferred heights of
>>>>> the buttons. Only when the width of the box pane is constrained can
>>>>> we determine the actual button heights (since they depend on the
>>>>> max. button width, which isn't known until layout - it is not, and
>>>>> cannot be, known at preferred size calculation time).
>>>>>
>>>>> So, you identified a valid issue - thank you! But in order to meet
>>>>> your use case, you'll need to ensure that the box pane is given
>>>>> enough vertical height to accommodate all the buttons - that height
>>>>> can't be determined automatically. Even a scroll pane or panorama
>>>>> can't help here - your box pane must simply be given enough vertical
>>>>> screen real estate to display all of the buttons.
>>>>>
>>>>> Hope this helps.
>>>>>
>>>>> G
>>>>>
>>>>> On Aug 6, 2009, at 9:47 PM, Greg Brown wrote:
>>>>>>
>>>>>> I understand your use case. I think that a vertical box pane with
>>>>>> fill set to true would meet your needs, if we can get PushButton to
>>>>>> behave correctly with respect to preferred aspect ratio.  :-)  I'm
>>>>>> looking into it right now.
>>>>>>
>>>>>> On Aug 6, 2009, at 9:42 PM, Scott Lanham wrote:
>>>>>>>
>>>>>>> Thanks Greg,
>>>>>>>
>>>>>>> What I originally expected aspect ratio to do is to increase the
>>>>>>> smallest of
>>>>>>> either height or width to keep the ratio constant. But my focus is
>>>>>>> only on my
>>>>>>> own needs so it is hard to see the big picture. It turns out a
>>>>>>> square button
>>>>>>> looks terrible when I did get it working and I ended up using an
>>>>>>> aspect ratio
>>>>>>> of 1.2. To get that ratio to work I had to set preferred height
>>>>>>> but I don't
>>>>>>> like setting explicit dimensions if it can be avoided though.
>>>>>>>
>>>>>>> What I am ultimately trying to do at the moment is create a
>>>>>>> vertical "toolbar"
>>>>>>> that keeps all buttons the same size. The size of the buttons are
>>>>>>> dictated by
>>>>>>> the button with the largest content and the aspect ratio is to
>>>>>>> keep all the
>>>>>>> buttons at a nice shape. One of the apps I work on is touch screen
>>>>>>> based so
>>>>>>> keeping the buttons large and a nice shape is important.
>>>>>>>
>>>>>>> On Fri, 7 Aug 2009 11:21:22 am Greg Brown wrote:
>>>>>>>>
>>>>>>>> Preferred aspect ratio currently affects the height if it is less
>>>>>>>> than
>>>>>>>> 1, and the width if it is greater than or equal to 1. However, I
>>>>>>>> can
>>>>>>>> see why you might expect that setting it to a value of 1 would
>>>>>>>> produce
>>>>>>>> a square button. I'll look into that.
>>>>>>>>
>>>>>>>> In the meantime, your best bet is to either a) use square content
>>>>>>>> (such as an icon whose width and height are equal) or b) manually
>>>>>>>> set
>>>>>>>> the preferred width and height to the same value.
>>>>>>>>
>>>>>>>> G
>>>>>>>>
>>>>>>>> On Aug 6, 2009, at 8:44 PM, Scott Lanham wrote:
>>>>>>>>>
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> I would like to create a PushButton that stays square no matter
>>>>>>>>> what
>>>>>>>>> its
>>>>>>>>> button data contains. I have tried to set preferredAspectRatio
>>>>>>>>> to 1
>>>>>>>>> but it
>>>>>>>>> only appears to affect the button width. Is there any way I can
>>>>>>>>> keep
>>>>>>>>> a button
>>>>>>>>> square besides setting the preferred height and width to be the
>>>>>>>>> same?
>>>>>>>>>
>>>>>>>>> Thanks,
>>>>>>>>>
>>>>>>>>> Scott.
>>>
>>> <applicationUi.xml>
>>
>
>