pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bill van Melle <bill.van.me...@gmail.com>
Subject Re: The patchwork that is Pivot layout
Date Thu, 17 Mar 2011 23:23:22 GMT
Well, first off, I apologize for the insult.  I really should have chosen a
less aggressive subject line.  It is certainly not my intent to insult the
Pivot team, which has produced a very impressive system with limited
resources.  Nor do I wish to glorify WPF, which I agree is a bloated beast.
 But it happens to be a beast with which I am somewhat familiar, and not
long ago Chris invited me to discuss things from there or elsewhere that I
thought might benefit Pivot, so here I am.

> <BoxPane orientation="vertical" styles="{fill:true}">
> >   <BoxPane styles="{horizontalAlignment:'center'}">
> >     <Border preferredWidth="150" preferredHeight="150"
> >       styles="{color:'gray', thickness:4, cornerRadii:10}">
> >       <ImageView bxml:id="imgPhoto" styles="{fill:true}" />
> >     </Border>
> >   </BoxPane>
> >   <Label styles="{wrapText:true}" text="...Some long paragraph..." />
> > </BoxPane>
> ...
> > Am I missing something?  Is there an easier way?
>
> I might put the BoxPane in the Border rather than the other way around.


Well, that wouldn't be less wordy, but I also don't think it works.  The
Border would fill the horizontal space.  And even if it didn't, I can't
center it, since Border lacks a horizontalAlignment property.

You might also consider using TablePane as your outer container instead of
> BoxPane.
>

It's true that I can get practically anything I want with TablePane, but it
can be pretty cumbersome.  The equivalent of a vertical BoxPane means adding
a columns specification, and wrapping each element in TablePane.Row.  In my
particular example, unless I'm missing some trick, it's more like

<TablePane>
  <columns>
    <TablePane.Column width="1*" />
    <TablePane.Column width="-1" />
    <TablePane.Column width="1*" />
  </columns>
  <TablePane.Row>
    <TablePane.Filler/>
    <Border styles="{color:'gray', thickness:4, cornerRadii:10}">
      <ImageView bxml:id="imgPhoto" styles="{fill:true}"
        preferredWidth="150" preferredHeight="150" />
    </Border>
    <TablePane.Filler/>
  </TablePane.Row>
  <TablePane.Row>
    <Label TablePane.columnSpan="3" styles="{wrapText:true}"
      text="...Some long paragraph..." />
  </TablePane.Row>
  <TablePane.Row>
    <TablePane.Filler/>
    <PushButton buttonData="Press Me" />
    <TablePane.Filler/>
  </TablePane.Row>
</TablePane>

But that's not quite right, because it ties the width of the imageview to
the width of the button -- if the image is wider than the button, the button
is stretched to the width of the image, while if the button is wider, the
border is stretched to the width of the button, leaving me no longer with a
square border.  So I really have to split it up into multiple tables:

<BoxPane orientation="vertical" styles="{fill:true}">
  <TablePane>
    <columns>
      <TablePane.Column width="1*" />
      <TablePane.Column width="-1" />
      <TablePane.Column width="1*" />
    </columns>
    <TablePane.Row>
      <TablePane.Filler />
      <Border styles="{color:'gray', thickness:4, cornerRadii:10}">
        <ImageView bxml:id="imgPhoto" styles="{fill:true}"
          preferredWidth="150" preferredHeight="150" />
      </Border>
      <TablePane.Filler />
    </TablePane.Row>
  </TablePane>
  <Label styles="{wrapText:true}" text="...Some long paragraph..." />
  <TablePane>
    <columns>
      <TablePane.Column width="1*" />
      <TablePane.Column width="-1" />
      <TablePane.Column width="1*" />
    </columns>
    <TablePane.Row>
      <TablePane.Filler />
      <PushButton buttonData="Press Me" />
      <TablePane.Filler />
    </TablePane.Row>
  </TablePane>
</BoxPane>

So you can see how I'd really rather have the ability to specify the
alignment (and sometimes size) of most components within their parent.

... WPF/XAML is an enormous beast that, in my opinion, is far more difficult
> to master than Pivot/BXML.
>

I grant you the former without hesitation, but I'd sure have to quibble with
the latter, especially if you're not trying to master the whole "design a
new control template for some widget and have fancy animation on various
mouse events" task, something which I daresay is hard in Pivot, too, and
which most of us rarely have the need for.

* The XAML editor has Intellisense.  That means there are autocompletion
hints on property names, and easy access to their documentation.  In Pivot,
I have to be constantly flipping thru the javadoc just to remember how to
spell things and which components have which properties, and whether it's a
component property or a style property.  After a while I get better at the
spelling part (though capitalization sometimes trips me up), but remembering
which components have what property I'm not fluent in yet.

* There's a visual designer, so in most cases I don't have to run my app to
see whether I got it right, or at least close.  The Pivot plugin for Eclipse
helps a tiny bit, but only for standalone bxml files, which is a rarity for
me -- most of the time I have a backing class.

* The connection between a XAML file and its backing class is handled
automagically internally.  That means I can write code that creates a custom
control by calling the control's constructor in the familiar way, rather
than fumbling with a serializer call, instance variables are automatically
declared for named components, and events named in the XAML are
automatically hooked up in the backing class.  (The second of those is
helped by the @BXML annotation, at least for trusted apps.  The first I
ameliorate by adopting a programming style of hiding the serializer call
inside a factory method of the class.)

* Events are a bit simpler.  That's mostly Java's fault, not Pivot's, but it
still is a learning issue.  In WPF, if I want to be notified when my control
is resized, I add a single method (or even a closure) to the control; I
don't have to write a ComponentListener with 11 (!) methods, 10 of which go
unused. I can also see all the supported events in a single place in the
documentation, rather than having to scan thru the javadoc of multiple
listeners.

Now to get all that, WPF has been around for years longer and is supported
by a huge, paid development team.  I don't expect all that from Pivot.  But
if someone were to ask me my recommendation for a framework in which to
build a GUI app that they only ever wanted to run on a Windows desktop, I'd
have to point them at WPF, sorry.  On the other hand, for cross-platform
apps, I *do* recommend Pivot, but it's with a lot of caveats.

So when there are things from WPF that I think would make Pivot more usable,
I hope I can bring them up.  Earlier I've mentioned such things as a
ScalingPane (something I could really use right now and have no idea how to
implement myself) and simpler markup for document spans of text (which you
fixed in 2.0.1, thank you).  I often hesitate to do so, lest you feel I'm
casting aspersions on Pivot.  I'm probably coming off as way to much of a
WPF fanboy as it is, which is unfortunate, since I and my colleagues get mad
at Microsoft all the time...

Mime
View raw message