summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ivybanner154
1 files changed, 82 insertions, 72 deletions
diff --git a/ivybanner b/ivybanner
index 4539e94..05d695c 100644
--- a/ivybanner
+++ b/ivybanner
@@ -27,9 +27,8 @@ my $logdir = "/tmp";
my $logfile = "ivybanner-";
my $conffile = "/etc/ivybanner.conf";
-my $width = 1024;
-my $height = 768;
-my $smallsized = 0;
+my $base_width = 1024;
+my $base_height = 768;
my $coef = 1;
# the following variables can be overloaded in configuration file
@@ -38,11 +37,38 @@ my $default_domain;
my @ivyports = (2010, 3009, 3110, 3945);
my $default_port = 3110;
-# font spec
-my @fontspec24 = (-font =>
- '-b&h-lucida-bold-i-normal-sans-24-240-100-100-p-216-iso8859-1');
-my @fontspec17 = (-font =>
- '-adobe-helvetica-bold-r-normal--17-120-100-100-p-92-iso10646-1');
+my %SIZES = ( "small" => {
+ "width" => 640,
+ "height" => 480,
+ "fontspec_large" => '-b&h-lucida-bold-i-normal-sans-15-150-100-100-p-216-iso8859-1',
+ "fontspec_medium" => '-adobe-helvetica-medium-r-normal--11-80-100-100-p-60-iso10646-1',
+ "logo_x" => -120,
+ "logo_y" => -144,
+ "logo_small_x" => 225,
+ "logo_small_y" => -16,
+ },
+ "medium" => {
+ "width" => 800,
+ "height" => 600,
+ "fontspec_large" => '-b&h-lucida-bold-i-normal-sans-17-120-100-100-p-108-iso10646-1',
+ "fontspec_medium" => '-adobe-helvetica-medium-r-normal-*-12-120-75-75-p-67-iso10646-1',
+ "logo_x" => -40,
+ "logo_y" => -80,
+ "logo_small_x" => 290,
+ "logo_small_y" => 0,
+ },
+ "normal" => {
+ "width" => $base_width,
+ "height" => $base_height,
+ "fontspec_large" => '-b&h-lucida-bold-i-normal-sans-24-240-100-100-p-216-iso8859-1',
+ "fontspec_medium" => '-adobe-helvetica-bold-r-normal--17-120-100-100-p-92-iso10646-1',
+ "logo_x" => 0,
+ "logo_y" => 0,
+ "logo_small_x" => 390,
+ "logo_small_y" => 26,
+ },
+ );
+
# colors spec
my $darkbg = '#1E161B';
@@ -68,7 +94,7 @@ my $level = 1;
#------------------------
Getopt::Long::Configure('pass_through');
&usage unless Getopt::Long::GetOptions(\%opt, 'conf=s', 'testdir=s', '-dir=s',
- 'nocursor', 'help', 'override', 'smallsize' );
+ 'nocursor', 'help', 'override', 'size=s', 'smallsize' );
&usage if $opt{help};
if ($opt{conf}) {
@@ -101,18 +127,9 @@ if ($opt{testdir}) {
}
-if ($opt{smallsize})
-{
- $width = 640;
- $height = 480;
- $smallsized = 1;
- $coef = 0.620;
- @fontspec24 = (-font =>
- '-b&h-lucida-bold-i-normal-sans-15-150-100-100-p-216-iso8859-1');
- @fontspec17 = (-font =>
- '-adobe-helvetica-medium-r-normal--11-80-100-100-p-60-iso10646-1');
-}
-
+$opt{size} = "normal" if not $SIZES{$opt{size}};
+$opt{size} = "small" if $opt{smallsize};
+$coef = $SIZES{$opt{size}}->{width} / $base_width;
# test directories
#----------------------------
@@ -166,7 +183,7 @@ if ($opt{nocursor}) {
} else {
$mw->configure(-cursor => 'circle');
}
-$mw->geometry ($width."x".$height);
+$mw->geometry ($SIZES{$opt{size}}->{width}."x".$SIZES{$opt{size}}->{height});
$mw->title ('ivybanner');
$mw->client ('ivybanner');
@@ -184,7 +201,7 @@ $fm1 = $mw->Frame->pack(-expand => 1, -fill => 'both');
my @buttonattr = (-width => 8*$coef, -height => 3,
-borderwidth => 1,
- @fontspec24,
+ -font => $SIZES{$opt{size}}->{fontspec_large},
-relief => 'flat',
-highlightthickness => 3,
-highlightbackground => $hlbg,
@@ -195,15 +212,8 @@ my @buttonattr = (-width => 8*$coef, -height => 3,
-$fm1->Label(-image => $logo_bg)->place(-x => 0, -y => 0);
-
-if ($opt{smallsize}){
-
- $fm1->Label(-image => $logo_bg)->place(-x => -120, -y => -144);
-}else{
- $fm1->Label(-image => $logo_bg)->place(-x => 0, -y => 0);
-}
-
+ $fm1->Label(-image => $logo_bg)->place(-x => $SIZES{$opt{size}}->{logo_x},
+ -y => $SIZES{$opt{size}}->{logo_y});
$fm1->Button(-text => 'demos',
-command => [\&demosframe, 'demos', $demosdir],
@buttonattr)->place(-x => 800*$coef, -y => 100*$coef);
@@ -270,20 +280,15 @@ sub demosframe {
$fm2 = $mw->Frame(-background => $darkbg)->pack(-expand => 1, -fill => 'both');
my $lb_logo;
-
- $fm2->Frame(-background => $darkbg, -relief => 'groove', -borderwidth => 5,
- -width => $width+20*$coef, -height => 160*$coef)
- ->place(-x => -10*$coef, -y => -10*$coef);
-
- if ($opt{smallsize}){
- $lb_logo = $fm2->Label(-image => $logo_small,
- -borderwidth => 0)->place(-x => 225, -y => -16);
- }else{
- $lb_logo = $fm2->Label(-image => $logo_small,
- -borderwidth => 0)->place(-x => 390, -y => 26);
- }
-
+ $fm2->Frame(-background => $darkbg, -relief => 'groove', -borderwidth => 5,
+ -width => $SIZES{$opt{size}}->{width}+20*$coef, -height => 160*$coef)
+ ->place(-x => -10*$coef, -y => -10*$coef);
+
+ $lb_logo = $fm2->Label(-image => $logo_small,
+ -borderwidth => 0)->place(-x => $SIZES{$opt{size}}->{logo_small_x},
+ -y => $SIZES{$opt{size}}->{logo_small_y});
+
# Note that we use a decorative frame for each widget because frame size can be
# set in pixel unit whereas buttons family manages size in characters number
# (so, the size depends on used font)
@@ -312,13 +317,13 @@ sub demosframe {
-background => $bg,
-foreground => $fg);
my @cbuttonattr = (@labelattr,
- @fontspec17,
+ -font => $SIZES{$opt{size}}->{fontspec_medium},
-activeforeground => $fg,
-activebackground => $bg,
-selectcolor => $selcolor);
my @entryattr = (-width => 15*$coef,
-state => 'disable',
- @fontspec17,
+ -font => $SIZES{$opt{size}}->{fontspec_medium},
-background => $bg);
my $fm_localhost = $fm2->Frame(@frameattr)->place(-x => $x, -y => $y);
my $fm_default = $fm2->Frame(@frameattr)->place(-x => $x+$w+$dx, -y => $y);
@@ -393,14 +398,14 @@ sub demosframe {
$y = 680*$coef;
my @labelattr = (-width => 6, -height => 2,
-borderwidth => 1,
- @fontspec24,
+ -font => $SIZES{$opt{size}}->{fontspec_large},
-relief => 'flat',
-background => $darkbg,
-foreground => $fg);
my @buttonattr = (-width => 6, -height => 2,
-borderwidth => 1,
- @fontspec24,
+ -font => $SIZES{$opt{size}}->{fontspec_large},
-relief => 'flat',
-highlightthickness => 3*$coef*$coef,
-highlightbackground => $hlbg,
@@ -410,8 +415,8 @@ sub demosframe {
-foreground => $fg);
$fm2->Frame(-background => $darkbg, -relief => 'groove',
-borderwidth => 5*$coef,
- -width => $width+20*$coef,
- -height => $height)->place(-x => -10*$coef, -y => $y - 30*$coef);
+ -width => $SIZES{$opt{size}}->{width}+20*$coef,
+ -height => $SIZES{$opt{size}}->{height})->place(-x => -10*$coef, -y => $y - 30*$coef);
$fm2->Button(@buttonattr,
-text => "top",
-command => sub {
@@ -471,7 +476,7 @@ sub subdirframe {
# demos frame
#--------------------------------------------------
- my @bbox = (40*$coef, 160*$coef, $width-40*$coef, 640*$coef);
+ my @bbox = (40*$coef, 160*$coef, $SIZES{$opt{size}}->{width}-40*$coef, 640*$coef);
my $fmh = 90*$coef;
my $fmw = 180*$coef;
my $butw = 14*$coef;
@@ -487,7 +492,7 @@ sub subdirframe {
-background => $bg);
my @rbuttonattr = (-width => $butw, -height => 4*$coef,
-borderwidth => 1,
- @fontspec17,
+ -font => $SIZES{$opt{size}}->{fontspec_medium},
-relief => 'flat',
-highlightthickness => 0,
-background => $bg,
@@ -499,7 +504,7 @@ sub subdirframe {
);
my @buttonattr = (-width => $butw, -height => 4*$coef,
-borderwidth => 1,
- @fontspec17,
+ -font => $SIZES{$opt{size}}->{fontspec_medium},
-relief => 'flat',
-highlightthickness => 3*$coef*$coef,
-highlightbackground => $hlbg,
@@ -636,7 +641,7 @@ sub viewConfig {
-borderwidth => 2,
-highlightthickness => 3*$coef,
-highlightbackground => $hlbg,
- @fontspec17,
+ -font => $SIZES{$opt{size}}->{fontspec_medium},
-height => 28,
-width => 102,
-scrollbars => 'oe');
@@ -665,7 +670,7 @@ sub viewConfig {
my @labelattr = (-width => 40*$coef,
-height => 2,
-borderwidth => 1,
- @fontspec24,
+ -font => $SIZES{$opt{size}}->{fontspec_large},
-relief => 'flat',
-highlightthickness => 3*$coef,
-highlightbackground => $hlbg,
@@ -721,7 +726,7 @@ sub viewLog {
my @labelattr = (-width => 40*$coef,
-height => 2,
-borderwidth => 1,
- @fontspec24,
+ -font => $SIZES{$opt{size}}->{fontspec_large},
-relief => 'flat',
-highlightthickness => 3*$coef,
-highlightbackground => $hlbg,
@@ -800,7 +805,7 @@ sub selectappname {
-borderwidth => 0,
-highlightthickness => 0,
-height => 2,
- @fontspec24);
+ -font => $SIZES{$opt{size}}->{fontspec_large});
my @buttonattr = (-relief => 'flat',
-background => $bg,
-foreground => $fg,
@@ -810,8 +815,8 @@ sub selectappname {
-height => 2,
-activebackground => $bg,
-activeforeground => $fg,
- @fontspec24);
- my @cbuttonattr = (@buttonattr, @fontspec17);
+ -font => $SIZES{$opt{size}}->{fontspec_large});
+ my @cbuttonattr = (@buttonattr, -font => $SIZES{$opt{size}}->{fontspec_medium});
my $i = 0;
my $selapp = 'all';
for my $app (keys(%apps), 'all') {
@@ -843,8 +848,8 @@ sub selectappname {
# placement at window center
$tl->update;
my ($x, $y) = ($mw->rootx, $mw->rooty);
- $x += int($width/2 - $tl->width/2);
- $y += int($height/2 - $tl->height/2);
+ $x += int($SIZES{$opt{size}}->{width} / 2 - $tl->width/2);
+ $y += int($SIZES{$opt{size}}->{height} / 2 - $tl->height/2);
$tl->geometry('+'.$x.'+'.$y);
$tl->grab;
@@ -864,7 +869,7 @@ sub readlog {
-background => $bg,
-relief => 'sunken',
-foreground => $fg,
- @fontspec17,
+ -font => $SIZES{$opt{size}}->{fontspec_medium},
-height => 28,
-width => 102,
-borderwidth => 2,
@@ -923,7 +928,7 @@ sub readpartiallog {
-background => $bg,
-relief => 'sunken',
-foreground => $fg,
- @fontspec17,
+ -font => $SIZES{$opt{size}}->{fontspec_medium},
-height => 28,
-width => 102,
-borderwidth => 2,
@@ -1001,13 +1006,14 @@ sub usage {
print " [-dir fugueconfdir] [-testdir testsdir]\n";
print "\n";
print "Options :\n";
- print " -override option passed to ivylaunch. if true, global agents\n";
- print " which are already connected will be overriden\n";
- print " -nocursor hide mouse cursor\n";
- print " -conf <file> configuration file; default=/etc/ivybanner.conf\n";
- print " -dir <dir> fugue configs directory\n";
- print " -testdir <dir> tests directory\n";
- print " -smallsize display IvyBanner in 640x480 instead of 1024x768\n";
+ print " -override option passed to ivylaunch. if true, global agents\n";
+ print " which are already connected will be overriden\n";
+ print " -nocursor hide mouse cursor\n";
+ print " -conf <file> configuration file; default=/etc/ivybanner.conf\n";
+ print " -dir <dir> fugue configs directory\n";
+ print " -testdir <dir> tests directory\n";
+ print " -smallsize display IvyBanner in 640x480 instead of 1024x768 (deprecated)\n";
+ print " -size=[small|medium|normal] display IvyBanner in 640x480 (small), 800x600 (medium) or normal (1024x768)\n";
print "\n";
exit 0;
}
@@ -1057,7 +1063,11 @@ Infer ivylaunch behavior when a B<global> agent is detected on the bus. See ivyl
=item B<-smallsize>
-display IvyBanner in 640x480 instead of 1024x768.
+display IvyBanner in 640x480 instead of 1024x768 (deprecated)
+
+=item B<-size=[small|medium|normal]>
+
+display IvyBanner in 640x480 (small), 800x600 (medium) or normal (1024x768)
=back