[haiku-commits] Re: haiku: hrev47085 - src/kits/interface

  • From: Ingo Weinhold <ingo_weinhold@xxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 03 Apr 2014 22:57:46 +0200

On 03.04.2014 22:42, John Scipione wrote:
Ingo Weinhold wrote:
On 03.04.2014 21:37, John Scipione wrote:
See how the +, -, and reset button labels are close to the bottom of the
button? The minus looks like an underscore, that's what I mean by too
low. You could also see the same effect in Keymap on the Tab and Return
keys.

Is a maximum height forced on the buttons in this case? If such a
maximum is smaller than the required space, it would cause ...
... a negative value here. While BLayoutUtils::AlignInFrame() would
return 0.

I used SetExplicitSize() here which sets the min, preferred, and max
dimensions, so, this doesn't seem to be the case.

If you e.g. set an explicit height of 10, but the font ascent + descent is 15, this is exactly the case.

On a tangentially related note, in BButton::Draw() just before we draw
the label we have the following code:

// always leave some room around the label
rect.InsetBy(kLabelMargin, kLabelMargin);

... where kLabelMargin is 3. This causes problems with some Be apps (and
even some Haiku apps) that have tight margins and thus won't allow the
label to display. Since we always center the label horizontally and
vertically can we remove this code?

The class should rather get methods to manipulate the margins, so that
new code can adjust them, if desired. For old code we might need to
implement some compatibility behavior.

This seems unnecessary to me. The margins cause nothing but trouble.
They don't provide any help since we center the label in both dimensions
unconditionally but in some cases they do hurt us by cutting off the
label text.

Unless you violate the button's layout constraints, nothing is cut off. And if you do, it doesn't really matter, if there are margins. E.g. there's very little text you can cram into a 1x1 button, margins or not.

What do we gain by having (adjustable) margins? The only case I could
see them being beneficial is if we allowed the label to be something
other than center aligned, but, we don't.

The margins define the distance between label and frame and allowing to set them would allow visually different results. Unless you override the button's layout constraints this has nothing to do with whether the label is centered or aligned differently. Greater margins just make the button larger.

CU, Ingo


Other related posts: