I don't particularly like the HTML box model. I think the learning curve is actually too high. In my opinion, a box with a width of 100px should be just that, 100px wide. Anything beyond that is superfluous and displeases god and nature. So that's my opinion about where the margins and borders should go in the "width =" equation.

Now for the padding. I disagree with the padding element approach you propose below. The idea of using a different brush and using that from now on is easy to grasp intuitively. But the idea of applying a padding in this way is a lot more difficult. I may be terribly traditional here, but I like a UI definition to be declarative, not procedural. Or at least, to look declarative, like stacks and flows do. The embedding of stacks and flows in the code corresponds exactly to the embedding of the actual visual elements, which is wonderful. A pad function would not have that particular benefit.

I really think Shoes is fine the way it is with respect to margins. If you want a padding, just throw in a flow with a margin. It seems natural to me.

This still leaves the problem that the coordinates in the inner box are different from those of the background. Now, I would say that only matters when using absolute positioning. (I may be wrong here.) Can't we use a construct like

:outer-top => 20, :outer-left: 10

(or parent- instead of outer-) for these cases? Setting :outer-top would subtract the margin width and set :top accordingly.


sb



On 28-dec-2007, at 22:23, why the lucky stiff wrote:

On Fri, Dec 28, 2007 at 09:36:59PM +0100, Koen Van der Auwera wrote:
Well, to be honest I like it just the way it is. It's clear. If I understand correctly the goal is to keep Shoes as simple as possible and then I'm not
sure the HTML-way is the best way.

Padding could be handy though :)

Well, let me share my concern about padding and maybe you can help
me make up my mind here.

The only real use for padding is to offset the contents of a box
from the background and border.  So, the margin offsets the
background and the padding offsets the text.

  <div style="width: 100px; padding: 10px; margin: 10px;
    background:red;">I love ragtime</div>

In this example, the box itself will be 140px wide.  From 0 to 140
on the x-axis.  The background will cover 10 to 130 on the x-axis.
And the text will cover 20 to 120 on the x-axis.

In Shoes, backgrounds are their own element, not a style.  So the
equivalent would be:

  stack :width => 140, :margin => 10 do
    background red
    stack :margin => 10 do
      para "I love ragtime"
    end
  end

So, the trouble with a padding style is that the padding would
affect only most elements, all but `background` and `border`.
This means that different elements would be operating under
slightly different coordinate systems.  I don't really like that a
style would only apply to certain elements, since it requires extra
memorization.

Maybe a padding element, which would pad everything underneath it.

  stack :width => 140, :margin => 10
    background red
    pad 10
    background blue
    para "I love ragtime"
  end

So the blue background is padded ten pixels along with the text.

This might even do away with margins:

  stack :width => 140
    pad 10
    background red
    pad 10
    background blue
    para "I love ragtime"
  end

There is a precedent for this in Shoes, since `stroke` and `fill`
are stateful and affect elements below them.

_why

Reply via email to