Skip to content

Commit 680aaa1

Browse files
Hugues Rossrubenwardy
Hugues Ross
authored andcommittedJan 16, 2020
Make clipping of formspec elements more consistent (#9262)
1 parent cea4fd2 commit 680aaa1

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed
 

‎doc/lua_api.txt

+8
Original file line numberDiff line numberDiff line change
@@ -2563,6 +2563,9 @@ Some types may inherit styles from parent types.
25632563

25642564
### Valid Properties
25652565

2566+
* box
2567+
* noclip - boolean, set to true to allow the element to exceed formspec bounds.
2568+
* Default to false in formspec_version version 3 or higher
25662569
* button, button_exit, image_button, item_image_button
25672570
* alpha - boolean, whether to draw alpha in bgimg. Default true.
25682571
* bgcolor - color, sets button tint.
@@ -2586,6 +2589,11 @@ Some types may inherit styles from parent types.
25862589
* border - set to false to hide the textbox background and border. Default true.
25872590
* noclip - boolean, set to true to allow the element to exceed formspec bounds.
25882591
* textcolor - color. Default white.
2592+
* image
2593+
* noclip - boolean, set to true to allow the element to exceed formspec bounds.
2594+
* Default to false in formspec_version version 3 or higher
2595+
* item_image
2596+
* noclip - boolean, set to true to allow the element to exceed formspec bounds. Default to false.
25892597
* label, vertlabel
25902598
* noclip - boolean, set to true to allow the element to exceed formspec bounds.
25912599
* image_button (additional properties)

‎src/gui/guiFormSpecMenu.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,8 @@ void GUIFormSpecMenu::parseImage(parserData* data, const std::string &element)
744744
gui::IGUIImage *e = Environment->addImage(rect, this, spec.fid, 0, true);
745745
e->setImage(texture);
746746
e->setScaleImage(true);
747-
e->setNotClipped(true);
747+
auto style = getStyleForElement("image", spec.fname);
748+
e->setNotClipped(style.getBool(StyleSpec::NOCLIP, m_formspec_version < 3));
748749
m_fields.push_back(spec);
749750

750751
return;
@@ -776,7 +777,8 @@ void GUIFormSpecMenu::parseImage(parserData* data, const std::string &element)
776777
);
777778
gui::IGUIImage *e = Environment->addImage(texture, pos, true, this,
778779
spec.fid, 0);
779-
e->setNotClipped(true);
780+
auto style = getStyleForElement("image", spec.fname);
781+
e->setNotClipped(style.getBool(StyleSpec::NOCLIP, m_formspec_version < 3));
780782
m_fields.push_back(spec);
781783

782784
return;
@@ -824,6 +826,8 @@ void GUIFormSpecMenu::parseItemImage(parserData* data, const std::string &elemen
824826

825827
GUIItemImage *e = new GUIItemImage(Environment, this, spec.fid,
826828
core::rect<s32>(pos, pos + geom), name, m_font, m_client);
829+
auto style = getStyleForElement("item_image", spec.fname);
830+
e->setNotClipped(style.getBool(StyleSpec::NOCLIP, false));
827831
e->drop();
828832

829833
m_fields.push_back(spec);
@@ -2110,7 +2114,8 @@ void GUIFormSpecMenu::parseBox(parserData* data, const std::string &element)
21102114

21112115
GUIBox *e = new GUIBox(Environment, this, spec.fid, rect, tmp_color);
21122116

2113-
e->setNotClipped(true);
2117+
auto style = getStyleForElement("box", spec.fname);
2118+
e->setNotClipped(style.getBool(StyleSpec::NOCLIP, m_formspec_version < 3));
21142119

21152120
e->drop();
21162121

‎src/network/networkprotocol.h

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

0 commit comments

Comments
 (0)
Please sign in to comment.