mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Formspec: fix clamped scroll offset of scroll_containers larger than 1000px
This commit is contained in:
parent
882f132062
commit
309c0a0cb6
6 changed files with 11 additions and 10 deletions
|
@ -695,7 +695,9 @@ void GUIFormSpecMenu::parseScrollBar(parserData* data, const std::string &elemen
|
|||
e->setMax(max);
|
||||
e->setMin(min);
|
||||
|
||||
e->setPos(stoi(value));
|
||||
// Preserve for min/max values defined by `scroll_container[]`.
|
||||
spec.aux_f32 = stoi(value); // scroll position
|
||||
e->setPos(spec.aux_f32);
|
||||
|
||||
e->setSmallStep(data->scrollbar_options.small_step);
|
||||
e->setLargeStep(data->scrollbar_options.large_step);
|
||||
|
@ -2198,7 +2200,6 @@ void GUIFormSpecMenu::parseItemImageButton(parserData* data, const std::string &
|
|||
|
||||
spec_btn.ftype = f_Button;
|
||||
rect += data->basepos-padding;
|
||||
spec_btn.rect = rect;
|
||||
m_fields.push_back(spec_btn);
|
||||
}
|
||||
|
||||
|
@ -3235,6 +3236,8 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
|
|||
for (const std::pair<FieldSpec, GUIScrollBar *> &b : m_scrollbars) {
|
||||
if (c.first == b.first.fname) {
|
||||
c.second->setScrollBar(b.second);
|
||||
b.second->setPos(b.first.aux_f32); // scroll position
|
||||
c.second->updateScrolling();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,9 +129,9 @@ class GUIFormSpecMenu : public GUIModalMenu
|
|||
bool is_exit;
|
||||
// Draw priority for formspec version < 3
|
||||
int priority;
|
||||
core::rect<s32> rect;
|
||||
gui::ECURSOR_ICON fcursor_icon;
|
||||
std::string sound;
|
||||
f32 aux_f32 = 0;
|
||||
};
|
||||
|
||||
struct TooltipSpec
|
||||
|
|
|
@ -249,7 +249,7 @@ void GUIScrollBar::updatePos()
|
|||
setPosRaw(scroll_pos);
|
||||
}
|
||||
|
||||
void GUIScrollBar::setPosRaw(const s32 &pos)
|
||||
void GUIScrollBar::setPosRaw(const s32 pos)
|
||||
{
|
||||
s32 thumb_area = 0;
|
||||
s32 thumb_min = 0;
|
||||
|
@ -275,7 +275,7 @@ void GUIScrollBar::setPosRaw(const s32 &pos)
|
|||
border_size;
|
||||
}
|
||||
|
||||
void GUIScrollBar::setPos(const s32 &pos)
|
||||
void GUIScrollBar::setPos(const s32 pos)
|
||||
{
|
||||
setPosRaw(pos);
|
||||
target_pos = std::nullopt;
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
void setLargeStep(const s32 &step);
|
||||
//! Sets a position immediately, aborting any ongoing interpolation.
|
||||
// setPos does not send EGET_SCROLL_BAR_CHANGED events for you.
|
||||
void setPos(const s32 &pos);
|
||||
void setPos(const s32 pos);
|
||||
//! The same as setPos, but it takes care of sending EGET_SCROLL_BAR_CHANGED events.
|
||||
void setPosAndSend(const s32 &pos);
|
||||
//! Sets a target position for interpolation.
|
||||
|
@ -94,7 +94,7 @@ private:
|
|||
|
||||
ISimpleTextureSource *m_tsrc;
|
||||
|
||||
void setPosRaw(const s32 &pos);
|
||||
void setPosRaw(const s32 pos);
|
||||
void updatePos();
|
||||
std::optional<s32> target_pos;
|
||||
u32 last_time_ms = 0;
|
||||
|
|
|
@ -92,8 +92,6 @@ void GUIScrollContainer::setScrollBar(GUIScrollBar *scrollbar)
|
|||
|
||||
m_scrollbar->setPageSize((total_content_px * scrollbar_px) / visible_content_px);
|
||||
}
|
||||
|
||||
updateScrolling();
|
||||
}
|
||||
|
||||
void GUIScrollContainer::updateScrolling()
|
||||
|
|
|
@ -29,6 +29,7 @@ public:
|
|||
}
|
||||
|
||||
void setScrollBar(GUIScrollBar *scrollbar);
|
||||
void updateScrolling();
|
||||
|
||||
private:
|
||||
enum OrientationEnum
|
||||
|
@ -43,5 +44,4 @@ private:
|
|||
f32 m_scrollfactor; //< scrollbar pos * scrollfactor = scroll offset in pixels
|
||||
std::optional<s32> m_content_padding_px; //< in pixels
|
||||
|
||||
void updateScrolling();
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue