@@ -2188,12 +2188,12 @@ Elements
2188
2188
2189
2189
* 9-sliced background. See https://en.wikipedia.org/wiki/9-slice_scaling
2190
2190
* Middle is a rect which defines the middle of the 9-slice.
2191
- * `x` - The middle will be x pixels from all sides.
2192
- * `x,y` - The middle will be x pixels from the horizontal and y from the vertical.
2193
- * `x,y,x2,y2` - The middle will start at x,y, and end at x2, y2. Negative x2 and y2 values
2194
- will be added to the width and height of the texture, allowing it to be used as the
2195
- distance from the far end.
2196
- * All numbers in middle are integers.
2191
+ * `x` - The middle will be x pixels from all sides.
2192
+ * `x,y` - The middle will be x pixels from the horizontal and y from the vertical.
2193
+ * `x,y,x2,y2` - The middle will start at x,y, and end at x2, y2. Negative x2 and y2 values
2194
+ will be added to the width and height of the texture, allowing it to be used as the
2195
+ distance from the far end.
2196
+ * All numbers in middle are integers.
2197
2197
* Example for formspec 8x4 in 16x resolution:
2198
2198
image shall be sized 8 times 16px times 4 times 16px
2199
2199
* If `auto_clip` is `true`, the background is clipped to the formspec size
@@ -2508,16 +2508,28 @@ Elements
2508
2508
* `span=<value>`: number of following columns to affect
2509
2509
(default: infinite).
2510
2510
2511
- ### `style[<name 1>,<name 2>,... ;<prop1>;<prop2>;...]`
2511
+ ### `style[<selector 1>,<selector 2>;<prop1>;<prop2>;...]`
2512
2512
2513
- * Set the style for the named element(s) `name`.
2513
+ * Set the style for the element(s) matching `selector` by name.
2514
+ * `selector` can be one of:
2515
+ * `<name>` - An element name.
2516
+ * `<name>:<state>` - An element name, a colon, and one or more states.
2517
+ * `state` is a list of states separated by the `+` character.
2518
+ * If a state is provided, the style will only take effect when the element is in that state.
2519
+ * All provided states must be active for the style to apply.
2514
2520
* Note: this **must** be before the element is defined.
2515
2521
* See [Styling Formspecs].
2516
2522
2517
2523
2518
- ### `style_type[<type 1>,<type 2>,... ;<prop1>;<prop2>;...]`
2524
+ ### `style_type[<selector 1>,<selector 2>;<prop1>;<prop2>;...]`
2519
2525
2520
- * Sets the style for all elements of type(s) `type` which appear after this element.
2526
+ * Set the style for the element(s) matching `selector` by type.
2527
+ * `selector` can be one of:
2528
+ * `<type>` - An element type.
2529
+ * `<type>:<state>` - An element type, a colon, and one or more states.
2530
+ * `state` is a list of states separated by the `+` character.
2531
+ * If a state is provided, the style will only take effect when the element is in that state.
2532
+ * All provided states must be active for the style to apply.
2521
2533
* See [Styling Formspecs].
2522
2534
2523
2535
Migrating to Real Coordinates
@@ -2560,23 +2572,32 @@ Styling Formspecs
2560
2572
2561
2573
Formspec elements can be themed using the style elements:
2562
2574
2563
- style[<name 1>,<name 2>,...;<prop1>;<prop2>;...]
2564
- style_type[<type 1>,<type 2>,...;<prop1>;<prop2>;...]
2575
+ style[<name 1>,<name 2>;<prop1>;<prop2>;...]
2576
+ style[<name 1>:<state>,<name 2>:<state>;<prop1>;<prop2>;...]
2577
+ style_type[<type 1>,<type 2>;<prop1>;<prop2>;...]
2578
+ style_type[<type 1>:<state>,<type 2>:<state>;<prop1>;<prop2>;...]
2565
2579
2566
2580
Where a prop is:
2567
2581
2568
2582
property_name=property_value
2569
2583
2584
+ For example:
2585
+
2586
+ style_type[button;bgcolor=#006699]
2587
+ style[world_delete;bgcolor=red;textcolor=yellow]
2588
+ button[4,3.95;2.6,1;world_delete;Delete]
2589
+
2570
2590
A name/type can optionally be a comma separated list of names/types, like so:
2571
2591
2572
2592
world_delete,world_create,world_configure
2573
2593
button,image_button
2574
2594
2575
- For example :
2595
+ Any name/type in the list can also be accompanied by a `+`-separated list of states, like so :
2576
2596
2577
- style_type[button;bgcolor=#006699]
2578
- style[world_delete;bgcolor=red;textcolor=yellow]
2579
- button[4,3.95;2.6,1;world_delete;Delete]
2597
+ world_delete:hovered+pressed
2598
+ button:pressed
2599
+
2600
+ States allow you to apply styles in response to changes in the element, instead of applying at all times.
2580
2601
2581
2602
Setting a property to nothing will reset it to the default value. For example:
2582
2603
@@ -2654,6 +2675,14 @@ Some types may inherit styles from parent types.
2654
2675
* noclip - boolean, set to true to allow the element to exceed formspec bounds.
2655
2676
* textcolor - color. Default white.
2656
2677
2678
+ ### Valid States
2679
+
2680
+ * *all elements*
2681
+ * default - Equivalent to providing no states
2682
+ * button, button_exit, image_button, item_image_button
2683
+ * hovered - Active when the mouse is hovering over the element
2684
+ * pressed - Active when the button is pressed
2685
+
2657
2686
Markup Language
2658
2687
---------------
2659
2688
0 commit comments