LGUI2:Templates

From Lavish Software Wiki
Jump to: navigation, search

A LavishGUI 2 Template is a JSON Object which provides values to use when not explicitly given (for example, default values). A Skin is then a collection of Templates which are activated together.

Defining a Template

Templates are defined as JSON Objects, usually within a Skin. Each JSON Object in the Skin's "templates" Object will become a Template with the given name, stored within the Skin.

The properties to provide within each Template depend entirely on how the Template is to be used. See the main Skin page for more information.

A "jsonTemplate" property may be provided to point to another Template, e.g. "jsonTemplate":"window.titleBar" would indicate that the template "window.titleBar" should be used for values not found in the current template.

Example

{
  "type": "skin",
  "name": "test skin",
  "templates": {
    "window.title": {
      "verticalAlignment": "center",
      "margin": [ 2, 0, 0, 0 ]
    },
    "window.titleBar": {
      "backgroundBrush": {
        "color": [ 0, 0, 1.0 ]
      }
    },
    "contextmenu": {
      "type": "contextmenu",
      "padding": [ 1, 1, 1, 1 ]
    },
    "contextmenuitem": {
      "type": "contextmenuitem",
      "padding": [ 2, 2, 2, 2 ],
      "margin": [ 1, 1, 1, 1 ],
      "styles": {
        "gotMouseOver": {
          "backgroundBrush": {
            "color": [ 0.0, 0.0, 0.3 ]
          },
          "font": {
            "bold": true
          },
          "color": [ 1.0,1.0,0]
        },
        "lostMouseOver": {
          "backgroundBrush": {
            "color": [ 0.0, 0.0, 0.0, 0.0 ]
          },
          "font": {
            "bold": false
          },
          "color": [ 1.0,1.0,1.0]
        }
      }
    }
  }
}  

LavishGUI 2 Topics