mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:47:34 +00:00
LibGUI: Add ScrollableContainerWidget :^)
This widget provides a scrollable view onto another (child) widget. If the child is larger than the parent, scrollbars are provided for panning around the child.
This commit is contained in:
parent
89f5f92b7e
commit
18d344609f
3 changed files with 111 additions and 0 deletions
36
Userland/Libraries/LibGUI/ScrollableContainerWidget.h
Normal file
36
Userland/Libraries/LibGUI/ScrollableContainerWidget.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibGUI/AbstractScrollableWidget.h>
|
||||
|
||||
namespace GUI {
|
||||
|
||||
class ScrollableContainerWidget : public GUI::AbstractScrollableWidget {
|
||||
C_OBJECT(ScrollableContainerWidget);
|
||||
|
||||
public:
|
||||
virtual ~ScrollableContainerWidget();
|
||||
|
||||
void set_widget(GUI::Widget*);
|
||||
GUI::Widget* widget() { return m_widget; }
|
||||
GUI::Widget const* widget() const { return m_widget; }
|
||||
|
||||
protected:
|
||||
virtual void did_scroll() override;
|
||||
virtual void resize_event(GUI::ResizeEvent&) override;
|
||||
|
||||
private:
|
||||
void update_widget_size();
|
||||
void update_widget_position();
|
||||
|
||||
ScrollableContainerWidget();
|
||||
|
||||
RefPtr<GUI::Widget> m_widget;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue