| 204 | public abstract float doLandscapeLayout(float screenWidth, float screenHeight); |
| 205 | } |
| 206 | private static class DefaultHeader extends Header { |
| 207 | protected static final float HEIGHT = Math.round(Utils.AVG_FINGER_HEIGHT * 0.8f); |
| 208 | protected static final FSkinFont FONT = FSkinFont.get(16); |
| 209 | |
| 210 | protected final FLabel btnBack, lblCaption; |
| 211 | |
| 212 | public DefaultHeader(String headerCaption) { |
| 213 | btnBack = add(new FLabel.Builder().icon(new BackIcon(HEIGHT, HEIGHT)).pressedColor(getBtnPressedColor()).align(Align.center).command(e -> Forge.back()).build()); |
| 214 | lblCaption = add(new FLabel.Builder().text(headerCaption).font(FONT).align(Align.center).build()); |
| 215 | } |
| 216 | |
| 217 | @Override |
| 218 | public float getPreferredHeight() { |
| 219 | return HEIGHT; |
| 220 | } |
| 221 | |
| 222 | @Override |
| 223 | public float doLandscapeLayout(float screenWidth, float screenHeight) { |
| 224 | return 0; //default header doesn't need to display for landscape mode |
| 225 | } |
| 226 | |
| 227 | @Override |
| 228 | public void drawBackground(Graphics g) { |
| 229 | g.fillRect(getBackColor(), 0, 0, getWidth(), getHeight()); |
| 230 | } |
| 231 | |
| 232 | @Override |
| 233 | public void drawOverlay(Graphics g) { |
| 234 | if (Forge.isLandscapeMode() && getWidth() < Forge.getCurrentScreen().getWidth()) { |
| 235 | //in landscape mode, draw left border for sidebar if needed |
| 236 | g.drawLine(LINE_THICKNESS, getLineColor(), 0, 0, 0, getHeight()); |
| 237 | return; |
| 238 | } |
| 239 | float y = HEIGHT - LINE_THICKNESS / 2; |
| 240 | g.drawLine(LINE_THICKNESS, getLineColor(), 0, y, getWidth(), y); |
| 241 | } |
| 242 | |
| 243 | @Override |
| 244 | protected void doLayout(float width, float height) { |
| 245 | btnBack.setBounds(0, 0, height, height); |
| 246 | lblCaption.setBounds(height, 0, width - 2 * height, height); |
| 247 | } |
| 248 | } |
| 249 | protected static class MenuHeader extends DefaultHeader { |
| 250 | private final FLabel btnMenu; |
| 251 | private final FPopupMenu menu; |