mirror of
https://github.com/minetest/minetest.git
synced 2024-11-30 03:23:45 +01:00
Add multiple element selection to style
and style_type
(#9380)
This commit is contained in:
parent
0c08f948d7
commit
7dffd08c1a
@ -2495,16 +2495,16 @@ Elements
|
|||||||
* `span=<value>`: number of following columns to affect
|
* `span=<value>`: number of following columns to affect
|
||||||
(default: infinite).
|
(default: infinite).
|
||||||
|
|
||||||
### `style[<name>;<prop1>;<prop2>;...]`
|
### `style[<name 1>,<name 2>,...;<prop1>;<prop2>;...]`
|
||||||
|
|
||||||
* Set the style for the named element `name`.
|
* Set the style for the named element(s) `name`.
|
||||||
* Note: this **must** be before the element is defined.
|
* Note: this **must** be before the element is defined.
|
||||||
* See [Styling Formspecs].
|
* See [Styling Formspecs].
|
||||||
|
|
||||||
|
|
||||||
### `style_type[<type>;<prop1>;<prop2>;...]`
|
### `style_type[<type 1>,<type 2>,...;<prop1>;<prop2>;...]`
|
||||||
|
|
||||||
* Sets the style for all elements of type `type` which appear after this element.
|
* Sets the style for all elements of type(s) `type` which appear after this element.
|
||||||
* See [Styling Formspecs].
|
* See [Styling Formspecs].
|
||||||
|
|
||||||
Migrating to Real Coordinates
|
Migrating to Real Coordinates
|
||||||
@ -2547,13 +2547,18 @@ Styling Formspecs
|
|||||||
|
|
||||||
Formspec elements can be themed using the style elements:
|
Formspec elements can be themed using the style elements:
|
||||||
|
|
||||||
style[<name>;<prop1>;<prop2>;...]
|
style[<name 1>,<name 2>,...;<prop1>;<prop2>;...]
|
||||||
style_type[<type>;<prop1>;<prop2>;...]
|
style_type[<type 1>,<type 2>,...;<prop1>;<prop2>;...]
|
||||||
|
|
||||||
Where a prop is:
|
Where a prop is:
|
||||||
|
|
||||||
property_name=property_value
|
property_name=property_value
|
||||||
|
|
||||||
|
A name/type can optionally be a comma separated list of names/types, like so:
|
||||||
|
|
||||||
|
world_delete,world_create,world_configure
|
||||||
|
button,image_button
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
style_type[button;bgcolor=#006699]
|
style_type[button;bgcolor=#006699]
|
||||||
|
@ -1,18 +1,9 @@
|
|||||||
local color = minetest.colorize
|
local color = minetest.colorize
|
||||||
|
|
||||||
local clip_fs = [[
|
local clip_fs = [[
|
||||||
style_type[label;noclip=%c]
|
style_type[label,button,image_button,item_image_button,
|
||||||
style_type[button;noclip=%c]
|
tabheader,scrollbar,table,animated_image
|
||||||
style_type[image_button;noclip=%c]
|
,field,textarea,checkbox,dropdown;noclip=%c]
|
||||||
style_type[item_image_button;noclip=%c]
|
|
||||||
style_type[tabheader;noclip=%c]
|
|
||||||
style_type[field;noclip=%c]
|
|
||||||
style_type[textarea;noclip=%c]
|
|
||||||
style_type[checkbox;noclip=%c]
|
|
||||||
style_type[dropdown;noclip=%c]
|
|
||||||
style_type[scrollbar;noclip=%c]
|
|
||||||
style_type[table;noclip=%c]
|
|
||||||
style_type[animated_image;noclip=%c]
|
|
||||||
|
|
||||||
label[0,0;A clipping test]
|
label[0,0;A clipping test]
|
||||||
button[0,1;3,0.8;x;A clipping test]
|
button[0,1;3,0.8;x;A clipping test]
|
||||||
|
@ -2450,13 +2450,6 @@ bool GUIFormSpecMenu::parseStyle(parserData *data, const std::string &element, b
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string selector = trim(parts[0]);
|
|
||||||
if (selector.empty()) {
|
|
||||||
errorstream << "Invalid style element (Selector required): '" << element
|
|
||||||
<< "'" << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
StyleSpec spec;
|
StyleSpec spec;
|
||||||
|
|
||||||
for (size_t i = 1; i < parts.size(); i++) {
|
for (size_t i = 1; i < parts.size(); i++) {
|
||||||
@ -2486,11 +2479,22 @@ bool GUIFormSpecMenu::parseStyle(parserData *data, const std::string &element, b
|
|||||||
spec.set(prop, value);
|
spec.set(prop, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> selectors = split(parts[0], ',');
|
||||||
|
for (size_t sel = 0; sel < selectors.size(); sel++) {
|
||||||
|
std::string selector = trim(selectors[sel]);
|
||||||
|
|
||||||
|
if (selector.empty()) {
|
||||||
|
errorstream << "Invalid style element (Empty selector): '" << element
|
||||||
|
<< "'" << std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (style_type) {
|
if (style_type) {
|
||||||
theme_by_type[selector] |= spec;
|
theme_by_type[selector] |= spec;
|
||||||
} else {
|
} else {
|
||||||
theme_by_name[selector] |= spec;
|
theme_by_name[selector] |= spec;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user