Changeset 664


Ignore:
Timestamp:
01/08/14 10:37:24 (10 years ago)
Author:
jts21
Message:

Add tooltip template to settings, and make _tooltipItem a static variable of the Item class which is set to whichever tooltip needs to be displayed

Location:
trunk/src/org/expeditee
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/gui/Frame.java

    r657 r664  
    511511
    512512                return t;
     513        }
     514       
     515        public Item getTooltipTextItem(String tooltipText) {
     516                return getTextItem(tooltipText, UserSettings.TooltipTemplate.get().copy());
    513517        }
    514518
  • trunk/src/org/expeditee/gui/FrameGraphics.java

    r656 r664  
    523523                        if(current != null) {
    524524                                current.paintTooltip(bg);
     525                        } else {
     526                                Item.clearTooltipOwner();
    525527                        }
    526528                }
  • trunk/src/org/expeditee/items/Item.java

    r656 r664  
    159159       
    160160        private String _tooltip = null;
    161         private Text _tooltipItem = null;
     161        private static Text _tooltipItem = null;
     162        private static Item _tooltipOwner = null;
    162163
    163164        public static void DuplicateItem(Item source, Item dest) {
     
    11291130        public void setTooltip(String tooltip) {
    11301131                _tooltip = tooltip;
    1131                 _tooltipItem = null;
    11321132        }
    11331133       
     
    11361136        }
    11371137       
     1138        public static void clearTooltipOwner() {
     1139                _tooltipOwner = null;
     1140        }
     1141       
    11381142        public void paintTooltip(Graphics2D g) {
    1139                 // don't try to show an empty tooltip
     1143                if(_tooltipOwner != this) {
     1144                        _tooltipItem = null;
     1145                        _tooltipOwner = this;
     1146                }
     1147                // generate tooltip item
    11401148                if(_tooltipItem == null) {
    11411149                        if(_tooltip != null && _tooltip.trim().length() != 0) {
    1142                                 _tooltipItem = (Text) getParentOrCurrentFrame().getStatsTextItem(_tooltip);
     1150                                _tooltipItem = (Text) getParentOrCurrentFrame().getTooltipTextItem(_tooltip);
    11431151                                _tooltipItem.setWidth(300);
    11441152                        } else {
  • trunk/src/org/expeditee/settings/UserSettings.java

    r655 r664  
    240240        };
    241241       
     242        private static final Text tooltipTemplate() {
     243                Text t = new Text("@StatsTemplate");
     244                t.setColor(Color.BLACK);
     245                t.setBackgroundColor(new Color(0.7F, 0.7F, 0.9F));
     246                // t.setFamily(Text.MONOSPACED_FONT);
     247                t.setSize(14);
     248                return t;
     249        }
     250        public static final GenericSetting<Text> TooltipTemplate = new GenericSetting<Text>(Text.class, "Template for tooltips", tooltipTemplate()) {
     251                @Override
     252                public boolean setSetting(Text text) {
     253                        _value = text.getTemplateForm();
     254                        return true;
     255                }
     256        };
     257       
    242258        /*
    243259         * Colorwheels
Note: See TracChangeset for help on using the changeset viewer.