MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / WidgetHScrollbarDraw

Function WidgetHScrollbarDraw

src/openrct2-ui/interface/Widget.cpp:771–816  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

769 }
770
771 static void WidgetHScrollbarDraw(
772 RenderTarget& rt, const ScrollArea& scroll, int32_t l, int32_t t, int32_t r, int32_t b, ColourWithFlags colour)
773 {
774 colour.flags.set(ColourFlag::translucent, false);
775
776 // Trough
777 Rectangle::fill(rt, { { l + kScrollBarWidth, t }, { r - kScrollBarWidth, b } }, getColourMap(colour.colour).lighter);
778 Rectangle::fill(
779 rt, { { l + kScrollBarWidth, t }, { r - kScrollBarWidth, b } }, getColourMap(colour.colour).midDark, true);
780 Rectangle::fill(
781 rt, { { l + kScrollBarWidth, t + 2 }, { r - kScrollBarWidth, t + 2 } }, getColourMap(colour.colour).midDark);
782 Rectangle::fill(
783 rt, { { l + kScrollBarWidth, t + 3 }, { r - kScrollBarWidth, t + 3 } }, getColourMap(colour.colour).lighter);
784 Rectangle::fill(
785 rt, { { l + kScrollBarWidth, t + 7 }, { r - kScrollBarWidth, t + 7 } }, getColourMap(colour.colour).midDark);
786 Rectangle::fill(
787 rt, { { l + kScrollBarWidth, t + 8 }, { r - kScrollBarWidth, t + 8 } }, getColourMap(colour.colour).lighter);
788
789 // Left button
790 {
791 auto borderStyle = (scroll.flags & HSCROLLBAR_LEFT_PRESSED) ? Rectangle::BorderStyle::inset
792 : Rectangle::BorderStyle::outset;
793
794 Rectangle::fillInset(rt, { { l, t }, { l + (kScrollBarWidth - 1), b } }, colour, borderStyle);
795 drawText(rt, { l + 1, t }, kBlackLeftArrowString);
796 }
797
798 // Thumb
799 {
800 int16_t left = std::max(l + kScrollBarWidth, l + scroll.hThumbLeft - 1);
801 int16_t right = std::min(r - kScrollBarWidth, l + scroll.hThumbRight - 1);
802 auto borderStyle = (scroll.flags & HSCROLLBAR_THUMB_PRESSED) ? Rectangle::BorderStyle::inset
803 : Rectangle::BorderStyle::outset;
804
805 Rectangle::fillInset(rt, { { left, t }, { right, b } }, colour, borderStyle);
806 }
807
808 // Right button
809 {
810 auto borderStyle = (scroll.flags & HSCROLLBAR_RIGHT_PRESSED) ? Rectangle::BorderStyle::inset
811 : Rectangle::BorderStyle::outset;
812
813 Rectangle::fillInset(rt, { { r - (kScrollBarWidth - 1), t }, { r, b } }, colour, borderStyle);
814 drawText(rt, { r - 6, t }, kBlackRightArrowString);
815 }
816 }
817
818 static void WidgetVScrollbarDraw(
819 RenderTarget& rt, const ScrollArea& scroll, int32_t l, int32_t t, int32_t r, int32_t b, ColourWithFlags colour)

Callers 1

WidgetScrollDrawFunction · 0.85

Calls 5

fillFunction · 0.85
getColourMapFunction · 0.85
fillInsetFunction · 0.85
drawTextFunction · 0.85
setMethod · 0.65

Tested by

no test coverage detected