1
Fork 0
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:
Andreas Kling 2021-05-05 22:15:09 +02:00
parent 89f5f92b7e
commit 18d344609f
3 changed files with 111 additions and 0 deletions

View 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;
};
}