Class AvatarGroup

java.lang.Object
limn.scene.Widget<AvatarGroup>
limn.components.AvatarGroup

public final class AvatarGroup extends Widget<AvatarGroup>
People drawn as a stack of Avatars: the approvers of a document, the members of a team. Each avatar overlaps the one before by a quarter of its width, ringed in the surface colour so the overlap reads as a stack. A circle covered by the next one centres its initials on the part that shows, the three quarters away from the overlap, so no letter is cut; the last circle keeps them in its middle. Every circle draws its initials at one size: the label's, or the smaller size the group's widest pair needs to fit that part ("MW" in the shipped face), so the stack reads even.

Past the most shown (four by default), the first ones are drawn and the last place is a circle that says how many more there are, "+3", whose tooltip lists the hidden names. The count takes no click: a group is a picture of who, and a list of everyone is the application's, in a Popover from a button beside it if it wants one.

To a reader a group is one node, a Accessible.Role.GROUP named by Widget.setAccessibleName(limn.i18n.I18nString) ("Approvers") and described by every member's name in order, the hidden ones included, joined by the language's list comma. The avatars inside are not published: they would repeat the description, and the hidden ones have no box to publish. A reader is not limited by the width the eye is.

Right to left, the group starts at the leading edge, the right one, and overlaps toward the left.


 new AvatarGroup(new Avatar("Ana Lima"), new Avatar("Rui Costa"), new Avatar("Eva Melo"))
         .setAccessibleName("Approvers");
 
  • Constructor Details

    • AvatarGroup

      public AvatarGroup(Avatar... avatars)
      A group of the avatars given, in order.
      Parameters:
      avatars - the members, in the order drawn
  • Method Details

    • add

      public AvatarGroup add(Avatar avatar)
      Adds a member at the end.
      Parameters:
      avatar - the member to add, which is in no other group
      Returns:
      this group
      Throws:
      IllegalArgumentException - if the avatar is already in a group
    • remove

      public AvatarGroup remove(Avatar avatar)
      Removes a member.
      Parameters:
      avatar - the member
      Returns:
      this group
    • members

      public List<Avatar> members()
      Returns:
      the members, in order, the hidden ones included
    • setMaxShown

      public AvatarGroup setMaxShown(int count)
      How many circles the group draws at most, the "+k" circle included: past it, the first count - 1 members are drawn and the last place counts the rest.
      Parameters:
      count - at least 1
      Returns:
      this group
      Throws:
      IllegalArgumentException - if count is less than 1
    • maxShown

      public int maxShown()
      Returns:
      how many circles the group draws at most
    • hiddenCount

      public int hiddenCount()
      Returns:
      how many members are hidden behind the "+k" circle
    • onMeasure

      protected Size onMeasure(Constraints constraints)
      Description copied from class: Widget
      Reports the size this widget wants within constraints. Called once per layout pass, and the result is cached against the constraints and the resolved axes (size step, layout direction, locale), so it must be a pure function of them and of this widget's own state.

      Resolve the ControlSize and the LayoutDirection once each here and thread them down; never read either in a constructor. The locale needs no threading: it is in scope, and I18n.locale() answers it wherever text is resolved.

      Specified by:
      onMeasure in class Widget<AvatarGroup>
    • onLayout

      protected void onLayout()
      Description copied from class: Widget
      Containers position children here (measure + Widget.layoutBox(float, float, float, float) per child).
      Overrides:
      onLayout in class Widget<AvatarGroup>
    • onAccessibility

      protected void onAccessibility(Accessibility a)
      One Accessible.Role.GROUP, named by the application and described by every member, the hidden ones included.
      Overrides:
      onAccessibility in class Widget<AvatarGroup>
      Parameters:
      a - the node being described
    • onAccessibilityChild

      protected void onAccessibilityChild(Widget<?> child, Accessibility a)
      The circles inside are not published: the group's description already says every name.
      Overrides:
      onAccessibilityChild in class Widget<AvatarGroup>
      Parameters:
      child - the child being described
      a - the child's node