Changes between Initial Version and Version 1 of GUI_-_Properties


Ignore:
Timestamp:
Feb 23, 2008, 4:19:00 AM (16 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GUI_-_Properties

    v1 v1  
     1First of all, it's important that I explain what is concidered a '''property''' (or a '''setting''') and what is not. Properties are all values that can be defined in the XML files when creating GUIs. These properties can later on be manipulated from Javascript by typing the property after the name, such as:
     2
     3{{{
     4  myobject.color = newcolor;
     5}}}
     6
     7Now the important part is this, the above can be done with not just properties, there is for instance a way to fetch the parent by typing "myobject.parent" also. This is, however, not a setting and won't be listed below. It is taken care of solely when talking about the GUI's Javascript interface.
     8{{Template:TODO|Gee|Add link to javascript interface.}}
     9
     10The '''default''' values are used to save space. Know the '''defaults''', and know your '''styles'''' defaults, and you'll have a lot cleaner XML files.
     11
     12= Foundation Settings =
     13
     14The '''Foundation Settings''' are the premise of any object, they differ from '''Base Settings''' as they cannot be changed.
     15
     16== name ==
     17 * default: "null"
     18 * value: [wiki:GUI_-_Data_Types#name name]
     19
     20Something to uniquely identify the object; no object should share the same name with another object.
     21
     22The name is case-sensitive and only regular characters should be used.
     23
     24Technically, the object name is optional; if a name is not specified, the object is given an internal name when declared. For example, an empty parent can be used to group children without specifying a name for the parent. If you want to do anything with an object, though (like toggle visibility of that group), it needs a name. Of course you can always manipulate the object by changing the settings of a super-object (ie the parent or its parent etc).
     25
     26== style ==
     27 * default: "default"
     28 * value: [wiki:GUI_-_Data_Types#name name]
     29
     30Specifies the name a "style" sheet that will be used to populate the control with any additional properties not specified at definition.
     31
     32If not specified, an object uses the values of the '''"default"''' style. (Current known values of the '''"default"''' style are specified in the "default:" properties in this control guide.)
     33
     34See [wiki:Styles] for more information.
     35
     36== type ==
     37 * default: "empty"
     38 * value: [wiki:GUI_-_Data_Types#name name]
     39
     40Specifies the type of object (for example, "button", "text", or "progressbar"). Different types unlock different types of extended settings (see below), and have different behaviours.
     41
     42The different type options are:
     43
     44= Base Settings =
     45
     46Settings shared between all types of object.
     47
     48== absolute ==
     49 * default: "false"
     50 * value: [wiki:GUI_-_Data_Types#bool bool] "(true|false)"
     51
     52If set to '''false''', the child's position, size and "height" (z) is relative to its parent's coordinates; they are calculated as delta values added to its parent's values ("0 0 100% 100%" would set it to the dimensions of its parent, and it could not exceed that border).
     53
     54This is handy when you want to link the position of an object(s) to another object. For example, a group of buttons could then be shifted in position by a few pixels without having to separately update each control's size value.
     55
     56If '''true''' (or left as default), the child's size is absolute (its size is relative to the screen resolution).
     57
     58When an object uses a scrollbar, all children are required to have absolute set to false, or they will not scroll within the parent window area.
     59
     60== enabled ==
     61 * default: "true"
     62 * value: [wiki:GUI_-_Data_Types#bool bool] "(true|false)"
     63
     64If set to "false", the object is disabled. It cannot be pressed by the user, and it uses the "_disabled" versions of its sprites. (Use for a control that is visible but temporarily unavailable. For example, a greyed-out checkbox, or a "train swordsman" icon when the player doesn't have enough resources to train the unit.)
     65
     66== ghost ==
     67 * default: "false"
     68 * value: [wiki:GUI_-_Data_Types#bool bool] "(true|false)"
     69
     70An object with ghost set to "true" does not acknowledge user input; it becomes purely cosmetic. Attempting to click it would only affect any object underneath it. (Useful for a non-interactive number drawn over an interactive button, for example).
     71
     72== hidden ==
     73 * default: "false"
     74 * value: [wiki:GUI_-_Data_Types#bool bool] "(true|false)"
     75
     76If '''false''', the object is visible. If '''hidden''', the object is invisible and cannot be pressed.
     77
     78If a parent is hidden, all of its children are also hidden. (Thus child controls can be grouped under a parent and toggled on or off by changing the "hidden" property of the parent.)
     79
     80== hotkey ==
     81 * default: "null"
     82 * value: [wiki:GUI_-_Data_Types#name name]
     83
     84Hotkey variables are declared in an appropriate .cfg file (such as binaries/config/system.cfg) by prefixing the variable with "hotkey."
     85
     86Object properties do not require the prefix, so if the .cfg variable is declared as ''hotkey.toggle.fps'', reference it using the object property ''hotkey="toggle.fps"''.
     87
     88When the player presses the key mapped to this hotkey, the "Press" event for an object with that hotkey property is triggered, as if the player had, say, clicked that button control.
     89
     90== parent ==
     91 * default: "null"
     92 * value: [wiki:GUI_-_Data_Types#name name]
     93
     94Used to return the name of the parent of this child object.
     95
     96== size ==
     97 * default: "0 0 100% 100%"
     98 * value: [wiki:GUI_-_Data_Types#client_area client area]
     99
     100The position and size of the object. To learn more about sizing, see [wiki:GUI_-_Data_Types#client_area client area].
     101
     102Unless an object with a greater-than-zero size has the "ghost" property, or the control is of the "empty" type, it will block interaction with the game world underneath this control.
     103
     104== z ==
     105 * default: .parent.z+10 (or "0" if the control has no parent)
     106 * value: [wiki:GUI_-_Data_Types#float float]
     107
     108An object's "Z value" specifies its drawing order. An object with a higher Z will be layered on top of an object with a lower Z.
     109
     110By default, all root (parentless) objects have a Z value of "0". Children will - if not manually set - have the value of its parent's Z plus 10.
     111
     112Since Z values are set automatically, this should only need to be specified in rare circumstances (such as when two siblings overlap each other). Generally just defining the objects in sequence should layer them in the right order.
     113
     114= Extended Settings =
     115
     116Settings that are only used by certain types of object.
     117
     118== buffer_zone ==
     119 * default: "5"
     120 * value: [wiki:GUI_-_Data_Types#float float]
     121
     122Specifies the distance in pixels between the text's bounding box and the edge of the control. The larger this value, the greater the size of the "border" between the text area and the edges of the sprite.
     123
     124== button_width ==
     125 * default: *
     126 * value: [wiki:GUI_-_Data_Types#float float]
     127{{Template:TODO|Gee|* Just add a default value to the default style and update this.}}
     128
     129Certain controls, such as the dropdown, have a small button that appears on the far right to open the dropdown list and select a new option.
     130
     131This value specifies the width of this button, so that the button does not have to be square (such as in a large dropdown with large texture images, where a slender button is preferred).
     132
     133Notice that even with the button, you can still press the whole control to open the dropdown area, not just this button.
     134
     135== caption ==
     136 * default: "null"
     137 * value: [wiki:GUI_-_Data_Types#string string]
     138
     139When a control needs to contain text, such as the label over a button or the field in an input box, it is stored in the object's caption property.
     140
     141The caption cannot actually be set as a caption="" property in the object's XML settings. Instead, it is stored as the value of the control object:
     142
     143{{{
     144  <object name="whatever" type="text">This is the caption</object>
     145}}}
     146
     147It is however called the caption when stored as a property of the object, and can be accessed as such through JS script:
     148
     149{{{
     150  whatever = getGUIObjectByName("whatever")
     151  whatever.caption = "Some other text"
     152}}}
     153
     154Captions are special strings that can accept a number of formatting tags. See the [wiki:GUI_-_Text_Renderer Text Renderer] sections for more information.
     155
     156== checked ==
     157 * default: "false"
     158 * value: [wiki:GUI_-_Data_Types#bool bool] "(true|false)"
     159
     160If set to "false", the control uses its "sprite*" properties to determine which artwork is displayed. (An empty box, for example.)
     161If set to "true", the control uses its "sprite2*" properties to determine which artwork is displayed. (A checked box, for example.)
     162
     163== cell_id ==
     164 * default: "null"
     165 * value: [wiki:GUI_-_Data_Types#string string]
     166
     167Used in conjunction with a sprite of cells to specify which element (in the range 0..n) of a multi-cell '''sprite=''' to display at this time.
     168
     169See the [wiki:cell_size] image property for more information about multi-cell sprites.
     170
     171== dropdown_buffer ==
     172 * default: *
     173 * value: [wiki:GUI_-_Data_Types#float float]
     174{{Template:TODO|Gee|* Just add a default value to the default style and update this.}}
     175
     176To make a [wiki:GUI_-_Drop-down Drop-down] look good, you will probably need sprites that are a bit larger than they should be, just like for [wiki:GUI_-_Input Input] controls. This will force the [wiki:GUI_-_Drop-down Drop-down] part to be placed with a little buffer below the main part.
     177
     178Check out the [wiki:GUI_-_Drop-down Drop-down] for an image of this.
     179
     180== dropdown_size ==
     181 * default: *
     182 * value: [wiki:GUI_-_Data_Types#float float]
     183{{Template:TODO|Gee|* Just add a default value to the default style and update this.}}
     184
     185In Windows, the size of a dropdown is specified as the perimeter of the whole control when opened, and then the height when closed is set to one row. This manually specifies this value, so the size of the dropdown is the size when closed.
     186
     187Check out the [wiki:GUI_-_Drop-down Drop-down] for an image of this.
     188
     189== font ==
     190 * default: "verdana12"
     191 * value: [wiki:GUI_-_Data_Types#name name]
     192
     193Specifies the name of the font used to display the control's text.
     194
     195Fonts are bitmap fonts generated from TrueType fonts with certain size and formatting options using the [wiki:Font_Builder Font Builder] tool.
     196
     197== fov_wedge_color ==
     198{{Template:TODO|Gee|I know this is for the Minimap control, but I can't see it ever being used in the code.}}
     199
     200== input_init_value_destroyed_at_focus ==
     201'''Not yet implemented.''' 
     202 * default: "false"
     203 * value: [wiki:GUI_-_Data_Types#bool bool] "(true|false)"
     204
     205Used by the input box. If set to true, the initial caption of the input box (eg "Insert Text Here") is removed the first time the control is clicked.
     206
     207== list ==
     208 * Default: ''empty of items''
     209 * Value: [wiki:GUI_-_Data_Types#list list]
     210
     211The list of strings in, for instance, the [wiki:GUI_-_List list] control.
     212
     213The Data Type ''list'' is a bit different as it can't be defined using a string. To understand more about it, see [wiki:GUI_-_Data_Types#list its documentation].
     214
     215== max_length ==
     216 * Default: *
     217 * Value: [wiki:GUI_-_Data_Types#int int]
     218{{Template:TODO|Gee|* Just add a default value to the default style and update this.}}
     219
     220Used by the [wiki:GUI_-_Input Input] control to specify the maximum number of characters the user is allowed to enter.
     221
     222== multiline ==
     223 * default: "false"
     224 * value: [wiki:GUI_-_Data_Types#bool bool] "(true|false)"
     225
     226Should the [wiki:GUI_-_Input Input] control word-wrap or scroll horizontally when reaching the right edge? True and it'll continue on the next row.
     227
     228== scrollbar ==
     229 * default: "false"
     230 * value: [wiki:GUI_-_Data_Types#bool bool] "(true|false)"
     231
     232If set to "true", the control displays its attached scrollbar at all times, not just when the length of its caption exceeds the size of the object.
     233'''Not yet implemented.''' As of now, there's no automatic detection that will make a scrollbar appear only when needed.
     234
     235== scrollbar_style ==
     236 * default: "sb2"
     237 * value: [wiki:GUI_-_Data_Types#name name]
     238
     239Specifies the type of scrollbar attached to this object. See the [wiki:GUI_-_Custom_Objects#scrollbar scrollbar] object for more information.
     240
     241An object uses the ''default'' scrollbar when ''scrollbar_style'' isn't specified.
     242
     243== selected ==
     244 * default: "-1"
     245 * value: [wiki:GUI_-_Data_Types#int int]
     246
     247''This value begins counting at 0, and -1 means nothing is selected.''
     248
     249Stores the value of which element in the control is currently selected. (For example, the current selection from a ''dropdown'' list, or the current row in a ''list'' box).
     250
     251== sprite ==
     252 * default: "null"
     253 * value: [wiki:GUI_-_Data_Types#name name]
     254
     255The object displays this texture container (or collage of textures) within its sprite boundaries. See [wiki:GUI_-_Sprites Sprites] for more information about declaring sprites.
     256
     257If you only wish to display a texture that stretches to fit the control's size, you can do this without defining the texture as a sprite in sprite1.xml using the syntax ''sprite="stretched:subfolder/texture.dds"'' (where subfolder/ is any subfolder under art/textures/ui/, and texture is the name of the texture. See [wiki:GUI_-_Sprites#Skip_a_step Skip a step] for more information.
     258
     259== sprite_background ==
     260 * default: "null"
     261 * value: [wiki:GUI_-_Data_Types#name name]
     262
     263Specifies the sprite to use as the background of the ''progressbar'' control.
     264
     265Also see the [wiki:GUI_-_Progress-bar Progress-bar].
     266
     267== sprite_bar ==
     268 * default: "null"
     269 * value: [wiki:GUI_-_Data_Types#name name]
     270
     271Specifies the sprite to use as the advancing bar of the ''progressbar'' control.
     272
     273Also see the [wiki:GUI_-_Progress-bar Progress-bar].
     274
     275== sprite_disabled ==
     276 * default: ''sprite''
     277 * value: [wiki:GUI_-_Data_Types#name name]
     278
     279This sprite is used when the primary sprite is disabled. (See the [wiki:GUI_-_Properties#enabled enabled] property for more information about this state).
     280
     281If no value is specified, it uses the value of the object's "sprite" property.
     282
     283== sprite_list ==
     284 * default: "null"
     285 * value: [wiki:GUI_-_Data_Types#name name]
     286
     287Background of the list in the [wiki:GUI_-_Drop-down Drop-down], go to its documentation for an image of this.
     288
     289== sprite_over ==
     290 * default: ''sprite''
     291 * value: [wiki:GUI_-_Data_Types#name name]
     292
     293This sprite is used when the user hovers the cursor over the primary sprite.
     294
     295If no value is specified, it uses the value of the object's "sprite" property.
     296
     297== sprite_pressed ==
     298 * default: ''sprite''
     299 * value: [wiki:GUI_-_Data_Types#name name]
     300
     301This sprite is used when the user clicks a button, it is only displayed while the mouse button is still down, and the cursor is hovering the object. If you're looking for a conventional button, this sprite should be an indented copy of ''sprite''.
     302
     303If no value is specified, it uses the value of the object's "sprite" property.
     304
     305== sprite_selectarea ==
     306 * default: "null"
     307 * value: [wiki:GUI_-_Data_Types#name name]
     308
     309The sprite to cover a selected area in several controls. For example text in an [wiki:GUI_-_Input input] control, or perhaps an element in a [wiki:GUI_-_List list] control (take a look at the image in the [wiki:GUI_-_List list's documentation]).
     310
     311== sprite2 ==
     312 * default: "null"
     313 * value: [wiki:GUI_-_Data_Types#name name]
     314
     315Used by controls that can be switched to another state or consist of more than one sprite. This specifies the "secondary sprite" used when the object is in its secondary mode.
     316
     317== sprite2_disabled ==
     318 * default: ''sprite2''
     319 * value: [wiki:GUI_-_Data_Types#name name]
     320
     321This sprite is used when the secondary sprite is disabled. (See the [wiki:GUI_-_Properties#enabled enabled] property for more information about this state).
     322
     323If no value is specified, it uses the value of the object's "sprite2" property.
     324
     325== sprite2_over ==
     326 * default: ''sprite2''
     327 * value: [wiki:GUI_-_Data_Types#name name]
     328
     329This sprite is used when the user hovers the cursor over the secondary sprite.
     330
     331If no value is specified, it uses the value of the object's "sprite2" property.
     332
     333== sprite2_pressed ==
     334 * default: ''sprite2''
     335 * value: [wiki:GUI_-_Data_Types#name name]
     336
     337This sprite is used when the user clicks the secondary sprite (ie the "Press" event is being fired).
     338
     339If no value is specified, it uses the value of the object's "sprite2" property.
     340
     341== square_side ==
     342 * default: "0"
     343 * value: [wiki:GUI_-_Data_Types#float float]
     344
     345[wiki:GUI_-_Check-box Check-boxes] and [wiki:GUI_-_Radio-button Radio-buttons] both have got square sized sprite to the side of the text showing a checked/unchecked state. This is not the sprite, but the side of the square. See [wiki:GUI_-_Check-box Check-box] for an image of this. If one would want a rectangle instead of a square, making a sprite that looks rectangular when fit into a square does the trick.
     346
     347== text_align ==
     348 * default: "left" ("center" for type "button")
     349 * value: [wiki:GUI_-_Data_Types#enum enum] "(left|center|right)"
     350'''Not yet implemented.''' The button does not have a special default on this value.
     351
     352Specifies horizontal alignment of caption text. (Left-aligned, right-aligned, or centered).
     353
     354== text_valign ==
     355 * default: "top" ("center" for types "button", "checkbox" and "radiobutton")
     356 * value: [wiki:GUI_-_Data_Types#enum enum] "(top|center|bottom)"
     357'''Not yet implemented.''' The button, checkbox and radiobutton does not have a special default on this value.
     358
     359Specifies vertical alignment of caption text. (top-aligned, bottom-aligned, or centered).
     360
     361== textcolor ==
     362 * default: "0 0 0"
     363 * value: [wiki:GUI_-_Data_Types#color color]
     364
     365Specifies the colour of caption's text (eg "255 255 255" for white text). See [wiki:GUI_-_Data_Types#color color] for more information about colour settings.
     366
     367== textcolor_disabled ==
     368 * default: ''textcolor''
     369 * value: [wiki:GUI_-_Data_Types#color color]
     370
     371Specifies the colour of caption's text when the object is disabled. (See the [wiki:GUI_-_Properties#enabled enabled] property for more information about this state).
     372
     373If no value is specified, it uses the value of the object's "textcolor" property.
     374
     375== textcolor_over ==
     376 * default: ''textcolor''
     377 * value: [wiki:GUI_-_Data_Types#color color]
     378
     379Specifies the colour of caption's text when the user hovers the cursor over the object.
     380
     381If no value is specified, it uses the value of the object's "textcolor" property.
     382
     383== textcolor_pressed ==
     384 * default: ''textcolor''
     385 * value: [wiki:GUI_-_Data_Types#color color]
     386
     387Specifies the colour of caption's text when the user clicks the object (ie the "Press" event is being fired).
     388
     389If no value is specified, it uses the value of the object's "textcolor" property.
     390
     391== textcolor_selected ==
     392 * default: ''textcolor''
     393 * value: [wiki:GUI_-_Data_Types#color color]
     394
     395Specifies the colour of caption's text when the input box is selected (the current focus; user's able to type text into it).
     396
     397If no value is specified, it uses the value of the object's "textcolor" property.
     398
     399== tooltip ==
     400 * default: "null"
     401 * value: [wiki:GUI_-_Data_Types#string string]
     402
     403Specifies the string of text to display in the tooltip object when this object is being "hovered" by the user. If empty, the string does not display a tooltip.
     404
     405See the [wiki:GUI_-_Custom_Objects#tooltip tooltip] object for more information.
     406
     407== tooltip_style ==
     408 * default: "default"
     409 * value: [wiki:GUI_-_Data_Types#string string]
     410
     411Specifies the name of the style of tooltip to display when this object is "hovered".
     412
     413If not specified, the object uses the tooltip called ''default''.
     414
     415See the [wiki:GUI_-_Custom_Objects#tooltip tooltip] object for more information.