Version 20 (modified by sveto, 16 years ago) (diff) |
---|
Analysis
Overview
The page preview palette is a part of the page tab in the left flap of the main window. It contains a list of representations of all pages in the book which can be manipulated to add, delete, or rearrange pages.
Task requirements
- The page palette should list thumbnails of the pages in the currently selected book.
- Selecting a thumbnail makes its page the current page of the book.
- A selected page may be deleted. User should be able to delete by pressing DELETE or BACKSPACE.
- The thumbnails are redrawn when the user changes pages.
- For this revision, thumbnails should be a fixed width (say 100 pixels wide) so that they are not redrawn when the user changes the flap width.
- For this revision, two buttons should appear at the bottom of the palette, labeled "Add Page Before" and "Add Page After". If "Add Page Before" is clicked, a new page is inserted immediately before the current page. If "Add Page After" is clicked, a new page is inserted immediately after the current page.
Task result
The result of this task is source code.
Implementation idea
Add the palette to the left flap and bind the list of its items to the books pages.
Change the existing PagePreviewPalette and PagePreviewCellRenderer classes. Use the framework in org.sophie2.base.scene to get page information (use scenes).
How to demo
- Open the page preview palette and show the thumbnails of all the pages in the book.
- Click on another page thumbnail in the page preview palette and see that Sophie goes to that page.
- Change something on a page and go to another page to show that the thumbnails are redrawn.
- Add a new page after the current page by clicking the "Add Page Before" button.
- Select a page in the page preview palette and hit DELETE to delete the page.
Design
- Most of the functionality is in place.
- We need to add a ReadPageWorkArea and a SimpleSceneVisual property in PagePreviewPalette. The ReadPageWorkArea should be used to set the current page as the page changes so a Scene object can be extracted from it. The Scene object should be set in the SimpleSceneVisual object to initiliaze it. In PagePreviewPaletteCellRenderer a java.awt.Component is obtained from the SimpleSceneVisual and SceneHelper is used to draw it to the graphic. Before the drawing the Graphics object is scaled by the ratio of thumbwidth/pagewidth.
- Functionality for setting the selected thumbnail as current page is already in place.
- Functionality for deleting a page is already in place.
- Functionality for updating the thumbnails once another page is selected is already in place.
- Two resource properties for the two buttons (add page before/after) should be created in PagePreviewPalette and added to the bottom of the palette in an overridden initFooter method. To facilitate this the ListPalette class will be supplemented with methods to add visual components to the footer of the palette.
- Classes to be changed:
- PagePreviewPalette
- PagePreviewPaletteCellRenderer
- ListPalette to add a footerComponent and an initFooter method.
- MainAppLayoutModule to add the palette to the Pages tab.
Implementation
(Implementation results should be described and linked here (from the wiki or the repository))
Testing
Comments
For later revisions:
- The user can rearrange pages by dragging them up and down.
- Dragging a page template from the right flap into the page preview template is creating a new page from this template. The new page is inserted before, between, or after existing pages depending on where the template was dropped.
- A template may be applied to a page by dragging the template to a page in the page preview palette.
- The thumbnails should be resized when the user changes the width of the flap.
Notes:
- I suspect that updating the page thumbnails every time a page is changed will end up making the entire program very slow. Probably we want to redraw thumbnails more frequently that every time the user changes pages, but we might want to think about only making some changes trigger thumbnail redrawing.