1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:17:45 +00:00

LibGUI: Minor cleanup in GScrollBar.

This commit is contained in:
Andreas Kling 2019-02-10 08:23:03 +01:00
parent 546946775b
commit 29f2a22d34
2 changed files with 37 additions and 36 deletions

View file

@ -3,9 +3,42 @@
#include <SharedGraphics/GraphicsBitmap.h>
#include <SharedGraphics/Painter.h>
static const char* s_up_arrow_bitmap_data = {
" "
" "
" ## "
" #### "
" ###### "
" ######## "
" ## "
" ## "
" ## "
" "
};
static const char* s_down_arrow_bitmap_data = {
" "
" ## "
" ## "
" ## "
" ######## "
" ###### "
" #### "
" ## "
" "
" "
};
static CharacterBitmap* s_up_arrow_bitmap;
static CharacterBitmap* s_down_arrow_bitmap;
GScrollBar::GScrollBar(GWidget* parent)
: GWidget(parent)
{
if (!s_up_arrow_bitmap)
s_up_arrow_bitmap = CharacterBitmap::create_from_ascii(s_up_arrow_bitmap_data, 10, 10).leak_ref();
if (!s_down_arrow_bitmap)
s_down_arrow_bitmap = CharacterBitmap::create_from_ascii(s_down_arrow_bitmap_data, 10, 10).leak_ref();
}
GScrollBar::~GScrollBar()
@ -88,42 +121,8 @@ Rect GScrollBar::scrubber_rect() const
return { 0, (int)y, button_size(), button_size() };
}
static const char* s_up_arrow_bitmap_data = {
" "
" "
" ## "
" #### "
" ###### "
" ######## "
" ## "
" ## "
" ## "
" "
};
static const char* s_down_arrow_bitmap_data = {
" "
" ## "
" ## "
" ## "
" ######## "
" ###### "
" #### "
" ## "
" "
" "
};
static CharacterBitmap* s_up_arrow_bitmap;
static CharacterBitmap* s_down_arrow_bitmap;
void GScrollBar::paint_event(GPaintEvent&)
{
if (!s_up_arrow_bitmap)
s_up_arrow_bitmap = CharacterBitmap::create_from_ascii(s_up_arrow_bitmap_data, 10, 10).leak_ref();
if (!s_down_arrow_bitmap)
s_down_arrow_bitmap = CharacterBitmap::create_from_ascii(s_down_arrow_bitmap_data, 10, 10).leak_ref();
Painter painter(*this);
painter.fill_rect(rect(), Color(164, 164, 164));