Plugin:Clist modern/en/Skin development guide

From Miranda NG
Jump to navigation Jump to search

Common definitions

Skin engine is based on next definitions and concepts:

  • Object — component of skin. All skin objects are created during module loading. Objects describes what and how is need to paint as reply to Request.
  • Glyph — some image. Now time are supported BMP, JPG and PNG (with transparancy). Size of glyph is defined by image size. Glyph picture loads to memory only at first attempt to paint it and is kept in memory till module unloading or other skin loading.
  • Rule — rule which Object is correspond to Request
  • Request — request from module (this or other) to paint one of corresponding objects at specific place and size.

Work algorithm

Skin engine sequence is next:

  1. Module generate request string as soon as it needs to paint something and give it to skin engine.
  2. Skin engine try to find first rule that correspond to given request and select an object that pointed by this rule.
  3. If selected object is Solid type: The requested area is painted by corresponding color with specified alpha.
  4. If selected object is a Image: such image is transformed to requested region size and paints.

Rules and Request

Rule consists of:

  1. Number
  2. Name of object to point
  3. Couple of parameters delimited by ","

Each parameter is a union of:

  • Parameter’s name (first parameter has name "Module" and that always skipped).
  • Condition (= - "is equal", ^ - "is not equal")
  • Parameter value.

Request has the same part as rule except number.

The rule corresponds to the request if:

  1. Request contains all the rule's parameters. (also request can contain the parameter that is not mention in rule)
  2. All values of common parameters are the same if rule's parameters condition is "equal" and not the same if rules condition is "not equal". Rule parameter values can contain wildcards "*" and "?".

Rule parameter's names and values can contain up to 24 chars. Values can not contain "," (comma) all commas are replaced by "." (dots) Names and values are CASE SENSITIVE. First parameter name should be skipped when points.

Glyph transformation

Example: We need to paint glyph with sizes 70х70 at the rectangle size 100х100.

Define for margins: Left, Top, Right, Bottom. These margins divide glyph at 9 areas:

  1. 4 corners
  2. 4 edges
  3. center

Glyph transformation example (before transformation).png

Transformation rules:

  1. Corner areas of glyph are painted as-it-is at the destination corners without any resizing.
  2. Edge parts transforms in direction along their nearest edges and keeping perpendicular to edge size as is.
  3. Center area transforms in both directions

After transformation (StretchBoth mode)

Glyph transformation example (after transformation).png

There is 4 transformation modes:

  1. StretchBoth — stretch at both directions
  2. TileHorz — Tile horizontal, but stretch vertical
  3. TileVert — Tile vertical but stretch horizontal
  4. TileBoth — Tile at both directions

Skin definition

Skin is union of skin description file (*.msf) and folder with graphic resources. Folder name should be the same as the name of descriptor file (without extension). All files inside descriptor should be referenced without path.

Descriptor file is the common ini file with changed extension. All keys imports to DB during skin loading. File formats is next:

[db_section_name]
; comments
  Key=#Value
  Key2=#Value2

Here «#» is placeholder for one of key type data marks. They can be one of following

  1. «b» — BYTE
  2. «w» — WORD
  3. «d» — DWORD
  4. «s» — STRING

All modern skin objects and rules are kept in [ModernSkin] section with string type value. So in this section all keys have ‘s’ after ‘=’ e.g.:

$hotopengroup=sGlyph,Image,hotopengroup.png,StretchBoth,2,2,2,2,250
@0=s$window:Main,ID=Background

Spaces inside are not allowed (only for string parameters like …,Name=First Name,…).

Objects description

So skin consists from several parts. One of they describes Objects.

Objects are described in next way:

$object_name=sGlyph,object_type,parameters,…

object_name — object name used to point from rules object_type — one of types Image or Solid parameters,… — parameters.

for Solid type:

$object_name =sGlyph,Solid,RedValue,GreenValue,BlueValue,AlphaValue

for Image:

$object_name =sGlyph,Image,File_Name,Fit_Mode,Left,Top,Right,Bottom,AlphaValue

RedValue, GreenValue, BlueValue, AlphaValue — Red,Green,Blue and alpha transparency values. File_Name — glyph image file name. Fit_Mode — transform mode: StretchBoth, TileHorz, TileVert, TileBoth. Left, Top, Right, Bottom — transform margins.

Examples:

$window=sGlyph,Image,back.bmp,TileBoth,1,1,1,1,150
$closed_miranda_group=sGlyph,Solid,0,0,255,200