mirror of
https://github.com/RGBCube/serenity
synced 2025-05-21 15:15:07 +00:00
LibGUI: Put all classes in the GUI namespace and remove the leading G
This took me a moment. Welcome to the new world of GUI::Widget! :^)
This commit is contained in:
parent
2d39da5405
commit
c5bd9d4ed1
337 changed files with 5400 additions and 4816 deletions
|
@ -27,17 +27,19 @@
|
|||
#include <LibGUI/GScrollBar.h>
|
||||
#include <LibGUI/GScrollableWidget.h>
|
||||
|
||||
GScrollableWidget::GScrollableWidget(GWidget* parent)
|
||||
: GFrame(parent)
|
||||
namespace GUI {
|
||||
|
||||
ScrollableWidget::ScrollableWidget(Widget* parent)
|
||||
: Frame(parent)
|
||||
{
|
||||
m_vertical_scrollbar = GScrollBar::construct(Orientation::Vertical, this);
|
||||
m_vertical_scrollbar = ScrollBar::construct(Orientation::Vertical, this);
|
||||
m_vertical_scrollbar->set_step(4);
|
||||
m_vertical_scrollbar->on_change = [this](int) {
|
||||
did_scroll();
|
||||
update();
|
||||
};
|
||||
|
||||
m_horizontal_scrollbar = GScrollBar::construct(Orientation::Horizontal, this);
|
||||
m_horizontal_scrollbar = ScrollBar::construct(Orientation::Horizontal, this);
|
||||
m_horizontal_scrollbar->set_step(4);
|
||||
m_horizontal_scrollbar->set_big_step(30);
|
||||
m_horizontal_scrollbar->on_change = [this](int) {
|
||||
|
@ -45,21 +47,21 @@ GScrollableWidget::GScrollableWidget(GWidget* parent)
|
|||
update();
|
||||
};
|
||||
|
||||
m_corner_widget = GWidget::construct(this);
|
||||
m_corner_widget = Widget::construct(this);
|
||||
m_corner_widget->set_fill_with_background_color(true);
|
||||
}
|
||||
|
||||
GScrollableWidget::~GScrollableWidget()
|
||||
ScrollableWidget::~ScrollableWidget()
|
||||
{
|
||||
}
|
||||
|
||||
void GScrollableWidget::mousewheel_event(GMouseEvent& event)
|
||||
void ScrollableWidget::mousewheel_event(MouseEvent& event)
|
||||
{
|
||||
// FIXME: The wheel delta multiplier should probably come from... somewhere?
|
||||
vertical_scrollbar().set_value(vertical_scrollbar().value() + event.wheel_delta() * 20);
|
||||
}
|
||||
|
||||
void GScrollableWidget::custom_layout()
|
||||
void ScrollableWidget::custom_layout()
|
||||
{
|
||||
auto inner_rect = frame_inner_rect_for_size(size());
|
||||
int height_wanted_by_horizontal_scrollbar = m_horizontal_scrollbar->is_visible() ? m_horizontal_scrollbar->preferred_size().height() : 0;
|
||||
|
@ -84,20 +86,20 @@ void GScrollableWidget::custom_layout()
|
|||
}
|
||||
}
|
||||
|
||||
void GScrollableWidget::resize_event(GResizeEvent& event)
|
||||
void ScrollableWidget::resize_event(ResizeEvent& event)
|
||||
{
|
||||
GFrame::resize_event(event);
|
||||
Frame::resize_event(event);
|
||||
update_scrollbar_ranges();
|
||||
}
|
||||
|
||||
Size GScrollableWidget::available_size() const
|
||||
Size ScrollableWidget::available_size() const
|
||||
{
|
||||
int available_width = frame_inner_rect().width() - m_size_occupied_by_fixed_elements.width() - width_occupied_by_vertical_scrollbar();
|
||||
int available_height = frame_inner_rect().height() - m_size_occupied_by_fixed_elements.height() - height_occupied_by_horizontal_scrollbar();
|
||||
return { available_width, available_height };
|
||||
}
|
||||
|
||||
void GScrollableWidget::update_scrollbar_ranges()
|
||||
void ScrollableWidget::update_scrollbar_ranges()
|
||||
{
|
||||
auto available_size = this->available_size();
|
||||
|
||||
|
@ -116,7 +118,7 @@ void GScrollableWidget::update_scrollbar_ranges()
|
|||
m_vertical_scrollbar->set_big_step(visible_content_rect().height() - m_vertical_scrollbar->step());
|
||||
}
|
||||
|
||||
void GScrollableWidget::set_content_size(const Size& size)
|
||||
void ScrollableWidget::set_content_size(const Size& size)
|
||||
{
|
||||
if (m_content_size == size)
|
||||
return;
|
||||
|
@ -124,7 +126,7 @@ void GScrollableWidget::set_content_size(const Size& size)
|
|||
update_scrollbar_ranges();
|
||||
}
|
||||
|
||||
void GScrollableWidget::set_size_occupied_by_fixed_elements(const Size& size)
|
||||
void ScrollableWidget::set_size_occupied_by_fixed_elements(const Size& size)
|
||||
{
|
||||
if (m_size_occupied_by_fixed_elements == size)
|
||||
return;
|
||||
|
@ -132,17 +134,17 @@ void GScrollableWidget::set_size_occupied_by_fixed_elements(const Size& size)
|
|||
update_scrollbar_ranges();
|
||||
}
|
||||
|
||||
int GScrollableWidget::height_occupied_by_horizontal_scrollbar() const
|
||||
int ScrollableWidget::height_occupied_by_horizontal_scrollbar() const
|
||||
{
|
||||
return m_horizontal_scrollbar->is_visible() ? m_horizontal_scrollbar->height() : 0;
|
||||
}
|
||||
|
||||
int GScrollableWidget::width_occupied_by_vertical_scrollbar() const
|
||||
int ScrollableWidget::width_occupied_by_vertical_scrollbar() const
|
||||
{
|
||||
return m_vertical_scrollbar->is_visible() ? m_vertical_scrollbar->width() : 0;
|
||||
}
|
||||
|
||||
Rect GScrollableWidget::visible_content_rect() const
|
||||
Rect ScrollableWidget::visible_content_rect() const
|
||||
{
|
||||
return {
|
||||
m_horizontal_scrollbar->value(),
|
||||
|
@ -152,14 +154,14 @@ Rect GScrollableWidget::visible_content_rect() const
|
|||
};
|
||||
}
|
||||
|
||||
void GScrollableWidget::scroll_into_view(const Rect& rect, Orientation orientation)
|
||||
void ScrollableWidget::scroll_into_view(const Rect& rect, Orientation orientation)
|
||||
{
|
||||
if (orientation == Orientation::Vertical)
|
||||
return scroll_into_view(rect, false, true);
|
||||
return scroll_into_view(rect, true, false);
|
||||
}
|
||||
|
||||
void GScrollableWidget::scroll_into_view(const Rect& rect, bool scroll_horizontally, bool scroll_vertically)
|
||||
void ScrollableWidget::scroll_into_view(const Rect& rect, bool scroll_horizontally, bool scroll_vertically)
|
||||
{
|
||||
auto visible_content_rect = this->visible_content_rect();
|
||||
if (visible_content_rect.contains(rect))
|
||||
|
@ -179,7 +181,7 @@ void GScrollableWidget::scroll_into_view(const Rect& rect, bool scroll_horizonta
|
|||
}
|
||||
}
|
||||
|
||||
void GScrollableWidget::set_scrollbars_enabled(bool scrollbars_enabled)
|
||||
void ScrollableWidget::set_scrollbars_enabled(bool scrollbars_enabled)
|
||||
{
|
||||
if (m_scrollbars_enabled == scrollbars_enabled)
|
||||
return;
|
||||
|
@ -189,17 +191,17 @@ void GScrollableWidget::set_scrollbars_enabled(bool scrollbars_enabled)
|
|||
m_corner_widget->set_visible(m_scrollbars_enabled);
|
||||
}
|
||||
|
||||
void GScrollableWidget::scroll_to_top()
|
||||
void ScrollableWidget::scroll_to_top()
|
||||
{
|
||||
scroll_into_view({ 0, 0, 1, 1 }, Orientation::Vertical);
|
||||
}
|
||||
|
||||
void GScrollableWidget::scroll_to_bottom()
|
||||
void ScrollableWidget::scroll_to_bottom()
|
||||
{
|
||||
scroll_into_view({ 0, content_height(), 1, 1 }, Orientation::Vertical);
|
||||
}
|
||||
|
||||
Rect GScrollableWidget::widget_inner_rect() const
|
||||
Rect ScrollableWidget::widget_inner_rect() const
|
||||
{
|
||||
auto rect = frame_inner_rect();
|
||||
rect.set_width(rect.width() - width_occupied_by_vertical_scrollbar());
|
||||
|
@ -207,7 +209,7 @@ Rect GScrollableWidget::widget_inner_rect() const
|
|||
return rect;
|
||||
}
|
||||
|
||||
Point GScrollableWidget::to_content_position(const Point& widget_position) const
|
||||
Point ScrollableWidget::to_content_position(const Point& widget_position) const
|
||||
{
|
||||
auto content_position = widget_position;
|
||||
content_position.move_by(horizontal_scrollbar().value(), vertical_scrollbar().value());
|
||||
|
@ -215,10 +217,12 @@ Point GScrollableWidget::to_content_position(const Point& widget_position) const
|
|||
return content_position;
|
||||
}
|
||||
|
||||
Point GScrollableWidget::to_widget_position(const Point& content_position) const
|
||||
Point ScrollableWidget::to_widget_position(const Point& content_position) const
|
||||
{
|
||||
auto widget_position = content_position;
|
||||
widget_position.move_by(-horizontal_scrollbar().value(), -vertical_scrollbar().value());
|
||||
widget_position.move_by(frame_thickness(), frame_thickness());
|
||||
return widget_position;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue