Version 11 (modified by deni, 16 years ago) (diff) |
---|
Analysis
Overview
This task is focused on delivering link functionality inside text frames.
Task requirements
- Create a halo for text links which evokes a HUD
- The halo should appear when text is selected.
- When pressed it should evoke a HUD (sample design for the HUD is added in the implementation idea below)
- Since the text's link functionality is so similar to the frame's link functionality, the HUDs could be almost identical with some minor differences.
- There must be a possibility to change the coloring of the link (see the implementation idea).
- When text is converted to link, there must be a visual marker for that (at least changing the text color)
- The triggers for the links are almost the same as the ones for the links we now have
- Mouse enter
- Mouse leave
- Mouse double click
- Mouse pressed
- Mouse released
- The actions are also similar to the events for regular links. However some new must be added:
- [Optional for this task] Open URL
Task result
The result of this task must be code.
Implementation idea
- Sample HUDs and their layout
- By default the link color for the over, pressed, visited and normal is the same, but the user can change that accessing additional subhud (as shown on the picture)
- By default the link color for the over, pressed, visited and normal is the same, but the user can change that accessing additional subhud (as shown on the picture)
- Keep the links as attachment in ImmHotText ot the text resource.
- Use the existing links hud and the logics connected with it for the UI.
- Use highlights to distinguish between the different states of a links.
Related
How to demo
- Insert text frame.
- Add some text in it and create link.
- Use different coloring options.
- Try if the link works in preview mode or reader.
Design
- ImmHotText will keep text links as attachments.
- create a marker interface for text attachmens in org.sophie2.base.model.text package - Attachment
- add a private field in ImmHotText that contains all attachments of this text - private ImmMap<HotInterval, Attachment> links
- add it as an argument to the private contructor
- make sure that all producer methods (such as applyStyle) keep this map
- create a new class TextLink in org.sophie2.main.func.text.model package
- it will extend Link and implement Attachment
- it will have 4 ImmColor private fields that are used for highlighting the link in its 4 different states - normal, hover, visited, pressed.
- ? maybe the normal state is unnecessary, because the normal style is defined using the text font hud.
- it will have producer methods that change a specific color.
- Highlights will be added in HeadTextFrameView.
- add a new property that contains a list of all hovered links - ListProp<TextLink> hoveredLinks()
- use this property to create the appropriate highlights in HeadTextFrameView.textView()...textFlow().getExtraHighlights()
- override void touch() in HotTextElementHelper to depend on the highlights, so that the scene gets repainted when the highlights change.
- A new logic will handle switching between the different states and firing LinkEvent.LINK_ACTION_TRIGGERED when a link has been triggered.
- create a new class TextFrameLogic in org.sophie2.main.func.text.view package with the following operations:
- ON_MOUSE_MOVED - takes care of highlighting hovered text links and firing an event if the MOUSE_ENTER and MOUSE_LEAVE triggers have been evoked while the mouse moves over a text frame view. This operation does not cover the case when there are some hovered links and the mouse leaves the frame.
- ON_MOUSE_EXITED_FRAME - removes all text links highlights and if necessary fire events for MOUSE_LEAVE trigger evocation.
- ON_MOUSE_PRESSED, ON_MOUSE_RELEASED and ON_MOUSE_DOUBLE_CLICKED take care to fire an event if the MOUSE_PRESSED, MOUSE_RELEASED and MOUSE_DOUBLE_CLICKED triggers of a text link have been evoked.
- The last 3 operations use a helper method - private static void fireLinkTriggeredEvents(EventR3 event, LinkTrigger trigger) .
- create a new class TextFrameLogic in org.sophie2.main.func.text.view package with the following operations:
- Executing the link actions should be done by already existing logics.
- ? However they require a ResourceView in order to use its access to open an access to their argument (frame, page).
- ? Maybe we will use the current BookView. In order to do so, we should make sure that all ResourceRef-s in huds are relative to the book.
- Hud ?
- Source code: [7801]
- Tests: TextLinksDemo
Implementation
Testing
(Place the testing results here.)
Comments
(Write comments for this or later revisions here.)
Attachments
- textlinks.png (61.6 KB) - added by todor 16 years ago.