mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 06:38:10 +00:00
LibGUI: Start working on a GScrollBar.
This widget is far from finished, but it's off to a good start. Also added a GResizeEvent and GWidget::resize_event() so that widgets can react to being resized.
This commit is contained in:
parent
4d5fe39494
commit
1f355f2a79
11 changed files with 231 additions and 5 deletions
|
@ -5,6 +5,7 @@
|
|||
#include <unistd.h>
|
||||
#include <SharedGraphics/GraphicsBitmap.h>
|
||||
#include <SharedGraphics/Painter.h>
|
||||
#include <LibGUI/GScrollBar.h>
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include "DirectoryView.h"
|
||||
|
||||
|
@ -14,12 +15,19 @@ DirectoryView::DirectoryView(GWidget* parent)
|
|||
m_directory_icon = GraphicsBitmap::load_from_file("/res/icons/folder16.rgb", { 16, 16 });
|
||||
m_file_icon = GraphicsBitmap::load_from_file("/res/icons/file16.rgb", { 16, 16 });
|
||||
m_symlink_icon = GraphicsBitmap::load_from_file("/res/icons/link16.rgb", { 16, 16 });
|
||||
|
||||
m_scrollbar = new GScrollBar(this);
|
||||
}
|
||||
|
||||
DirectoryView::~DirectoryView()
|
||||
{
|
||||
}
|
||||
|
||||
void DirectoryView::resize_event(GResizeEvent& event)
|
||||
{
|
||||
m_scrollbar->set_relative_rect(event.size().width() - 16, 0, 16, event.size().height());
|
||||
}
|
||||
|
||||
void DirectoryView::open(const String& path)
|
||||
{
|
||||
if (m_path == path)
|
||||
|
@ -55,6 +63,7 @@ void DirectoryView::reload()
|
|||
entries.append(move(entry));
|
||||
}
|
||||
closedir(dirp);
|
||||
m_scrollbar->set_range(0, item_count() - 1);
|
||||
}
|
||||
|
||||
const GraphicsBitmap& DirectoryView::icon_for(const Entry& entry) const
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include <AK/Function.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
class GScrollBar;
|
||||
|
||||
class DirectoryView final : public GWidget {
|
||||
public:
|
||||
DirectoryView(GWidget* parent);
|
||||
|
@ -19,6 +21,7 @@ public:
|
|||
|
||||
private:
|
||||
virtual void paint_event(GPaintEvent&) override;
|
||||
virtual void resize_event(GResizeEvent&) override;
|
||||
virtual void mousedown_event(GMouseEvent&) override;
|
||||
|
||||
Rect row_rect(int item_index) const;
|
||||
|
@ -47,4 +50,6 @@ private:
|
|||
RetainPtr<GraphicsBitmap> m_directory_icon;
|
||||
RetainPtr<GraphicsBitmap> m_file_icon;
|
||||
RetainPtr<GraphicsBitmap> m_symlink_icon;
|
||||
|
||||
GScrollBar* m_scrollbar { nullptr };
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue