Codechange: Assign/StoreSizePosition x/y can be negative. (#11416)

AssignSizePosition is used with negative values when an NWidgetMatrix is
scrolled, but they were passed as unsigned and then stored as signed.

Widget pos_x/pos_y were already made signed.
pull/615/head
Peter Nelson 8 months ago committed by GitHub
parent c97120f003
commit bb50cbb772
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -129,7 +129,7 @@ public:
this->smallest_x = this->head->smallest_x + this->tail->smallest_x; // First and last are always shown, rest not
}
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override
{
assert(given_width >= this->smallest_x && given_height >= this->smallest_y);

@ -1667,7 +1667,7 @@ public:
this->smallest_y = ComputeMaxSize(min_acs_height, this->smallest_y + this->resize_y - 1, this->resize_y);
}
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override
{
this->StoreSizePosition(sizing, x, y, given_width, given_height);

@ -1740,7 +1740,7 @@ public:
this->resize_y = std::min(display->resize_y, bar->resize_y);
}
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override
{
this->pos_x = x;
this->pos_y = y;

@ -1424,7 +1424,7 @@ public:
_toolbar_width = nbuttons * this->smallest_x;
}
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override
{
assert(given_width >= this->smallest_x && given_height >= this->smallest_y);

@ -1008,7 +1008,7 @@ NWidgetBase::NWidgetBase(WidgetType tp) : ZeroedMemoryAllocator()
*/
/**
* @fn void NWidgetBase::AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl)
* @fn void NWidgetBase::AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl)
* Assign size and position to the widget.
* @param sizing Type of resizing to perform.
* @param x Horizontal offset of the widget relative to the left edge of the window.
@ -1163,7 +1163,7 @@ bool NWidgetResizeBase::UpdateVerticalSize(uint min_y)
return true;
}
void NWidgetResizeBase::AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool)
void NWidgetResizeBase::AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool)
{
this->StoreSizePosition(sizing, x, y, given_width, given_height);
}
@ -1400,7 +1400,7 @@ void NWidgetStacked::SetupSmallestSize(Window *w, bool init_array)
}
}
void NWidgetStacked::AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl)
void NWidgetStacked::AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl)
{
assert(given_width >= this->smallest_x && given_height >= this->smallest_y);
this->StoreSizePosition(sizing, x, y, given_width, given_height);
@ -1570,7 +1570,7 @@ void NWidgetHorizontal::SetupSmallestSize(Window *w, bool init_array)
this->pip_pre = this->pip_inter = this->pip_post = 0;
}
void NWidgetHorizontal::AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl)
void NWidgetHorizontal::AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl)
{
assert(given_width >= this->smallest_x && given_height >= this->smallest_y);
@ -1678,7 +1678,7 @@ NWidgetHorizontalLTR::NWidgetHorizontalLTR(NWidContainerFlags flags) : NWidgetHo
this->type = NWID_HORIZONTAL_LTR;
}
void NWidgetHorizontalLTR::AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool)
void NWidgetHorizontalLTR::AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool)
{
NWidgetHorizontal::AssignSizePosition(sizing, x, y, given_width, given_height, false);
}
@ -1755,7 +1755,7 @@ void NWidgetVertical::SetupSmallestSize(Window *w, bool init_array)
this->pip_pre = this->pip_inter = this->pip_post = 0;
}
void NWidgetVertical::AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl)
void NWidgetVertical::AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl)
{
assert(given_width >= this->smallest_x && given_height >= this->smallest_y);
@ -1981,7 +1981,7 @@ void NWidgetMatrix::SetupSmallestSize(Window *w, bool init_array)
this->resize_y = resize.height;
}
void NWidgetMatrix::AssignSizePosition(SizingType, uint x, uint y, uint given_width, uint given_height, bool)
void NWidgetMatrix::AssignSizePosition(SizingType, int x, int y, uint given_width, uint given_height, bool)
{
assert(given_width >= this->smallest_x && given_height >= this->smallest_y);
@ -2249,7 +2249,7 @@ void NWidgetBackground::SetupSmallestSize(Window *w, bool init_array)
}
}
void NWidgetBackground::AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl)
void NWidgetBackground::AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl)
{
this->StoreSizePosition(sizing, x, y, given_width, given_height);

@ -127,7 +127,7 @@ public:
virtual void AdjustPaddingForZoom();
virtual void SetupSmallestSize(Window *w, bool init_array) = 0;
virtual void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) = 0;
virtual void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) = 0;
virtual void FillNestedArray(NWidgetBase **array, uint length) = 0;
@ -204,7 +204,7 @@ public:
RectPadding uz_padding; ///< Unscaled padding, for resize calculation.
protected:
inline void StoreSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height);
inline void StoreSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height);
};
/**
@ -233,7 +233,7 @@ inline uint NWidgetBase::GetVerticalStepSize(SizingType sizing) const
* @param given_width Width allocated to the widget.
* @param given_height Height allocated to the widget.
*/
inline void NWidgetBase::StoreSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height)
inline void NWidgetBase::StoreSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height)
{
this->pos_x = x;
this->pos_y = y;
@ -263,7 +263,7 @@ public:
bool UpdateVerticalSize(uint min_y);
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override;
void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override;
uint min_x; ///< Minimal horizontal size of only this widget.
uint min_y; ///< Minimal vertical size of only this widget.
@ -452,7 +452,7 @@ public:
void AdjustPaddingForZoom() override;
void SetupSmallestSize(Window *w, bool init_array) override;
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override;
void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override;
void FillNestedArray(NWidgetBase **array, uint length) override;
void Draw(const Window *w) override;
@ -503,7 +503,7 @@ public:
NWidgetHorizontal(NWidContainerFlags flags = NC_NONE);
void SetupSmallestSize(Window *w, bool init_array) override;
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override;
void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override;
};
/**
@ -514,7 +514,7 @@ class NWidgetHorizontalLTR : public NWidgetHorizontal {
public:
NWidgetHorizontalLTR(NWidContainerFlags flags = NC_NONE);
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override;
void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override;
};
/**
@ -526,7 +526,7 @@ public:
NWidgetVertical(NWidContainerFlags flags = NC_NONE);
void SetupSmallestSize(Window *w, bool init_array) override;
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override;
void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override;
};
/**
@ -548,7 +548,7 @@ public:
void SetScrollbar(Scrollbar *sb);
void SetupSmallestSize(Window *w, bool init_array) override;
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override;
void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override;
void FillNestedArray(NWidgetBase **array, uint length) override;
NWidgetCore *GetWidgetFromPos(int x, int y) override;
@ -599,7 +599,7 @@ public:
void AdjustPaddingForZoom() override;
void SetupSmallestSize(Window *w, bool init_array) override;
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override;
void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override;
void FillNestedArray(NWidgetBase **array, uint length) override;

Loading…
Cancel
Save