From 5cae1eabc82d4fcd106897abb9acbd482ad2f849 Mon Sep 17 00:00:00 2001 From: Tor Norbye Date: Mon, 16 Apr 2012 13:52:02 -0700 Subject: Improved layout window management This changeset improves the way the layout editor handles windows. In particular, it attempts to make the property sheet and the outline more visible. Specifically: * It adds the WindowBuilder docking support, which offers several new features: (1) You can collapse and expand the palette and structure views. If you hover over a collapsed palette (for example) it temporarily opens, and when you drag from it over to the canvas it collapses again. (2) The initial size is pixel based rather than percentage based, so the default palette size is more reasonable on large displays (it used to always take 20%, which was fine on a small screen but a waste on larger screens). (3) You can drag & drop to reconfigure the layout a bit. (This is fairly limited though; in particular, you cannot drag these views out of the editor area and mix them with Eclipse views.) * When the property sheet view is not shown anywhere else, it is shown as part of the outline instead (sharing the vertical space). This works better for the new property sheet implementation since it works better as a vertical window than a horizontal window. * When the outline is not shown anywhere else, it is shown in a new composite window *inside* the editor area. This mode is also entered when you temporarily maximize the layout editor window. * The layout canvas is auto-fit-zoomed when you enter and exit maximized mode, as well as when you open or close docked windows within the editor. The goal is for these changes to offer a good layout editing experience with the outline views and property sheets *without* using a new perspective for layout editing. Note that this is not identical to what WindowBuilder does; they always embed both the palette and the structure views within the editor area, which means the structure view is typically redundant with the outline view on the right unless you maximize the view. With the approach above hopefully we'll avoid that case and you'll always see the views without redundancy (and therefore with more available space for the layouts). Change-Id: I0d338b2781b9732e992f088fcc4e1ba46ff0954f --- .../internal/editors/layout/gle2/LayoutCanvas.java | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java') diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java index 8913850ce..1354ebe82 100755 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java @@ -281,8 +281,12 @@ public class LayoutCanvas extends Canvas { @Override public void controlResized(ControlEvent e) { super.controlResized(e); + mHScale.setClientSize(getClientArea().width); mVScale.setClientSize(getClientArea().height); + + // Update the zoom level in the canvas when you toggle the zoom + getDisplay().asyncExec(mZoomCheck); } }); @@ -309,7 +313,28 @@ public class LayoutCanvas extends Canvas { } } - public void handleKeyPressed(KeyEvent e) { + private Runnable mZoomCheck = new Runnable() { + private Boolean mWasZoomed; + + @Override + public void run() { + if (isDisposed()) { + return; + } + + IEditorPart editor = getEditorDelegate().getEditor(); + IWorkbenchPage page = editor.getSite().getPage(); + Boolean zoomed = page.isPageZoomed(); + if (mWasZoomed != zoomed) { + if (mWasZoomed != null) { + setFitScale(true /*onlyZoomOut*/); + } + mWasZoomed = zoomed; + } + } + }; + + void handleKeyPressed(KeyEvent e) { // Set up backspace as an alias for the delete action within the canvas. // On most Macs there is no delete key - though there IS a key labeled // "Delete" and it sends a backspace key code! In short, for Macs we should @@ -565,6 +590,7 @@ public class LayoutCanvas extends Canvas { Image image = mImageOverlay.setImage(session.getImage(), session.isAlphaChannelImage()); mOutlinePage.setModel(mViewHierarchy.getRoot()); + mEditorDelegate.getGraphicalEditor().setModel(mViewHierarchy.getRoot()); if (image != null) { mHScale.setSize(image.getImageData().width, getClientArea().width); -- cgit v1.2.3