41 | | ^(Describe your design here.)^ |
| 41 | * ImmHotText will keep text links as attachments. |
| 42 | * create a marker interface for text attachmens in org.sophie2.base.model.text package - {{{ Attachment }}} |
| 43 | * add a private field in ImmHotText that contains all attachments of this text - {{{ private ImmMap<HotInterval, Attachment> links }}} |
| 44 | * add it as an argument to the private contructor |
| 45 | * make sure that all producer methods (such as applyStyle) keep this map |
| 46 | * create a new class {{{ TextLink }}} in org.sophie2.main.func.text.model package |
| 47 | * it will extend {{{ Link }}} and implement {{{ Attachment }}} |
| 48 | * it will have 4 ImmColor private fields that are used for highlighting the link in its 4 different states - normal, hover, visited, pressed. |
| 49 | * ? maybe the normal state is unnecessary, because the normal style is defined using the text font hud. |
| 50 | * it will have producer methods that change a specific color. |
| 51 | |
| 52 | * Highlights will be added in {{{HeadTextFrameView}}}. |
| 53 | * add a new property that contains a list of all hovered links - {{{ ListProp<TextLink> hoveredLinks() }}} |
| 54 | * use this property to create the appropriate highlights in {{{ HeadTextFrameView.textView()...textFlow().getExtraHighlights() }}} |
| 55 | * override {{{ void touch() }}} in {{{ HotTextElementHelper }}} to depend on the highlights, so that the scene gets repainted when the highlights change. |
| 56 | |
| 57 | * A new logic will handle switching between the different states and firing {{{ LinkEvent.LINK_ACTION_TRIGGERED }}} when a link has been triggered. |
| 58 | * create a new class {{{ TextFrameLogic }}} in org.sophie2.main.func.text.view package with the following operations: |
| 59 | * 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. |
| 60 | * ON_MOUSE_EXITED_FRAME - removes all text links highlights and if necessary fire events for MOUSE_LEAVE trigger evocation. |
| 61 | * 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. |
| 62 | * The last 3 operations use a helper method - {{{ private static void fireLinkTriggeredEvents(EventR3 event, LinkTrigger trigger) }}}. |
| 63 | |
| 64 | * Executing the link actions should be done by already existing logics. |
| 65 | * ? However they require a ResourceView in order to use its access to open an access to their argument (frame, page). |
| 66 | * ? 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. |
| 67 | |
| 68 | * Hud ? |
| 69 | |
| 70 | * Source code: [7801] |
| 71 | * Tests: TextLinksDemo |