MCPcopy Create free account
hub / github.com/Card-Forge/forge / MenuHeader

Class MenuHeader

forge-gui-mobile/src/forge/screens/FScreen.java:249–314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

247 }
248 }
249 protected static class MenuHeader extends DefaultHeader {
250 private final FLabel btnMenu;
251 private final FPopupMenu menu;
252
253 public MenuHeader(String headerCaption, FPopupMenu menu0) {
254 super(headerCaption);
255 menu = menu0;
256 btnMenu = add(new FLabel.Builder().icon(new MenuIcon(HEIGHT, HEIGHT)).pressedColor(getBtnPressedColor()).align(Align.center).command(new FEventHandler() {
257 @Override
258 public void handleEvent(FEvent e) {
259 menu.show(btnMenu, 0, HEIGHT);
260 }
261 }).build());
262 }
263
264 @Override
265 public void drawOverlay(Graphics g) {
266 if (Forge.isLandscapeMode() && displaySidebarForLandscapeMode()) {
267 //in landscape mode, draw left border for header
268 g.drawLine(LINE_THICKNESS, getLineColor(), 0, 0, 0, getHeight());
269 return;
270 }
271 super.drawOverlay(g);
272 }
273
274 @Override
275 protected void doLayout(float width, float height) {
276 super.doLayout(width, height);
277
278 menu.hide(); //ensure menu hidden when screen resized
279
280 if (Forge.isLandscapeMode() && displaySidebarForLandscapeMode()) {
281 //for landscape mode, hide menu button and display menu as sidebar
282 btnBack.setBounds(0, 0, 0, 0);
283 lblCaption.setBounds(0, 0, 0, 0);
284 btnMenu.setBounds(0, 0, 0, 0);
285 menu.show(getLeft(), 0, width, height);
286 return;
287 }
288
289 btnMenu.setBounds(width - height, 0, height, height);
290 }
291
292 @Override
293 protected void onScreenActivate() {
294 //ensure menu layout refreshed for sidebar when screen activated
295 if (Forge.isLandscapeMode() && displaySidebarForLandscapeMode()) {
296 menu.hide();
297 menu.show(getLeft(), 0, getWidth(), getHeight());
298 }
299 }
300
301 protected boolean displaySidebarForLandscapeMode() {
302 return true;
303 }
304
305 @Override
306 public float doLandscapeLayout(float screenWidth, float screenHeight) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected