Content-Type: text/x-patch; name=bidilayout-r1910.patch
X-Attachment-Id: f_fd52xrls0
Content-Disposition: attachment; filename=bidilayout-r1910.patch
Attachment converted: adil:bidilayout-r1910.patch (TEXT/ttxt) (00651F80)
3/ The implementation calls LocaleInfo.getCurrentLocale().isRTL() to get the default RTL direction. Apart from Shanjian's comment, is this a quick way to get the RTL value? As I can imagine an application may need to get the RTL many times.
I can see from the code that the value is computed from CLDR but I cannot see how it is accessed as I do not know how this part of GWT is built.
rajeev,
For one thing, we discussed about adding following API to DOM before,
void setRTLDirection(Element element, bool isRTL);
bool isRTLDirection(Element element);
Then following code :
+ DOM.setElementProperty(getElement(),
+ HasDirection.DIR_PROPERTY_NAME,
+ isRTL ? HasDirection.DIR_PROPERTY_VALUE_RTL : HasDirection.DIR_PROPERTY_VALUE_RTL);
can be replaced by:
DOM.setRTLDirection(getElement(), isRTL);
This will greatly improve readability for RTL program, since the above 2 function will be called very often.
Another thing we talked about before is margin in DOM, if we can have something like:
public static void setLeadingMargin(Element elem, string value) {
if (isRTLDirection(elem)) {
setElementAttribute(elem, "marginLeft", value);
} else {
setElementAttribute(elem, "marginRight", value);
}
For same reason, such method is frequently used and thus could a be candidate for addition.
shanjian
Hello RajeevIts great to see the bidi work in your patch! I will give my considered comments later but here are some initial impressions:1/ I really like the way the layout is tied to the locale. Being able to add "?locale=ar" to the URL is an ideal way to set the default direction. Is this also working for other RTL locales?
2/ Your patch file did not include corner-rtl.gif - I enclose it
4/ Not wanting to bring up any thorny issues but, what is the requirement to support Firefox 3 in GWT 1.5? I noticed several layout issues related to both Bidi and non-bidi cases. If these are new bugs in FF3 we should report them to Mozilla soon as FF3 is currently in beta.
5/ regarding the RTL HorizontalSplitPanel - I think it would be better to resize the left panel when you resize the window.
best regardsAdil
At 7:06 -0500 26/2/08, Rajeev Dayal wrote:
Content-Type: text/x-patch; name=bidilayout-r1910.patch
X-Attachment-Id: f_fd52xrls0
Content-Disposition: attachment; filename=bidilayout-r1910.patch
-User.gwt.xml now includes the I18N module. This change was necessary in order to support the use of LocaleInfo in the user libraries without having to move the LocaleInfo class into the user.client package
-Removed LocaleInfo_none_Test. This test was used to test that LocaleInfo functioned correctly when the I18N module was not included. Due to the above-mentioned change, this test is no longer relevant
+ public void setRTLDirection(boolean isRTL) {
+ DOM.setElementProperty(getElement(),
+ HasDirection.DIR_PROPERTY_NAME,
+ isRTL ? HasDirection.DIR_PROPERTY_VALUE_RTL : HasDirection.DIR_PROPERTY_VALUE_RTL);
Shouldn't that be:
+ public void setRTLDirection(boolean isRTL) {
+ DOM.setElementProperty(getElement(),
+ HasDirection.DIR_PROPERTY_NAME,
+ isRTL ? HasDirection.DIR_PROPERTY_VALUE_RTL : HasDirection.DIR_PROPERTY_VALUE_LTR);
Content-Type: text/x-patch; name=bidilayout-r1910.patch
X-Attachment-Id: f_fd52xrls0
Content-Disposition: attachment; filename=bidilayout-r1910.patch
I did some testing on Firefox 3 with RTL layout - the issues I previously noticed were fixed in one of the recent nightly builds but I did notice a general problem.If you open KitchenSink (with locale = ar) in Firefox and look at the Lists tab you will notice that the tree widget items and the text box label are left aligned. GWT Panels are rendered in HTML as tables. In the Lists tab the content is made up of a vertical panel that is explicitly left aligned which embeds a horizontal panel that embeds the widgets so:Vertical Panel (align = left) -> Horizontal Panel (default align) -> WidgetsIn Firefox, the left alignment of the vertical panel is affecting the default alignment of the horizontal panel only if the layout is rtl. This is also a general issue. I made a simple test case and tried it in IE, FF and Safari (see http://www.diwan.com/w/rtl-table.html).Each browser handles the inheritance of alignment into embedded tables in different and inconsistent ways. Even in tables that are not rtl.With the bidi changes we have defined a new alignment for GWT called ALIGN_DEFAULT. Because of the inconsistency in browsers we need to be stricter about defining exactly what "default" alignment means (especially for rtl applications) and then apply this consistently in panels on each browser.I suggest that ALIGN_DEFAULT should mean "right" if the locale is rtl and "left" otherwise. This should also be compatible with the way alignment is handled in GWT 1.4.So in CellPanel.setCellHorizontalAlignment and also HTMLTable we need to do something like this:protected void setCellHorizontalAlignment(Element td,
HorizontalAlignmentConstant align) {
if (align == HasHorizontalAlignment.ALIGN_DEFAULT)
{
if (LocaleInfo.getCurrentLocale().isRTL())
DOM.setElementProperty(td, "align", HasHorizontalAlignment.ALIGN_RIGHT.getTextAlignString());
else
DOM.setElementProperty(td, "align", HasHorizontalAlignment.ALIGN_LEFT.getTextAlignString());
}
else
DOM.setElementProperty(td, "align", align.getTextAlignString());
}It is depressing to see an elegant implementation of alignment have to be changed because each browser cannot agree how alignment is to be inherited.regardsAdil
At 11:15 -0500 29/2/08, Rajeev Dayal wrote:
Content-Type: text/x-patch; name=bidilayout_updated-r2078.patch
X-Attachment-Id: f_fdqt80c50
Content-Disposition: attachment; filename=bidilayout_updated-r2078.patch
Attachment converted: adil:bidilayout_updated-r2078.patch (TEXT/ttxt) (0066C9FD)
Content-Type: application/zip; name=rtlimages.zip
X-Attachment-Id: f_fdqt8gm81
Content-Disposition: attachment; filename=rtlimages.zip
Attachment converted: adil:rtlimages.zip (pZIP/«IC») (0066C9FE)
Hi Rajeev,Great work - and thanks for taking my comments to heart!- your zip has an incorrect image it should have menuBarSubMenuIcon_rtl.gif but has menuBarSubMenuIcon.gif instead.
- I think setSplitPosition does not need a bidi equivalent as the graphics environment has its zero offset on the left regardless so programmers should be used to this.
- DisclosurePanel definitely needs a left-pointing arrow for rtl.
- setLeadingMargin/setTrailingMargin was kind-of my idea and I spent some time persuading Shanjian to accept it! When I decided to implement this I saw some widgets were setting their indent programmatically (e.g. the Tree widget). If it is the case that a lot of GWT apps and widgets set the indent explicitly then I think we need setLeadingMargin/setTrailingMargin. If the future is for indents to all go into CSS then we don't.
I did some quick testing and the patch seems to be working nicely. So the patch looks good as far as I can see.I also did some work to bidi-fy (if that is a real verb) the Showcase sample. Showcase is very impressive. I really like the new decoration and animation effects! I have the following notes:
- animations for menus etc, definitely need rtl equivalents.
- DecoratorPanel adds "left" and "right" decorations. To follow the same principle as DockPanel "left" and "right" should keep their meaning - that would save a lot of extra CSS work. So I modified it to swap the order of the TR's in createTR() depending on the locale rtl so:static Element createTR(String styleName) {Element trElem = DOM.createTR();setStyleName(trElem, styleName);if (LocaleInfo.getCurrentLocale().isRTL()) {DOM.appendChild(trElem, createTD(styleName + "Right"));DOM.appendChild(trElem, createTD(styleName + "Center"));DOM.appendChild(trElem, createTD(styleName + "Left"));}else {DOM.appendChild(trElem, createTD(styleName + "Left"));DOM.appendChild(trElem, createTD(styleName + "Center"));DOM.appendChild(trElem, createTD(styleName + "Right"));
}return trElem;}
- I changed the GWT-default.rtl.css in Showcase to remove any special formatting for right and left decorations (enclosed).
- Showcase puts the shadow for the custom buttons on the opposite side for rtl layout. From experience shadows should not be swapped for rtl layout.
- Showcase has a method called: includeStyleSheets(). This replaces the current css file reference to refer to the rtl css file if the locale is rtl. It would be nice if the functionality of this method can be integrated into GWT proper so all an app has to do is include a ".rtl.css" and GWT will just know when to use it without any extra code.
- also I noticed that the rtl version of the css file had some errors. This made me think. In principle, when we have an RTL css, it should be done in a way where it only overrides the selectors that need to change not the whole file. That would make code more reliable. Would that be OK with all browsers or is it safer to replace the whole file?
- naming conventions. When we have a specific rtl version of a file we should have a standard naming convention. Currently there are three. e.g: blah-rtl.png, blah_rtl.png or blah.rtl.png. I suggest we match the i18n files and have blah_rtl.png.
I think that's it.regardsAdil
At 12:35 -0400 13/3/08, Rajeev Dayal wrote:
public interface TreeImages extends ImageBundle {
/**
* An image indicating an open branch.
*
* @return a prototype of this image
*/
AbstractImagePrototype treeOpen();
// ...
}
public interface TreeImagesRTL extends TreeImages {
@Resource("treeOpenRTL.gif")
AbstractImagePrototype treeOpen();
// ...
}
Tree {
public Tree() {
if (rtl) {
this(GWT.<TreeImages>create(TreeImages.class));
} else {
this(GWT.<TreeImagesRTL>create(TreeImagesRTL.class));
}
}
public Tree(TreeImages images) {
// ...
}
BidiUtils, HasDirection:- isDirectionRTLOnElement() implies boolean return, but is enum (should probably be get)- Direction.UNSET could be DEFAULT. You could then make setDirectionOnElement() take an enum as well (DEFAULT => clear property)
TextBox:- Minor formatting issues in setDirection()
HorizontalSplitPanel:- The 'final' qualifier was removed from a number of methods (e.g., getRightWidget()). Was this done for any particular reason?
MenuBar:- TODO left in (we should just make an issue)MenuBar:- menuBarSubMenuIcon_rtl.gif appears to be missing- Probably shouldn't be adding an rtl image to this image bundle, as it generates two *simultaneous* images. See below.
SuggestBox:- Could use some tests for popup positioning (that stuff does get a bit complicated...)
ListBox:- Not showing up RTL on Safari3 (could simply be a browser bug)
A few notes on RTL images:MenuBar, Tree, & DisclosurePanel have the problem that they allow images to be specified that might need to change for RTL locales. We need a way to make these user-specifiable (they currently all use ImageBundle) while only loading one image at a time. One proposal would be to continue to allow the ImageBundle to be passed into the ctor, and have the default ctor check for RTL and possibly pass a replacement to the ImageBundle ctor. An example would be:
public interface TreeImages extends ImageBundle {
/**
* An image indicating an open branch.
*
* @return a prototype of this image
*/
AbstractImagePrototype treeOpen();
// ...
}
public interface TreeImagesRTL extends TreeImages {
@Resource("treeOpenRTL.gif")
AbstractImagePrototype treeOpen();
// ...
}
Tree {
public Tree() {
if (rtl) {
this(GWT.<TreeImages>create(TreeImages.class));
} else {
this(GWT.<TreeImagesRTL>create(TreeImagesRTL.class));
}
}
public Tree(TreeImages images) {
// ...
}
}