Changeset 59


Ignore:
Timestamp:
08/08/07 02:45:29 (6 years ago)
Author:
saua
Message:

implement choosing a smaller font if switching to three lines is not sufficient

File:
1 edited

Legend:

Unmodified
Added
Removed
  • bbtracker/trunk/src/org/bbtracker/mobile/gui/StatusTile.java

    r50 r59  
    88import org.bbtracker.UnitConverter; 
    99import org.bbtracker.Utils; 
     10import org.bbtracker.mobile.BBTracker; 
    1011import org.bbtracker.mobile.Preferences; 
    1112import org.bbtracker.mobile.TrackManager; 
     
    7071        protected void onResize() { 
    7172                twoLineLayout = fitsTwoLineLayout(width); 
     73                if (!twoLineLayout && width < ((MARGIN + latWidth) * 2 + MINIMAL_GAP)) { 
     74                        BBTracker.log("onResize: Setting Font size to small, because even three lines overlap!"); 
     75                        setFontSize(Font.SIZE_SMALL); 
     76                } 
    7277        } 
    7378 
    7479        protected boolean fitsTwoLineLayout(final int width) { 
    75                 final int twoLineWidth = (MARGIN + MINIMAL_GAP + latWidth) * 2 + lengthWidth; 
    76                 return width >= twoLineWidth; 
     80                return width >= (MARGIN + MINIMAL_GAP + latWidth) * 2 + lengthWidth; 
     81        } 
     82 
     83        protected boolean fitsThreeLineLayout(final int width) { 
     84                return width >= (MARGIN + latWidth) * 2 + MINIMAL_GAP; 
    7785        } 
    7886 
     
    167175 
    168176        public int getPreferredHeight(final int width) { 
    169                 final int lineCount = fitsTwoLineLayout(width) ? 2 : 3; 
     177                final int lineCount; 
     178                if (fitsTwoLineLayout(width)) { 
     179                        lineCount = 2; 
     180                } else { 
     181                        lineCount = 3; 
     182                        if (!fitsThreeLineLayout(width)) { 
     183                                BBTracker.log("getPreferredHeight: Setting Font size to small, because even three lines overlap!"); 
     184                                setFontSize(Font.SIZE_SMALL); 
     185                        } 
     186                } 
    170187                return MARGIN + font.getHeight() * lineCount + MARGIN; 
    171188        } 
Note: See TracChangeset for help on using the changeset viewer.