Make clipping of formspec elements more consistent (#9262)

master
Hugues Ross 2020-01-16 13:41:07 -05:00 committed by rubenwardy
parent cea4fd2b27
commit 680aaa1bd5
3 changed files with 17 additions and 3 deletions

View File

@ -2563,6 +2563,9 @@ Some types may inherit styles from parent types.
### Valid Properties
* box
* noclip - boolean, set to true to allow the element to exceed formspec bounds.
* Default to false in formspec_version version 3 or higher
* button, button_exit, image_button, item_image_button
* alpha - boolean, whether to draw alpha in bgimg. Default true.
* bgcolor - color, sets button tint.
@ -2586,6 +2589,11 @@ Some types may inherit styles from parent types.
* border - set to false to hide the textbox background and border. Default true.
* noclip - boolean, set to true to allow the element to exceed formspec bounds.
* textcolor - color. Default white.
* image
* noclip - boolean, set to true to allow the element to exceed formspec bounds.
* Default to false in formspec_version version 3 or higher
* item_image
* noclip - boolean, set to true to allow the element to exceed formspec bounds. Default to false.
* label, vertlabel
* noclip - boolean, set to true to allow the element to exceed formspec bounds.
* image_button (additional properties)

View File

@ -744,7 +744,8 @@ void GUIFormSpecMenu::parseImage(parserData* data, const std::string &element)
gui::IGUIImage *e = Environment->addImage(rect, this, spec.fid, 0, true);
e->setImage(texture);
e->setScaleImage(true);
e->setNotClipped(true);
auto style = getStyleForElement("image", spec.fname);
e->setNotClipped(style.getBool(StyleSpec::NOCLIP, m_formspec_version < 3));
m_fields.push_back(spec);
return;
@ -776,7 +777,8 @@ void GUIFormSpecMenu::parseImage(parserData* data, const std::string &element)
);
gui::IGUIImage *e = Environment->addImage(texture, pos, true, this,
spec.fid, 0);
e->setNotClipped(true);
auto style = getStyleForElement("image", spec.fname);
e->setNotClipped(style.getBool(StyleSpec::NOCLIP, m_formspec_version < 3));
m_fields.push_back(spec);
return;
@ -824,6 +826,8 @@ void GUIFormSpecMenu::parseItemImage(parserData* data, const std::string &elemen
GUIItemImage *e = new GUIItemImage(Environment, this, spec.fid,
core::rect<s32>(pos, pos + geom), name, m_font, m_client);
auto style = getStyleForElement("item_image", spec.fname);
e->setNotClipped(style.getBool(StyleSpec::NOCLIP, false));
e->drop();
m_fields.push_back(spec);
@ -2110,7 +2114,8 @@ void GUIFormSpecMenu::parseBox(parserData* data, const std::string &element)
GUIBox *e = new GUIBox(Environment, this, spec.fid, rect, tmp_color);
e->setNotClipped(true);
auto style = getStyleForElement("box", spec.fname);
e->setNotClipped(style.getBool(StyleSpec::NOCLIP, m_formspec_version < 3));
e->drop();

View File

@ -232,6 +232,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
FORMSPEC VERSION 3:
Formspec elements are drawn in the order of definition
bgcolor[]: use 3 parameters (bgcolor, formspec (now an enum), fbgcolor)
box[] and image[] elements enable clipping by default
*/
#define FORMSPEC_API_VERSION 3