Re: GtkLabel, GtkMisc, alignment and containers; an idea
- From: Behdad Esfahbod <behdad behdad org>
- To: Davyd Madeley <davyd madeley id au>
- Cc: gtk-devel-list gnome org
- Subject: Re: GtkLabel, GtkMisc, alignment and containers; an idea
- Date: Tue, 07 Jul 2009 13:25:08 +0100
On 07/07/2009 09:53 AM, Davyd Madeley wrote:
So, I was looking at why a GtkLabel with a RTL control code didn't seem
to right-align the text in a GtkLabel. The answer being that the width
of the PangoLayout is set to -1, rather than the width of the
allocation.
So I was wondering how you'd fix this. My immediate thought was to set
the PangoLayout to always have the width of the allocation. This would
allow for RTL control codes to function + make the justify modes in
GtkLabel work how people think they should (rather than how they do).
Unfortunately it breaks gtk_misc_set_alignment(), you can no longer
align a smaller PangoLayout inside a bigger allocation.
Thus I was thinking about how this might be fixed properly, and I came
up with the following idea. It breaks API and assumptions in GTK+, and I
don't yet have an idea for a migration path; but I'll share it anyway.
My idea:
(1) Make alignment a child-property of the GtkContainer. This would
allow any widget that wasn't EXPAND|FILL to be aligned within it's
available space. It would remove the requirement for GtkAlignment in a
lot of cases. This could be added to GTK+ without breaking API.
(2) Remove the GtkMisc class. Alignment is now a child-property.
(3) Make the PangoLayout of labels always fill their allocation. This
would make features like the RTL control code and PangoJustify work as
developers expect. If developers want a left-justified, right-aligned
text block, they can set the widget to not be EXPAND|FILL, and set the
align-x child-property to 1.0. This will likely require extended layout
for wrapped labels.
(4) Profit.
Thoughts?
Generally agreed. Makes the code so much simpler...
behdad
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]