mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Fix background[] pos-offset lower-right-corner being at least (1,1) (#13320)
IGUIElement has a MinSize for the RelativeRect, which is at least (1,1). This means a pos offset of (0,0) will cause a seemingly off-by-1 error at the lower right corner, and (0.1,0.1) for example will just not work on the lower right corner. Ergo, we can't use the AbsoluteRect for storing the pos offset.
This commit is contained in:
parent
d49d80a4a0
commit
ae7271b725
3 changed files with 19 additions and 10 deletions
|
@ -1101,17 +1101,18 @@ void GUIFormSpecMenu::parseBackground(parserData* data, const std::string &eleme
|
|||
258 + m_fields.size()
|
||||
);
|
||||
|
||||
core::rect<s32> rect;
|
||||
core::rect<s32> rect{};
|
||||
v2s32 autoclip_offset{};
|
||||
if (!clip) {
|
||||
// no auto_clip => position like normal image
|
||||
rect = core::rect<s32>(pos, pos + geom);
|
||||
} else {
|
||||
// it will be auto-clipped when drawing
|
||||
rect = core::rect<s32>(-pos, pos);
|
||||
// element will be auto-clipped when drawing
|
||||
autoclip_offset = pos;
|
||||
}
|
||||
|
||||
GUIBackgroundImage *e = new GUIBackgroundImage(Environment, data->background_parent.get(),
|
||||
spec.fid, rect, name, middle, m_tsrc, clip);
|
||||
spec.fid, rect, name, middle, m_tsrc, clip, autoclip_offset);
|
||||
|
||||
FATAL_ERROR_IF(!e, "Failed to create background formspec element");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue