wiki:BOOK_WINDOW_R1
Last modified 16 years ago Last modified on 06/09/09 04:05:52

Error: Macro BackLinksMenu(None) failed
compressed data is corrupt

Error: Macro TicketQuery(summary=BOOK_WINDOW_R1, format=table, col=summary|owner|status|type|component|priority|effort|importance, rows=description|analysis_owners|analysis_reviewers|analysis_score|design_owners|design_reviewers|design_score|implementation_owners|implementation_reviewers|implementation_score|test_owners|test_reviewers|test_score|) failed
current transaction is aborted, commands ignored until end of transaction block

Analysis

Overview

Book window is responsible for displaying the book. Book window is present in Author app and not in Reader.
Book window has

  • Title bar - title bar contains the name of the book and buttons for minimize, restore and close.
  • Bottom bar - has zoom, page selector and other controls

Task requirements

  1. Remove the thick black border of the book window (see if it is reasonable)
  2. Minimize button should minimize book to the Opened book tabbar. Currently a new button is created at the bottom of the work area.
  3. The default position of the page work area should be at the center of the book window.
  4. If the page work area can be displayed in the book window, it should be at the center of it. Recomputing should be done on mouse drop (if possible). When scrollbars appear, the position should not be recomputed anymore. On book open the page work are should be centered in the book window.
    • On change of the size of the book
    • On change of the size of the window
  5. Define minimum size of the book window, so that scroll bars for the controls (bottom book panel) do not appear.

Task result

Code.

Implementation idea

  • JInternalFrame supports the drawing of a title bar in a new java project, but it is not displaying in Sophie.
    • computeTitle on BookDocumentWindow
  • The border with is currently hard-coded, with a comment from mitex to add this to the skin definition "later" Consider doing this now
  • Minimum size of the book should be calculated based on the size of the bottom book panel, so that if the panel is changed, the window reacts properly
  • It appears that resizing the book window does not resize the background, and thus the page does not re-center
  • Ask if we want a Sophie looking title or the host OS title bar for these windows
  • Regarding the centering of the page, the PageWorkArea is a set size based on the size of the page and the JScrollArea on the BookDocument window scrolls that. The page is centered on the PageWorkArea. The PageWorkArea is aligned topLeft. So maybe the PageWorkArea needs to be resized as the window is resized, maximize=infinity, minimize=page size

How to demo

  • Demo the position of the page within the window as the window is resized on the desktop
  • Demo the book restricting re-sizing the book window to the minimal size

Design

  1. Border: Remove the call to setBorder on the JInternalFrame in the setup() method of BookDocumentWindow.swingFrameSync(). This not only will remove the border, it brings back the title bar and window shadows on the Macintosh
  1. Removing the iconified book from the desktop - ie, handing iconification better

2.1 - Add a method named show() to DefaultDocumentWindow that shows the document window and makes sure it is not iconified.

2.2 - When the swing frame is iconified in DefaultDocumentWindow, make sure Sophie knows it is deselected by calling userActs. This is important as the desktop panes only use swing calls to iconify/deiconify the window. Also, set the window's visible to false so it does not show on the desktop.

2.3 - When the swing frame is decionified in DefaultDocumentWindow, make sure Sophie knows it is selected by calling userActs. This is important as the desktop panes only use swing calls to iconify/deiconify the window.

2.4 - In BookLogic, when a book is selected, make sure it's window is told to show(). This ensures that anything in Sophie that selects a book (ie a click, or a menu item) makes sure that the window for the newly selected book is deiconified and showing.

  1. The default position of the page work area should be at the center of the book window

3.1 The scene positions what it renders in the swing by calling SceneToSwing on every coordinate. Change SimpleSceneVisual actualViewRect to center minimalViewRect's coordinates around the scene's coordinates. Thus, as minimalViewRect grows, the scene will render centered in the window. Do this by taking the delta of the widths and heights of the minimalViewRect and the scene rect and subtracting half them from the location of the scene rect, while setting the width and height of the scene rect to the larger of the scene rect or minimalViewRect.

  1. Change the page work area to consider the size of the book window as well as the page

4.1 - Add minimalViewRect() property to SceneVisual, which defines the smallest size a scene visual should be

4.2 - Modify SimpleSceneVisual actualViewRect() to take minimalViewRect into account

4.3 - Add a ComponentListener to DefaultDocumentWindow so that it can know when the swing internalFrame is resized

4.4 - Add property windowSize to DefaultDocumentWindow to track the window's size

4.5 - Add a resource property to PageWorkArea to track the document window's size and set the scene's minimalViewRect and repaint (force update)

  1. Define minimum size of the book window, so that scroll bars for the controls (bottom book panel) do not appear

5.1 - Remove the use of bottomPanelScroll() in BookDocumentWindow

5.2 - use setMinimumSize(widthOfBottomPanel,Integer.MAX_VALUE) on the swing panel to keep the window from being resized too small horizontally

Classes To Modify

  • BookDocumentWindow
  • DefaultDocumentWindow
  • SceneVisual
  • SimpleSceneVisual
  • DummySceneImplementation in SceneDemo
  • MDDocumentWindow

Implementation

  1. Remove the border from the page work area

Removed the call to setBorder from the setup() method of MDDocumentWindow. This change should be checked on Windows and Linux. It removed the border as requested (and fixed a Mac issue with no title bar)

  1. Removing the iconified book from the desktop

Added method show to MDDocumentWindow swingFrame() which causes the window to become active and visible. When the window is iconified, use userActs to disable the current book. Because of the fullscreen changes, changed the implementation to call method show from setupCurrent, which tracks the current state of the DefaultDocumentWindow instance.

  1. Center the page on the page work area

The design was wrong. SimpleSceneVisual adjusts the actual view rect into negative coordinates, which are then offset by SceneToSwing. So in order to properly center everything in the page work area, changed actualViewRect to determine an x and y offset based on the deltas between the actual view rect and the minimal view rect. This offset is then subtracted from the origin, much like the padding is, and causes the page, frames, halos, etc to be centered on the page work area.

  1. Change BookDocumentWindow to track changes to it's content pane and update the sceneVisual minimalViewRect

Added minimalViewRect to SceneVisual which is set by the page work area which determines what size we'd like the scene to be. Added miniamalSceneRect property to SceneVisual which returns the smallest rectangle that encompasses the scene (not including background). Added an component listener to BookDocumentWindow which listens for resize changes on the JPanel. When the event listener is notified that the window was resized, determine if we still need scroll bars or not and also set the minimalViewRect on the scene.

Added actualViewRectCache to SceneVisual which is a property that is set to the actualViewRect whenever the actualViewRect changes. This allows a class interested in this to watch for changes and repaint. PageWorkArea currently utilizes this in actualViewRectCacheSync(). This is necessary (for now) to ensure the scene paints properly because the scene uses the swing coordinate system to actually lay out the objects (vs. a discreet offset type of property) so if you change the actualViewRect value during an event (and this happens every time you resize a page or frame) then the repaint code only draws the newly offset pixels and not the older bits that it doesn't know changed. See suggestions for future tasks in comments about this issue.

  1. Define minimum size of the book window, so that scroll bars for the controls (bottom book panel) do not appear

Due to delays caused by the merging and changes from fullScreen mode, this was not implemented for weekly time boxing purposes

-- ChangeSets --

[3062] - Commit after merge with trunk, with all changes except "Define minimum size of the book window" because of changes to panels, need to fix the implementation

[3205] - Fix for over-iconifying windows

[3272] - Refactor changes, move code into BookDocumentWindow, clean up MDDocumentWindow, clean up iconification, refactor setup

Unit Tests

[2834] - Updated BookViewUnitTest to test the BookDocumentWindow (which implements BookView interface)

Testing

Comments

The page should be at the center of the book window. (when bigger than it, in other cases scrollbars are responsible for positioning of the page.)

2009-05-12

  • The default position of the page should be at the center of the book window. -Isn't it already at the center of the book window? It doesn't re-center as you resize the window, but I think it is centered by default at least on my system.
  • I need to know if you want the page work area to expand to the size of the window, and then have the page stay centered on the page work area? That would mean a large change to how things work now, which is ok, I just need to know that this is what you want.
  1. Comments - The iconification is handled by the current look and feel, triggered by the look and feel minimize button (or in the case of the tab bar, the show desktop button, which walks all frames (windows) and calls setIcon(true). Simply hiding or showing the frame is not acceptable as it does not maintain a separate state of the window. Currently the plan is to figure out how to change the look and feel's iconify behavior. WindowListener iconify events are only called *after* the window is iconified and are intended to be used as a way for the document to release resources, etc and thus not useful for this problem. -- sriggins

2009-05-15

2009-05-22

  • Please super review and remove task requirements 2 and 6 due to time boxing - sriggins

-- Removed Task Requirements --

  1. Currently, when part of the book window is behind the right flap ot the bottom of the workspace, it disappears on maximize. See what causes that issue and fix it.
  2. Make the background of the window changable by the skin (optional)
  1. Define minimum size of the book window, so that scroll bars for the controls (bottom book panel) do not appear

5.1 - Remove the use of bottomPanelScroll() in BookDocumentWindow

5.2 - use setMinimumSize(widthOfBottomPanel,Integer.MAX_VALUE) on the swing panel to keep the window from being resized too small horizontally

-- Suggestions for future tasks --

  • Change SimpleSceneVisual to not just rely on the coordinate system being offset to actually do the math to figure out where things are. This causes all sorts of redraw issues and is evident even before this task's changes (click and drag in the page work area of alpha 1, for example) Swing only repaints what it thinks is dirty (optimization) so if the coordinate system changes during an event, then things do not get repainted properly. Either this needs to change, or we need to rethink how scenes communicate with those classes displaying scenes to ensure everything gets updated properly. We just need a better coordinate system for scenes vs relying on offsetting the swing coordinates.

-- Older Changesets ---

[3013] - Commit before merging with trunk (keep this because sub-task 5 is here but not committed yet)

Attachments