#!/usr/bin/perl use warnings; use strict; use Tk; #create a new MainWindow my $mw = MainWindow->new( -background => 'black' ); #fullscreen $mw->geometry($mw->screenwidth.'x'.$mw->screenheight); #remove window chrome $mw->overrideredirect(1); #create a Tk::Frame to act as the top app bar hotspot. my $top_appbar = $mw->Frame( -background => $mw->cget(-background), -height => 10 )->pack( -side => 'top', -fill => 'x' ); $top_appbar->bind('' => sub { \&AppBar($top_appbar, 'show', 'top'); } ); $top_appbar->bind('' => sub { \&AppBar($top_appbar, 'hide', 'top'); } ); #create a Tk::Frame to act as the bottom app bar hotspot my $bottom_appbar = $mw->Frame( -background => $mw->cget(-background), -height => 10 )->pack( -side => 'bottom', -fill => 'x' ); $bottom_appbar->bind('' => sub { \&AppBar($bottom_appbar, 'show', 'bottom'); } ); $bottom_appbar->bind('' => sub { \&AppBar($bottom_appbar, 'hide', 'bottom'); } ); #create a Tk::Frame to hold the application's content my $content = $mw->Frame( -background => $mw->cget(-background), -height => $mw->screenheight-20 )->pack( -fill => 'x' ); $content->Label( -text => 'This is where the application content is displayed (buttons, images, etc...)', -background => $mw->cget(-background), -foreground => 'gray' )->pack(); sub AppBar { my $self = shift; my $method = shift; my $name = shift; if ($method eq 'show'){ #change the appbar's height and color to make it visable and useable $self->configure( -background => 'gray' ); $self->configure( -height => 50) if $name eq 'top'; if ( $name eq 'top' ){ $top_appbar->{label1} = $top_appbar->Label( -text => 'The navigation bar, or top app bar, is the recommended place to put navigation controls that let the user access other areas of the app (buttons).', -background => 'gray', -foreground => 'black' )->pack( -side => 'left' ); } elsif ( $name eq 'bottom' ){ $bottom_appbar->{label1} = $bottom_appbar->Label( -text => 'The bottom app bar is the recommended place to put commands (buttons).', -background => 'gray', -foreground => 'black' )->pack( -side => 'left' ); $self->configure( -height => 50); $mw->configure( -height => $mw->screenheight-60 ); } } elsif ($method eq 'hide'){ #change the appbar's height and color to make it hidden and not useable $self->configure( -background => $mw->cget(-background) ); $self->configure( -height => 10) if $name eq 'top'; if ( $name eq 'top'){ $top_appbar->{label1}->packForget(); } elsif ( $name eq 'bottom' ){ $bottom_appbar->{label1}->packForget(); $self->configure( -height => 10 ); $mw->configure( -height => $mw->screenheight-20 ); } } $mw->update(); } $mw->MainLoop();