Codechange: Remove direct access to _colour_gradient.

Access is now through GetColourGradient, which ensures parameters are in range.
This commit is contained in:
Peter Nelson
2023-12-24 22:51:55 +00:00
committed by Peter Nelson
parent 56cf89d189
commit 0463d4c198
23 changed files with 98 additions and 65 deletions

View File

@@ -37,7 +37,7 @@ public:
virtual void Draw(const Rect &full, const Rect &, bool, Colours bg_colour) const
{
if (this->masked) GfxFillRect(full, _colour_gradient[bg_colour][5], FILLRECT_CHECKER);
if (this->masked) GfxFillRect(full, GetColourGradient(bg_colour, 5), FILLRECT_CHECKER);
}
TextColour GetColour(bool sel) const
@@ -63,8 +63,8 @@ public:
void Draw(const Rect &full, const Rect &, bool, Colours bg_colour) const override
{
uint8_t c1 = _colour_gradient[bg_colour][3];
uint8_t c2 = _colour_gradient[bg_colour][7];
uint8_t c1 = GetColourGradient(bg_colour, 3);
uint8_t c2 = GetColourGradient(bg_colour, 7);
int mid = CenterBounds(full.top, full.bottom, 0);
GfxFillRect(full.left, mid - WidgetDimensions::scaled.bevel.bottom, full.right, mid - 1, c1);

View File

@@ -41,9 +41,9 @@ void DrawSliderWidget(Rect r, int min_value, int max_value, int value, const std
int wx1 = r.left + sw / 2;
int wx2 = r.right - sw / 2;
if (_current_text_dir == TD_RTL) std::swap(wx1, wx2);
const uint shadow = _colour_gradient[COLOUR_GREY][3];
const uint fill = _colour_gradient[COLOUR_GREY][6];
const uint light = _colour_gradient[COLOUR_GREY][7];
const uint shadow = GetColourGradient(COLOUR_GREY, 3);
const uint fill = GetColourGradient(COLOUR_GREY, 6);
const uint light = GetColourGradient(COLOUR_GREY, 7);
const std::vector<Point> wedge{ Point{wx1, r.bottom - ha}, Point{wx2, r.top + ha}, Point{wx2, r.bottom - ha} };
GfxFillPolygon(wedge, fill);
GfxDrawLine(wedge[0].x, wedge[0].y, wedge[2].x, wedge[2].y, light, t);