mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:37:36 +00:00
LibGUI: Minor cleanup in GScrollBar.
This commit is contained in:
parent
546946775b
commit
29f2a22d34
2 changed files with 37 additions and 36 deletions
|
@ -98,8 +98,10 @@ Rect DirectoryView::row_rect(int item_index) const
|
||||||
|
|
||||||
void DirectoryView::mousedown_event(GMouseEvent& event)
|
void DirectoryView::mousedown_event(GMouseEvent& event)
|
||||||
{
|
{
|
||||||
|
if (event.button() == GMouseButton::Left) {
|
||||||
for (int i = 0; i < item_count(); ++i) {
|
for (int i = 0; i < item_count(); ++i) {
|
||||||
if (row_rect(i).contains(event.position())) {
|
if (!row_rect(i).contains(event.position()))
|
||||||
|
continue;
|
||||||
auto& entry = this->entry(i);
|
auto& entry = this->entry(i);
|
||||||
if (entry.is_directory()) {
|
if (entry.is_directory()) {
|
||||||
FileSystemPath new_path(String::format("%s/%s", m_path.characters(), entry.name.characters()));
|
FileSystemPath new_path(String::format("%s/%s", m_path.characters(), entry.name.characters()));
|
||||||
|
|
|
@ -3,9 +3,42 @@
|
||||||
#include <SharedGraphics/GraphicsBitmap.h>
|
#include <SharedGraphics/GraphicsBitmap.h>
|
||||||
#include <SharedGraphics/Painter.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)
|
GScrollBar::GScrollBar(GWidget* parent)
|
||||||
: 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()
|
GScrollBar::~GScrollBar()
|
||||||
|
@ -88,42 +121,8 @@ Rect GScrollBar::scrubber_rect() const
|
||||||
return { 0, (int)y, button_size(), button_size() };
|
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&)
|
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 painter(*this);
|
||||||
|
|
||||||
painter.fill_rect(rect(), Color(164, 164, 164));
|
painter.fill_rect(rect(), Color(164, 164, 164));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue