Skip to content

Commit

Permalink
LibGUI: Rename ScrollableWidget => AbstractScrollableWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed May 3, 2021
1 parent 6212579 commit d47f15a
Show file tree
Hide file tree
Showing 26 changed files with 95 additions and 94 deletions.
2 changes: 1 addition & 1 deletion Userland/Applications/Browser/Tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ void Tab::context_menu_requested(const Gfx::IntPoint& screen_position)
m_tab_context_menu->popup(screen_position);
}

GUI::ScrollableWidget& Tab::view()
GUI::AbstractScrollableWidget& Tab::view()
{
if (m_type == Type::InProcessWebView)
return *m_page_view;
Expand Down
2 changes: 1 addition & 1 deletion Userland/Applications/Browser/Tab.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Tab final : public GUI::Widget {
const String& title() const { return m_title; }
const Gfx::Bitmap* icon() const { return m_icon; }

GUI::ScrollableWidget& view();
GUI::AbstractScrollableWidget& view();

private:
explicit Tab(Type);
Expand Down
2 changes: 1 addition & 1 deletion Userland/Applications/FontEditor/GlyphMapWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void GlyphMapWidget::resize_event(GUI::ResizeEvent& event)
int content_height = rows() * (font().glyph_height() + m_vertical_spacing) + frame_thickness();
set_content_size({ content_width, content_height });

ScrollableWidget::resize_event(event);
AbstractScrollableWidget::resize_event(event);
}

void GlyphMapWidget::set_selected_glyph(int glyph)
Expand Down
4 changes: 2 additions & 2 deletions Userland/Applications/FontEditor/GlyphMapWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

#pragma once

#include <LibGUI/ScrollableWidget.h>
#include <LibGUI/AbstractScrollableWidget.h>
#include <LibGfx/BitmapFont.h>

class GlyphMapWidget final : public GUI::ScrollableWidget {
class GlyphMapWidget final : public GUI::AbstractScrollableWidget {
C_OBJECT(GlyphMapWidget)
public:
virtual ~GlyphMapWidget() override;
Expand Down
4 changes: 2 additions & 2 deletions Userland/Applications/HexEditor/HexEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
#include <AK/NonnullOwnPtrVector.h>
#include <AK/NonnullRefPtrVector.h>
#include <AK/StdLibExtras.h>
#include <LibGUI/ScrollableWidget.h>
#include <LibGUI/AbstractScrollableWidget.h>
#include <LibGfx/Font.h>
#include <LibGfx/TextAlignment.h>

class HexEditor : public GUI::ScrollableWidget {
class HexEditor : public GUI::AbstractScrollableWidget {
C_OBJECT(HexEditor)
public:
enum EditMode {
Expand Down
2 changes: 1 addition & 1 deletion Userland/Applications/Piano/RollWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ void RollWidget::mousewheel_event(GUI::MouseEvent& event)
}

if (!(event.modifiers() & KeyModifier::Mod_Ctrl)) {
GUI::ScrollableWidget::mousewheel_event(event);
GUI::AbstractScrollableWidget::mousewheel_event(event);
return;
}

Expand Down
4 changes: 2 additions & 2 deletions Userland/Applications/Piano/RollWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

#include "KeysWidget.h"
#include "Music.h"
#include <LibGUI/ScrollableWidget.h>
#include <LibGUI/AbstractScrollableWidget.h>

class TrackManager;

class RollWidget final : public GUI::ScrollableWidget {
class RollWidget final : public GUI::AbstractScrollableWidget {
C_OBJECT(RollWidget)
public:
virtual ~RollWidget() override;
Expand Down
2 changes: 1 addition & 1 deletion Userland/Applications/Spreadsheet/ConditionalFormatting.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "Forward.h"
#include <AK/String.h>
#include <LibGUI/ScrollableWidget.h>
#include <LibGUI/AbstractScrollableWidget.h>
#include <LibGfx/Color.h>

namespace Spreadsheet {
Expand Down
4 changes: 2 additions & 2 deletions Userland/DevTools/HackStudio/FormEditorWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
#pragma once

#include <AK/HashTable.h>
#include <LibGUI/ScrollableWidget.h>
#include <LibGUI/AbstractScrollableWidget.h>

namespace HackStudio {

class FormWidget;
class Tool;
class WidgetTreeModel;

class FormEditorWidget final : public GUI::ScrollableWidget {
class FormEditorWidget final : public GUI::AbstractScrollableWidget {
C_OBJECT(FormEditorWidget)
public:
virtual ~FormEditorWidget() override;
Expand Down
2 changes: 1 addition & 1 deletion Userland/DevTools/HackStudio/Git/DiffViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ void DiffViewer::update_content_size()

void DiffViewer::resize_event(GUI::ResizeEvent& event)
{
ScrollableWidget::resize_event(event);
AbstractScrollableWidget::resize_event(event);
update_content_size();
}

Expand Down
4 changes: 2 additions & 2 deletions Userland/DevTools/HackStudio/Git/DiffViewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
#include <AK/String.h>
#include <AK/Vector.h>
#include <LibDiff/Hunks.h>
#include <LibGUI/ScrollableWidget.h>
#include <LibGUI/AbstractScrollableWidget.h>

namespace HackStudio {
class DiffViewer final : public GUI::ScrollableWidget {
class DiffViewer final : public GUI::AbstractScrollableWidget {
C_OBJECT(DiffViewer)
public:
virtual ~DiffViewer() override;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <[email protected]>
* Copyright (c) 2018-2021, Andreas Kling <[email protected]>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
Expand All @@ -11,10 +11,11 @@

namespace GUI {

class ScrollableWidget : public Frame {
C_OBJECT(ScrollableWidget)
class AbstractScrollableWidget : public Frame {
C_OBJECT_ABSTRACT(AbstractScrollableWidget);

public:
virtual ~ScrollableWidget() override;
virtual ~AbstractScrollableWidget() override;

Gfx::IntSize content_size() const { return m_content_size; }
int content_width() const { return m_content_size.width(); }
Expand Down Expand Up @@ -63,7 +64,7 @@ class ScrollableWidget : public Frame {
Gfx::IntRect to_widget_rect(const Gfx::IntRect& content_rect) const { return { to_widget_position(content_rect.location()), content_rect.size() }; }

protected:
ScrollableWidget();
AbstractScrollableWidget();
virtual void custom_layout() override;
virtual void resize_event(ResizeEvent&) override;
virtual void mousewheel_event(MouseEvent&) override;
Expand All @@ -72,11 +73,11 @@ class ScrollableWidget : public Frame {
void set_size_occupied_by_fixed_elements(const Gfx::IntSize&);

private:
class ScrollableWidgetScrollbar final : public Scrollbar {
C_OBJECT(ScrollableWidgetScrollbar);
class AbstractScrollableWidgetScrollbar final : public Scrollbar {
C_OBJECT(AbstractScrollableWidgetScrollbar);

protected:
explicit ScrollableWidgetScrollbar(ScrollableWidget& owner, Gfx::Orientation orientation)
explicit AbstractScrollableWidgetScrollbar(AbstractScrollableWidget& owner, Gfx::Orientation orientation)
: Scrollbar(orientation)
, m_owner(owner)
{
Expand All @@ -88,15 +89,15 @@ class ScrollableWidget : public Frame {
}

private:
ScrollableWidget& m_owner;
AbstractScrollableWidget& m_owner;
};
friend class ScrollableWidgetScrollbar;

void update_scrollbar_ranges();
void handle_wheel_event(MouseEvent&, Widget&);

RefPtr<ScrollableWidgetScrollbar> m_vertical_scrollbar;
RefPtr<ScrollableWidgetScrollbar> m_horizontal_scrollbar;
RefPtr<AbstractScrollableWidgetScrollbar> m_vertical_scrollbar;
RefPtr<AbstractScrollableWidgetScrollbar> m_horizontal_scrollbar;
RefPtr<Widget> m_corner_widget;
Gfx::IntSize m_content_size;
Gfx::IntSize m_size_occupied_by_fixed_elements;
Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibGUI/AbstractTableView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ void AbstractTableView::scroll_into_view(const ModelIndex& index, bool scroll_ho
rect = row_rect(index.row());
break;
}
ScrollableWidget::scroll_into_view(rect, scroll_horizontally, scroll_vertically);
AbstractScrollableWidget::scroll_into_view(rect, scroll_horizontally, scroll_vertically);
}

void AbstractTableView::context_menu_event(ContextMenuEvent& event)
Expand Down
22 changes: 11 additions & 11 deletions Userland/Libraries/LibGUI/AbstractView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ NonnullRefPtr<Gfx::Font> AbstractView::font_for_index(const ModelIndex& index) c

void AbstractView::mousedown_event(MouseEvent& event)
{
ScrollableWidget::mousedown_event(event);
AbstractScrollableWidget::mousedown_event(event);

if (!model())
return;
Expand Down Expand Up @@ -254,36 +254,36 @@ void AbstractView::set_hovered_index(const ModelIndex& index)

void AbstractView::leave_event(Core::Event& event)
{
ScrollableWidget::leave_event(event);
AbstractScrollableWidget::leave_event(event);
set_hovered_index({});
}

void AbstractView::mousemove_event(MouseEvent& event)
{
if (!model())
return ScrollableWidget::mousemove_event(event);
return AbstractScrollableWidget::mousemove_event(event);

auto hovered_index = index_at_event_position(event.position());
set_hovered_index(hovered_index);

auto data_type = m_model->drag_data_type();
if (data_type.is_null())
return ScrollableWidget::mousemove_event(event);
return AbstractScrollableWidget::mousemove_event(event);

if (!m_might_drag)
return ScrollableWidget::mousemove_event(event);
return AbstractScrollableWidget::mousemove_event(event);

if (!(event.buttons() & MouseButton::Left) || m_selection.is_empty()) {
m_might_drag = false;
return ScrollableWidget::mousemove_event(event);
return AbstractScrollableWidget::mousemove_event(event);
}

auto diff = event.position() - m_left_mousedown_position;
auto distance_travelled_squared = diff.x() * diff.x() + diff.y() * diff.y();
constexpr int drag_distance_threshold = 5;

if (distance_travelled_squared <= drag_distance_threshold)
return ScrollableWidget::mousemove_event(event);
return AbstractScrollableWidget::mousemove_event(event);

VERIFY(!data_type.is_null());

Expand Down Expand Up @@ -317,7 +317,7 @@ void AbstractView::mousemove_event(MouseEvent& event)

void AbstractView::mouseup_event(MouseEvent& event)
{
ScrollableWidget::mouseup_event(event);
AbstractScrollableWidget::mouseup_event(event);

if (!model())
return;
Expand Down Expand Up @@ -481,7 +481,7 @@ void AbstractView::set_edit_triggers(unsigned triggers)
void AbstractView::hide_event(HideEvent& event)
{
stop_editing();
ScrollableWidget::hide_event(event);
AbstractScrollableWidget::hide_event(event);
}

void AbstractView::keydown_event(KeyEvent& event)
Expand Down Expand Up @@ -596,7 +596,7 @@ void AbstractView::keydown_event(KeyEvent& event)
}
}

ScrollableWidget::keydown_event(event);
AbstractScrollableWidget::keydown_event(event);
}

void AbstractView::cancel_searching()
Expand Down Expand Up @@ -706,7 +706,7 @@ void AbstractView::draw_item_text(Gfx::Painter& painter, const ModelIndex& index

void AbstractView::focusin_event(FocusEvent& event)
{
ScrollableWidget::focusin_event(event);
AbstractScrollableWidget::focusin_event(event);

if (model() && !cursor_index().is_valid()) {
move_cursor(CursorMovement::Home, SelectionUpdate::None);
Expand Down
4 changes: 2 additions & 2 deletions Userland/Libraries/LibGUI/AbstractView.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
#pragma once

#include <AK/Function.h>
#include <LibGUI/AbstractScrollableWidget.h>
#include <LibGUI/Model.h>
#include <LibGUI/ModelSelection.h>
#include <LibGUI/ScrollableWidget.h>
#include <LibGfx/TextElision.h>

namespace GUI {

class AbstractView
: public ScrollableWidget
: public AbstractScrollableWidget
, public ModelClient {

C_OBJECT_ABSTRACT(AbstractView);
Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibGUI/Forward.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ResizeCorner;
class ResizeEvent;
class ScreenRectChangeEvent;
class Scrollbar;
class ScrollableWidget;
class AbstractScrollableWidget;
class Slider;
class SortingProxyModel;
class SpinBox;
Expand Down
4 changes: 2 additions & 2 deletions Userland/Libraries/LibGUI/IconView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void IconView::scroll_into_view(const ModelIndex& index, bool scroll_horizontall
{
if (!index.is_valid())
return;
ScrollableWidget::scroll_into_view(item_rect(index.row()), scroll_horizontally, scroll_vertically);
AbstractScrollableWidget::scroll_into_view(item_rect(index.row()), scroll_horizontally, scroll_vertically);
}

void IconView::resize_event(ResizeEvent& event)
Expand Down Expand Up @@ -373,7 +373,7 @@ void IconView::scroll_out_of_view_timer_fired()
else if (m_out_of_view_position.x() < in_view_rect.left())
adjust_x = -(SCROLL_OUT_OF_VIEW_HOT_MARGIN / 2) + max(-SCROLL_OUT_OF_VIEW_HOT_MARGIN, m_out_of_view_position.x() - in_view_rect.left());

ScrollableWidget::scroll_into_view({ scroll_to.translated(adjust_x, adjust_y), { 1, 1 } }, true, true);
AbstractScrollableWidget::scroll_into_view({ scroll_to.translated(adjust_x, adjust_y), { 1, 1 } }, true, true);
update_rubber_banding(m_out_of_view_position);
}

Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibGUI/ListView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ void ListView::scroll_into_view(const ModelIndex& index, bool scroll_horizontall
{
if (!model())
return;
ScrollableWidget::scroll_into_view(content_rect(index.row()), scroll_horizontally, scroll_vertically);
AbstractScrollableWidget::scroll_into_view(content_rect(index.row()), scroll_horizontally, scroll_vertically);
}

}
Loading

0 comments on commit d47f15a

Please sign in to comment.