Piotr Czarny > Image-ButtonMaker > Image::ButtonMaker

Download:
Image-ButtonMaker-0.1.4.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Report a bug
Module Version: 0.1.4   Source  

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:

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:

METHODS ^

AUTHORS ^

Piotr Czarny <picz@sifira.dk> wrote this module and this crappy documentation.

SEE ALSO ^

Image::ButtonMaker::Button, Image::ButtonMaker::Lexicon