[gwt-contrib] FastTree focus issue

2009-04-15 Thread jlabanca

Reviewers: rjrjr,

Description:
Description:
===
The focusable element in FastTree is being positioned relative to the
window (or whatever its offset parent happens to be) instead of the
FastTree itself.  This causes the window to jump when the TreeItem is
selected.


Fix:
===
This patch sets the outer element of FastTree to "relative" so it can
act as the offfet parent.  It also fixes up the focusable widget so it
has the correct height, width, top and left values.


Testing:
==
I verified that that FastTree no longer jumps on any browser.  Another
patch in the GWT trunk will further improve the scrollIntoView method so
it scrolls to the correct location.

Please review this at http://gwt-code-reviews.appspot.com/20802

Affected files:
   src-demo/com/google/gwt/gen2/demo/fasttree/client/FastTreeDemo.java
   src/com/google/gwt/gen2/complexpanel/client/FastTree.java
   src/com/google/gwt/gen2/widgetbase/public/FastTree.css
   src/com/google/gwt/gen2/widgetbase/public/FastTree_base.css



--~--~-~--~~~---~--~~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~--~~~~--~~--~--~---



[gwt-contrib] FastTree Focus Issue

2009-04-06 Thread nwolf

Reviewers: jlabanca, minz,

Description:
There was a focus issue with the fasttree when the size of the tree was
larger than the viewport, this was especially manifested with very large
trees.

Please review this at http://gwt-code-reviews.appspot.com/18801

Affected files:
   com/google/gwt/gen2/complexpanel/client/FastTree.java


Index: com/google/gwt/gen2/complexpanel/client/FastTree.java
===
--- com/google/gwt/gen2/complexpanel/client/FastTree.java   (revision 1594)
+++ com/google/gwt/gen2/complexpanel/client/FastTree.java   (working copy)
@@ -53,6 +53,7 @@
  import com.google.gwt.user.client.DOM;
  import com.google.gwt.user.client.Element;
  import com.google.gwt.user.client.Event;
+import com.google.gwt.user.client.Window;
  import com.google.gwt.user.client.ui.Accessibility;
  import com.google.gwt.user.client.ui.Focusable;
  import com.google.gwt.user.client.ui.Panel;
@@ -849,15 +850,26 @@
}

private void moveElementOverTarget(Element movable, Element target) {
-int containerTop = getAbsoluteTop();
-
-int top = DOM.getAbsoluteTop(target) - containerTop;
+int top = DOM.getAbsoluteTop(target);
  int height = DOM.getElementPropertyInt(target, "offsetHeight");
+int left = DOM.getAbsoluteLeft(target) + getAbsoluteLeft();
+int width = DOM.getElementPropertyInt(target, "offsetWidth");
+
+int maxBottom = Window.getScrollTop() + Window.getClientHeight();

+if (top + target.getOffsetHeight() > maxBottom) {
+  top = maxBottom - target.getOffsetHeight();
+}
+
  // Set the element's position and size to exactly underlap the
  // item's content element.
  DOM.setStyleAttribute(movable, "height", height + "px");
-DOM.setStyleAttribute(movable, "top", top + "px");
+
+if (top > 0) {
+  DOM.setStyleAttribute(movable, "top", top + "px");
+}
+DOM.setStyleAttribute(movable, "left", left + "px");
+DOM.setStyleAttribute(movable, "width", width + "px");
}

/**



--~--~-~--~~~---~--~~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~--~~~~--~~--~--~---