NAME
Image::ButtonMaker - Button generator.
SYNOPSIS
#Create Image::ButtonMaker object
$bmaker = Image::ButtonMaker->new();
# Add directory with some truetype fonts in it
$bmaker->add_font_dir('./happyfonts');
# Add directory with icons to be used inside buttons
$bmaker->add_image_dir('./happyfaces');
#This is where the output will go
$bmaker->set_target_dir('/httpd/happybuttons');
# Read the list of classes
$bmaker->read_classfile('happyclasses.pl');
# Read the list of buttons to be generated
$bmaker->read_buttonfile('buttonlist.pl');
# Generate buttons
$bmaker->generate;
DESCRIPTION
Image::ButtonMaker is a helper module for people who need to generate vast amounts of button images. The module supports dividing your buttons into classes, who inherit appearance from each other and overriding needed parameters on class level or on single button level.
Image::ButtonMaker was developed as a part of a large scale web application with multiple language support, themes and products.
Image::ButtonMaker requires Image::Magick with TrueType Font support to run.
MAIN PRINCIPLES
Each button has a set of different attributes, which determine the appearance of the button. The button can belong to a class which acts as a template for the button. The class can be a member of a class tree, where attributes are inherited from parent class to child class.
The class tree can be stored in one or multiple files. The Image::ButtonMaker object method read_classfile
will read those files and build the class tree.
With the class tree in place it is time for the button definition.
CLASS FILE SYNTAX
Class file contains a list of classes written in Perl syntax as a list of lists:
## Button class list
[
[
classname => 'basicbutton',
properties => {
FileType => 'png',
HeightMin => 17,
HeightMax => 17,
WidthMin => 90,
CanvasType => 'pixmap',
CanvasTemplateImg => 'rounded_button_template.png',
CanvasCutRight => 1,
CanvasCutLeft => 1,
CanvasCutTop => 1,
CanvasCutBottom => 1,
ArtWorkType => 'text',
ArtWorkHAlign => 'center',
ArtWorkVAlign => 'baseline',
TextColor => '#606060',
TextSize => 11,
TextFont => 'verdana.ttf',
TextAntiAlias => 'yes',
MarginLeft => 6,
MarginRight => 6,
MarginTop => 3,
MarginBottom => 4,
}
],
[
classname => 'basicbutton_with_arrow',
parent => 'basicbutton',
properties => {
ArtWorkType => 'icon+text',
ArtWorkHAlign => 'left',
IconName => 'smallarrow.gif',
IconSpace => 3,
IconVerticalAdjust => 0,
WidthMin => 100,
WidthMax => 100,
}
],
[
classname => 'errorbutton',
parent => 'basicbutton',
properties => {
TextColor => '#f00000',
}
],
]
Every class definition has two or three attributes:
classname
The name of the class. Should be something unique for every class.
parent (optional)
Specify the class to inherit from.
properties
A list of properties for the button. Properties can be inherited or defined for each class, depending on presence of a parent.
The properties will be passed to the Image::ButtonMaker::Button module and are listed in this modules man page.
BUTTON FILE SYNTAX
The button list file syntax is very similar to the class list syntax. A list of buttons is defined. Every button belongs to a class and has a list of properties that can override class defaults:
### Button list
[
[
name => 'submitForm',
classname => 'basicbutton',
properties => {
Text => 'Submit Data',
}
],
[
name => 'goBack',
classname => 'basicbutton_with_arrow',
properties => {
Text => 'Back to Main',
}
],
[
name => 'showAlert',
classname => 'errorbutton',
properties => {
Text => 'Important Info',
}
],
]
Each button definition has three attributes:
name
Button name. Will eventually become the name of the generated file (with suffix matching FileType attribute)
classname
Class that this button calls home.
properties
Hash of properties with name similar to properties in the class files and the attributes of the Image::ButtonMaker::Button package.
METHODS
new
The constructor. Returns the Image::ButtonMaker object.
read_classfile
Read the class file and add it to the class tree.
read_buttonfile
Read button list and add found buttons to the list of buttons to be generated with the
generate
method.clear_buttonlist
Empty the button list.
add_image_dir
Add a path to the list of paths, where the ButtonMaker looks for images.
get_image_dirs
Return list of paths.
add_font_dir
Add a path to the list of paths, where the ButtonMaker looks for fonts.
get_font_dirs
Return list of font paths.
set_target_dir
Set the directory for the ButtonMaker to use for output files.
get_target_dir
Return the directory for output paths.
get_lang_id
Get current language ID (for use with the undocumented Lexicon)
set_lang_id
Set current language ID (for use with the undocumented Lexicon)
generate
Generate buttons.
AUTHORS
Piotr Czarny <picz@sifira.dk> wrote this module and this crappy documentation.