diff options
author | Vincent Robinson <robinsonvincent89@gmail.com> | 2021-02-02 11:55:13 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-02 20:55:13 +0100 |
commit | f227e40180b2035f33059749b14287478bab374a (patch) | |
tree | 1e5295c0044ca1ce92d725f946e7399b4ba9afc3 /src | |
parent | 9388c23e86e85e507c521b1ac01687f249fd1a0a (diff) | |
download | minetest-f227e40180b2035f33059749b14287478bab374a.tar.gz minetest-f227e40180b2035f33059749b14287478bab374a.tar.bz2 minetest-f227e40180b2035f33059749b14287478bab374a.zip |
Fix list spacing and size (again) (#10869)
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/guiFormSpecMenu.cpp | 38 | ||||
-rw-r--r-- | src/gui/guiInventoryList.cpp | 2 |
2 files changed, 18 insertions, 22 deletions
diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp index e4678bcd1..88ea77812 100644 --- a/src/gui/guiFormSpecMenu.cpp +++ b/src/gui/guiFormSpecMenu.cpp @@ -19,6 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include <cstdlib> +#include <cmath> #include <algorithm> #include <iterator> #include <limits> @@ -500,37 +501,34 @@ void GUIFormSpecMenu::parseList(parserData *data, const std::string &element) auto style = getDefaultStyleForElement("list", spec.fname); v2f32 slot_scale = style.getVector2f(StyleSpec::SIZE, v2f32(0, 0)); - v2s32 slot_size( - slot_scale.X <= 0 ? imgsize.X : slot_scale.X * imgsize.X, - slot_scale.Y <= 0 ? imgsize.Y : slot_scale.Y * imgsize.Y + v2f32 slot_size( + slot_scale.X <= 0 ? imgsize.X : std::max<f32>(slot_scale.X * imgsize.X, 1), + slot_scale.Y <= 0 ? imgsize.Y : std::max<f32>(slot_scale.Y * imgsize.Y, 1) ); v2f32 slot_spacing = style.getVector2f(StyleSpec::SPACING, v2f32(-1, -1)); - if (data->real_coordinates) { - slot_spacing.X = slot_spacing.X < 0 ? imgsize.X * 0.25f : - imgsize.X * slot_spacing.X; - slot_spacing.Y = slot_spacing.Y < 0 ? imgsize.Y * 0.25f : - imgsize.Y * slot_spacing.Y; + v2f32 default_spacing = data->real_coordinates ? + v2f32(imgsize.X * 0.25f, imgsize.Y * 0.25f) : + v2f32(spacing.X - imgsize.X, spacing.Y - imgsize.Y); - slot_spacing.X += slot_size.X; - slot_spacing.Y += slot_size.Y; - } else { - slot_spacing.X = slot_spacing.X < 0 ? spacing.X : - slot_spacing.X * spacing.X; - slot_spacing.Y = slot_spacing.Y < 0 ? spacing.Y : - slot_spacing.Y * spacing.Y; - } + slot_spacing.X = slot_spacing.X < 0 ? default_spacing.X : + imgsize.X * slot_spacing.X; + slot_spacing.Y = slot_spacing.Y < 0 ? default_spacing.Y : + imgsize.Y * slot_spacing.Y; + + slot_spacing += slot_size; v2s32 pos = data->real_coordinates ? getRealCoordinateBasePos(v_pos) : getElementBasePos(&v_pos); core::rect<s32> rect = core::rect<s32>(pos.X, pos.Y, - pos.X + (geom.X - 1) * slot_spacing.X + imgsize.X, - pos.Y + (geom.Y - 1) * slot_spacing.Y + imgsize.Y); + pos.X + (geom.X - 1) * slot_spacing.X + slot_size.X, + pos.Y + (geom.Y - 1) * slot_spacing.Y + slot_size.Y); GUIInventoryList *e = new GUIInventoryList(Environment, data->current_parent, - spec.fid, rect, m_invmgr, loc, listname, geom, start_i, slot_size, - slot_spacing, this, data->inventorylist_options, m_font); + spec.fid, rect, m_invmgr, loc, listname, geom, start_i, + v2s32(slot_size.X, slot_size.Y), slot_spacing, this, + data->inventorylist_options, m_font); e->setNotClipped(style.getBool(StyleSpec::NOCLIP, false)); diff --git a/src/gui/guiInventoryList.cpp b/src/gui/guiInventoryList.cpp index dfdb60448..183d72165 100644 --- a/src/gui/guiInventoryList.cpp +++ b/src/gui/guiInventoryList.cpp @@ -104,8 +104,6 @@ void GUIInventoryList::draw() && m_invmgr->getInventory(selected_item->inventoryloc) == inv && selected_item->listname == m_listname && selected_item->i == item_i; - core::rect<s32> clipped_rect(rect); - clipped_rect.clipAgainst(AbsoluteClippingRect); bool hovering = m_hovered_i == item_i; ItemRotationKind rotation_kind = selected ? IT_ROT_SELECTED : (hovering ? IT_ROT_HOVERED : IT_ROT_NONE); |