wiki:TEXT_LINK_MANIPULATION_R0
Last modified 15 years ago Last modified on 11/05/09 18:18:33

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

Error: Macro TicketQuery(summary=TEXT_LINK_MANIPULATION_R0, 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

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)

  • 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.

GROUP_LINKS_R0

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

  • Model
    • ImmHotText will keep text links as attachments.
    • create a marker interface for text attachments 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> attachments
      • add it as an argument to the private contructor
      • add helper methods to add or remove attachments
    • create a new class LinkAttachment in org.sophie2.main.func.text.model package
      • it will implement Attachment and have a Link as private field.
      • in addition, it will have 4 ImmColor private fields that are used for highlighting the link in its 4 different states - normal, hover, visited, pressed.
      • it will have producer methods that change a specific color.
    • make sure that text with link attachments is persisted correctly
      • persist the attachments map in ImmHotTextPersister
      • create a new class LinkAttachmentPersister extending RefToStoragePersister<LinkAttachment> to persist link attachments

  • Highlights
    • Highlights will be added in HeadTextFrameView .
      • add a new property that contains a list of all hovered links - ListProp<LinkAttachment> 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.
    • Swithing between the different states and changing highlights will be done in a new logic - TextFrameLogic

  • Executing links
    • Evoking link triggers:
      • 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 LINK_ACTION_TRIGGERED event if the MOUSE_ENTER or MOUSE_LEAVE triggers have been evoked. This operation does not cover the case when there are some hovered text links and the mouse leaves the frame.
        • ON_MOUSE_EXITED_FRAME - removes the highlights for hovered links when the mouse leaves the frame and fires LINK_ACTION_TRIGGERED event if the MOUSE_LEAVE trigger has been evoked.
        • ON_MOUSE_PRESSED, ON_MOUSE_RELEASED and ON_MOUSE_DOUBLE_CLICKED - fire LINK_ACTION_TRIGGERED event if the MOUSE_PRESSED trigger has been evoked.
      • add a resource access as a second parameter to the LinkProcessorLogic.LinkEvent#LINK_ACTION_TRIGGERED event. If the LinkAction has a resource as target (for example a frame to show), this access should be used to open an access to the target resource.
    • Executing link actions should be done by already existing logics.
      • they should be modified to use the resource access argument instead of the context resource view to open the target resources.
  • LinkHolder - an interface that can be used by logics and huds to access and manipulate in the same way the links associated with different resources. In particular, it will be used in LinksHud to display and modify both frame and page links, and text link attachments.
    • It has the following methods:
      • Link getLink();
      • ResourceRefR4 getRef();
      • ResourceAccess getAccess();
      • List<LinkTrigger> getTriggers() - gets a list of all possible triggers for this holder's link.
    • Add a nested class SimpleLinkHolder exdending LinkHolder in ElementView .
      • add a new property in ElementView - public Prop<SimpleLinkHolder> linkHolder()
    • Add a nested class TextLinkHolder exdending LinkHolder in HeadTextFrameView .
      • it will need one additional method - public LinkAttachment getLinkAttachment().
      • add a new property in HeadTextFrameView - public Prop<TextLinkHolder> textLinkHolder()
  • Huds - general
    • The existing LinksHud should be used for creating links for both element links and for text link attachments.
    • The holder property's type will be changed from ElementH to LinkHolder.
    • Two subclasses of LinksHud will be created:
      • ElementLinksHud with a SimpleLinkHolder
      • TextLinksHud with a TextLinkHolder and additional controls for selecting link colors in org.sophie2.main.func.text.view package.
    • The operations in LinksHudLogic should be modified to make the new link and to throw a new SET_LINK event instead of setting the link in the model.
    • A new operation ON_SET_ELEMENT_LINK in LinksHudLogic will register an autoaction to set the link of ElementLinksHud's model.
    • A new operation ON_SET_TEXT_LINK in TextLinksHudLogic will create a new ImmHotText object with the changed link and fire a SET_TEXT event.
  • TextLinksHud's hierarchy:
    • ColorTitleBar extending HudTitleBar
      • ColorSubHudButton extending SubHudButton - shows TextLinkColorHud
        • TextLinkColorHud - a hud with 4 color picker fields (see the picture in the analysis)
          • NormalColorField extends ColorPickerHudField - a color picker field that changes the link's normal color.
          • HoverColorField extends ColorPickerHudField - a color picker field that changes the link's hover color.
          • VisitedColorField extends ColorPickerHudField - a color picker field that changes the link's visited color.
          • PressedColorField extends ColorPickerHudField - a color picker field that changes the link's pressed color.
          • TextLinkColorHudLogic with 4 operation, each one changing the color for a different state.
    • ColorField extends ColorPickerHudField - a color picker field that changes all links colors simultaneously.
    • TextLinksHudLogic with 2 operations:
      • ON_SET_TEXT_LINK described above
      • ON_COLOR_SUBMIT changes the color of all link's states simultaneously

Implementation

  • Done according to the design... with the following changes:
    • The type of the hoveredLinks property in HeadTextFrameView was changed from LinkAttachment to HotInterval. This is safe, because no more than one link can be attached to a single interval.
    • Pressed links: a new list property pressedLinks is added in HeadTextFrameView and the link attachments whose intervals it contains are highlighted in HeadTextFrameView.textView()...textFlow().getExtraHighlights()
    • Visited links: A new boolean field visited was added to Link . When a link that is attached to text is executed, we mark it as visited in the model. This happens in FrameTextLogic and enables us to add special highlights for visited links.

  • Merged to the trunk at [7958].

Testing

(Place the testing results here.)

Comments

(Write comments for this or later revisions here.)

Attachments