Nux

Merge lp://qastaging/~haggai-eran/nux/rtl-rebased into lp://qastaging/nux/2.0

Proposed by Haggai Eran
Status: Superseded
Proposed branch: lp://qastaging/~haggai-eran/nux/rtl-rebased
Merge into: lp://qastaging/nux/2.0
Diff against target: 678 lines (+207/-97)
7 files modified
Nux/Area.cpp (+11/-0)
Nux/Area.h (+16/-0)
Nux/HLayout.cpp (+146/-97)
Nux/Layout.cpp (+16/-0)
Nux/Layout.h (+3/-0)
Nux/Nux.cpp (+12/-0)
Nux/Nux.h (+3/-0)
To merge this branch: bzr merge lp://qastaging/~haggai-eran/nux/rtl-rebased
Reviewer Review Type Date Requested Status
Jay Taoko Pending
Review via email: mp+82225@code.qastaging.launchpad.net

This proposal has been superseded by a proposal from 2012-04-27.

Commit message

Add right-to-left mirroring support. Implement mirroring for HLayout.

Description of the change

Hi,

Here's my branch rebased against trunk. I hope the changes are more clear now.

There's still a problem with this patch to HLayout, though. When in right-to-left state, it packs child elements to the layout starting from the last on the list, instead of starting from the first, in order to get them in reverse order. However, it seems that for some of the widgets this doesn't work very well. I checked the CheckBox example, and the AbstractCheckedButton::ComputeContentSize code depends on the fact that the HLayout will first allocate space to the checkbox, and afterwards to the label. When using a right-to-left direction, the label is laid out first, and then the checkbox is positioned out of the widget's bounds.

Should I change my patch to pack the children in their logical order, starting from the rightmost edge, or should I leave the code as it is, and try to fix uses like the AbstractCheckedButton?

Regards,
Haggai

To post a comment you must log in.
Revision history for this message
Jay Taoko (jaytaoko) wrote :

Haggai

Selecting right to left has to be done per layout. Lets say you have an horizontal layout that has a checkbox followed by a button, and the button is followed by a combobox. In LTR order you get this:
 checkbox | button | combobox

If you make the HLayout to be RTL then the content will look like this:

 combobox| button | checkbox

This should work out fine because only a specific HLayout has been been changed to RTL.

So you have to select only the layouts of the interface that need to be inverted. Rather than having SetDefaultDirection in Nux.cpp, it should be a function member of LinearLayout. Then for each layout (HLayout or VLayout), you will be able to decide if it goes from LTR or RTL. Individual views like the Checkbox, will remain un-affected.

How about that?

Revision history for this message
Haggai Eran (haggai-eran) wrote :

Jay,

I agree that we should be able to set directionality on per-layout basis. I even implemented it as a member of Area. However, I think that the default when using an RTL locale should be right to left, for all widgets, and not just specific HLayouts.

In the example you described, you could show the detailed widgets like this (in LTR):

[ combobox ↓ | button | [x] checkbox ]

Then, I expect the RTL rendering to be like this:

[ checkbox [x] | button | ↓ combobox ]

The internal layout of comboboxes and checkboxes should also be mirrored.

Please compare how GTK looks in LTR and RTL in the following two screenshots of the widget factory:
http://i44.tinypic.com/2lks0e8.jpg
http://i43.tinypic.com/25ri0ds.png

Haggai

Revision history for this message
Jay Taoko (jaytaoko) wrote :

Ok, I see how it is. I think many widget will have to have support for a RTL design.
But first we can get this branch in since it has global support for RTL at the layout level. Then the next step would be to go to each individual widgets that requires it and review the design.

It is up to me now to review and adapt this branch and see that we can merge it. We now have the requirement of proposing tests along side major features. Can you think of some way we can test the features of this branch?

Revision history for this message
Haggai Eran (haggai-eran) wrote :

Hi,

I think that perhaps rewriting the code to pack in the same order as in LTR might still have some advantages. I've tried to think on how that would work. Instead of walking the list of HLayout children in reverse, and packing them to the left, I'll walk the list in the usual order, and pack from right to left.

As far as I can see, I would only need to change HLayout::ComputeContentSize, and HLayout::ComputeContentPosition, which would make the changes simpler. I'm sure in both cases other widget will need to be modified, but if any widget's layout depends on the order of children's placement, then that order wouldn't change.

Regarding tests, I suppose that a tests for HLayout can be modified to test the RTL case as well, but I cannot find such a test (perhaps my tree isn't updated). I imagine a test that creates an HLayout, with several children that are using different settings for scaling, vertical placement, etc. and asserting there placement. What do you think?

Unmerged revisions

521. By Haggai Eran

Change LayoutContentDistribution only when in RTL mode.

520. By Haggai Eran

More HLayout changes toward right-to-left support.

519. By Haggai Eran

Add right-to-left mirroring support. Implement mirroring for HLayout.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches

to all changes: