mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 06:04:57 +00:00
LibGfx+Userland: Remove dependency on GUI::TabWidget from StylePainter
Move TabPosition into its own file, and using it into the global namespace the same way we do for Gfx::Orientation. This unbreaks the gn build, and out of tree builds.
This commit is contained in:
parent
702dd0ca55
commit
d8ab9ed87c
11 changed files with 38 additions and 24 deletions
|
@ -131,13 +131,13 @@ BrowserWindow::BrowserWindow(WebView::CookieJar& cookie_jar, Vector<URL> const&
|
|||
Browser::BookmarksBarWidget::the().set_visible(show_bookmarks_bar);
|
||||
|
||||
m_window_actions.on_vertical_tabs = [this](auto& action) {
|
||||
m_tab_widget->set_tab_position(action.is_checked() ? GUI::TabWidget::TabPosition::Left : GUI::TabWidget::TabPosition::Top);
|
||||
m_tab_widget->set_tab_position(action.is_checked() ? TabPosition::Left : TabPosition::Top);
|
||||
Config::write_bool("Browser"sv, "Preferences"sv, "VerticalTabs"sv, action.is_checked());
|
||||
};
|
||||
|
||||
bool vertical_tabs = Config::read_bool("Browser"sv, "Preferences"sv, "VerticalTabs"sv, false);
|
||||
m_window_actions.vertical_tabs_action().set_checked(vertical_tabs);
|
||||
m_tab_widget->set_tab_position(vertical_tabs ? GUI::TabWidget::TabPosition::Left : GUI::TabWidget::TabPosition::Top);
|
||||
m_tab_widget->set_tab_position(vertical_tabs ? TabPosition::Left : TabPosition::Top);
|
||||
|
||||
build_menus();
|
||||
|
||||
|
|
|
@ -244,7 +244,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
backtrace_label.set_fixed_height(16);
|
||||
|
||||
auto& backtrace_tab_widget = backtrace_tab.add<GUI::TabWidget>();
|
||||
backtrace_tab_widget.set_tab_position(GUI::TabWidget::TabPosition::Bottom);
|
||||
backtrace_tab_widget.set_tab_position(TabPosition::Bottom);
|
||||
|
||||
auto& cpu_registers_tab = tab_widget.add_tab<GUI::Widget>("CPU Registers"_string);
|
||||
cpu_registers_tab.set_layout<GUI::VerticalBoxLayout>(4);
|
||||
|
@ -254,7 +254,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
cpu_registers_label.set_fixed_height(16);
|
||||
|
||||
auto& cpu_registers_tab_widget = cpu_registers_tab.add<GUI::TabWidget>();
|
||||
cpu_registers_tab_widget.set_tab_position(GUI::TabWidget::TabPosition::Bottom);
|
||||
cpu_registers_tab_widget.set_tab_position(TabPosition::Bottom);
|
||||
|
||||
auto& environment_tab = tab_widget.add_tab<GUI::Widget>("Environment"_string);
|
||||
environment_tab.set_layout<GUI::VerticalBoxLayout>(4);
|
||||
|
|
|
@ -72,7 +72,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, Vector<NonnullR
|
|||
current_cell_label.set_enabled(false);
|
||||
|
||||
m_tab_widget = container.add<GUI::TabWidget>();
|
||||
m_tab_widget->set_tab_position(GUI::TabWidget::TabPosition::Bottom);
|
||||
m_tab_widget->set_tab_position(TabPosition::Bottom);
|
||||
|
||||
m_cell_value_editor = cell_value_editor;
|
||||
m_current_cell_label = current_cell_label;
|
||||
|
|
|
@ -76,7 +76,7 @@ DebugInfoWidget::DebugInfoWidget()
|
|||
auto& splitter = bottom_box.add<GUI::HorizontalSplitter>();
|
||||
m_backtrace_view = splitter.add<GUI::ListView>();
|
||||
auto& variables_tab_widget = splitter.add<GUI::TabWidget>();
|
||||
variables_tab_widget.set_tab_position(GUI::TabWidget::TabPosition::Bottom);
|
||||
variables_tab_widget.set_tab_position(TabPosition::Bottom);
|
||||
variables_tab_widget.add_widget(build_variables_tab());
|
||||
variables_tab_widget.add_widget(build_registers_tab());
|
||||
|
||||
|
|
|
@ -1371,7 +1371,7 @@ ErrorOr<void> HackStudioWidget::create_action_tab(GUI::Widget& parent)
|
|||
void HackStudioWidget::create_project_tab(GUI::Widget& parent)
|
||||
{
|
||||
m_project_tab = parent.add<GUI::TabWidget>();
|
||||
m_project_tab->set_tab_position(GUI::TabWidget::TabPosition::Bottom);
|
||||
m_project_tab->set_tab_position(TabPosition::Bottom);
|
||||
|
||||
auto& tree_view_container = m_project_tab->add_tab<GUI::Widget>("Files"_string);
|
||||
tree_view_container.set_layout<GUI::VerticalBoxLayout>(GUI::Margins {}, 2);
|
||||
|
|
|
@ -9,19 +9,13 @@
|
|||
|
||||
#include <LibGUI/Margins.h>
|
||||
#include <LibGUI/Widget.h>
|
||||
#include <LibGfx/TabPosition.h>
|
||||
|
||||
namespace GUI {
|
||||
|
||||
class TabWidget : public Widget {
|
||||
C_OBJECT(TabWidget)
|
||||
public:
|
||||
enum TabPosition {
|
||||
Top,
|
||||
Bottom,
|
||||
Left,
|
||||
Right,
|
||||
};
|
||||
|
||||
virtual ~TabWidget() override = default;
|
||||
|
||||
TabPosition tab_position() const { return m_tab_position; }
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
namespace Gfx {
|
||||
|
||||
void ClassicStylePainter::paint_tab_button(Painter& painter, IntRect const& rect, Palette const& palette, bool active, bool hovered, bool enabled, GUI::TabWidget::TabPosition position, bool in_active_window, bool accented)
|
||||
void ClassicStylePainter::paint_tab_button(Painter& painter, IntRect const& rect, Palette const& palette, bool active, bool hovered, bool enabled, TabPosition position, bool in_active_window, bool accented)
|
||||
{
|
||||
Color base_color = palette.button();
|
||||
Color highlight_color2 = palette.threed_highlight();
|
||||
|
@ -36,7 +36,7 @@ void ClassicStylePainter::paint_tab_button(Painter& painter, IntRect const& rect
|
|||
accent = accent.to_grayscale();
|
||||
|
||||
switch (position) {
|
||||
case GUI::TabWidget::TabPosition::Top:
|
||||
case TabPosition::Top:
|
||||
// Base
|
||||
painter.fill_rect({ 1, 1, rect.width() - 2, rect.height() - 1 }, base_color);
|
||||
|
||||
|
@ -58,7 +58,7 @@ void ClassicStylePainter::paint_tab_button(Painter& painter, IntRect const& rect
|
|||
painter.draw_line({ rect.width() - 2, 2 }, { rect.width() - 2, rect.height() - 1 }, shadow_color1);
|
||||
painter.set_pixel(rect.width() - 2, 1, shadow_color2);
|
||||
break;
|
||||
case GUI::TabWidget::TabPosition::Bottom:
|
||||
case TabPosition::Bottom:
|
||||
// Base
|
||||
painter.fill_rect({ 0, 0, rect.width() - 1, rect.height() }, base_color);
|
||||
|
||||
|
@ -79,7 +79,7 @@ void ClassicStylePainter::paint_tab_button(Painter& painter, IntRect const& rect
|
|||
painter.draw_line({ rect.width() - 2, 0 }, { rect.width() - 2, rect.height() - 3 }, shadow_color1);
|
||||
painter.set_pixel({ rect.width() - 2, rect.height() - 2 }, shadow_color2);
|
||||
break;
|
||||
case GUI::TabWidget::TabPosition::Left:
|
||||
case TabPosition::Left:
|
||||
// Base tab
|
||||
painter.fill_rect({ 1, 1, rect.width(), rect.height() - 1 }, base_color);
|
||||
painter.draw_line({ 2, 0 }, { rect.width(), 0 }, highlight_color2);
|
||||
|
@ -98,7 +98,7 @@ void ClassicStylePainter::paint_tab_button(Painter& painter, IntRect const& rect
|
|||
painter.set_pixel({ 1, 1 }, highlight_color2);
|
||||
painter.set_pixel({ 1, rect.height() - 2 }, shadow_color2);
|
||||
break;
|
||||
case GUI::TabWidget::TabPosition::Right:
|
||||
case TabPosition::Right:
|
||||
// Base tab
|
||||
painter.fill_rect({ 0, 1, rect.width() - 1, rect.height() - 1 }, base_color);
|
||||
painter.draw_line({ 0, 0 }, { rect.width() - 2, 0 }, highlight_color2);
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Gfx {
|
|||
class ClassicStylePainter : public BaseStylePainter {
|
||||
public:
|
||||
virtual void paint_button(Painter&, IntRect const&, Palette const&, ButtonStyle, bool pressed, bool hovered = false, bool checked = false, bool enabled = true, bool focused = false, bool default_button = false) override;
|
||||
virtual void paint_tab_button(Painter&, IntRect const&, Palette const&, bool active, bool hovered, bool enabled, GUI::TabWidget::TabPosition position, bool in_active_window, bool accented) override;
|
||||
virtual void paint_tab_button(Painter&, IntRect const&, Palette const&, bool active, bool hovered, bool enabled, TabPosition position, bool in_active_window, bool accented) override;
|
||||
virtual void paint_frame(Painter&, IntRect const&, Palette const&, FrameStyle, bool skip_vertical_lines = false) override;
|
||||
virtual void paint_window_frame(Painter&, IntRect const&, Palette const&) override;
|
||||
virtual void paint_progressbar(Painter&, IntRect const&, Palette const&, int min, int max, int value, StringView text, Orientation = Orientation::Horizontal) override;
|
||||
|
|
|
@ -18,7 +18,7 @@ BaseStylePainter& StylePainter::current()
|
|||
return style;
|
||||
}
|
||||
|
||||
void StylePainter::paint_tab_button(Painter& painter, IntRect const& rect, Palette const& palette, bool active, bool hovered, bool enabled, GUI::TabWidget::TabPosition position, bool in_active_window, bool accented)
|
||||
void StylePainter::paint_tab_button(Painter& painter, IntRect const& rect, Palette const& palette, bool active, bool hovered, bool enabled, TabPosition position, bool in_active_window, bool accented)
|
||||
{
|
||||
current().paint_tab_button(painter, rect, palette, active, hovered, enabled, position, in_active_window, accented);
|
||||
}
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Forward.h>
|
||||
#include <LibGUI/TabWidget.h>
|
||||
#include <LibGfx/Forward.h>
|
||||
#include <LibGfx/Orientation.h>
|
||||
#include <LibGfx/TabPosition.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
|
@ -38,7 +38,7 @@ public:
|
|||
virtual ~BaseStylePainter() = default;
|
||||
|
||||
virtual void paint_button(Painter&, IntRect const&, Palette const&, ButtonStyle, bool pressed, bool hovered = false, bool checked = false, bool enabled = true, bool focused = false, bool default_button = false) = 0;
|
||||
virtual void paint_tab_button(Painter&, IntRect const&, Palette const&, bool active, bool hovered, bool enabled, GUI::TabWidget::TabPosition position, bool in_active_window, bool accented) = 0;
|
||||
virtual void paint_tab_button(Painter&, IntRect const&, Palette const&, bool active, bool hovered, bool enabled, TabPosition position, bool in_active_window, bool accented) = 0;
|
||||
virtual void paint_frame(Painter&, IntRect const&, Palette const&, FrameStyle, bool skip_vertical_lines = false) = 0;
|
||||
virtual void paint_window_frame(Painter&, IntRect const&, Palette const&) = 0;
|
||||
virtual void paint_progressbar(Painter&, IntRect const&, Palette const&, int min, int max, int value, StringView text, Orientation = Orientation::Horizontal) = 0;
|
||||
|
@ -57,7 +57,7 @@ public:
|
|||
|
||||
// FIXME: These are here for API compatibility, we should probably remove them and move BaseStylePainter into here
|
||||
static void paint_button(Painter&, IntRect const&, Palette const&, ButtonStyle, bool pressed, bool hovered = false, bool checked = false, bool enabled = true, bool focused = false, bool default_button = false);
|
||||
static void paint_tab_button(Painter&, IntRect const&, Palette const&, bool active, bool hovered, bool enabled, GUI::TabWidget::TabPosition position, bool in_active_window, bool accented);
|
||||
static void paint_tab_button(Painter&, IntRect const&, Palette const&, bool active, bool hovered, bool enabled, TabPosition position, bool in_active_window, bool accented);
|
||||
static void paint_frame(Painter&, IntRect const&, Palette const&, FrameStyle, bool skip_vertical_lines = false);
|
||||
static void paint_window_frame(Painter&, IntRect const&, Palette const&);
|
||||
static void paint_progressbar(Painter&, IntRect const&, Palette const&, int min, int max, int value, StringView text, Orientation = Orientation::Horizontal);
|
||||
|
|
20
Userland/Libraries/LibGfx/TabPosition.h
Normal file
20
Userland/Libraries/LibGfx/TabPosition.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Andrew Kaster <akaster@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
enum TabPosition {
|
||||
Top,
|
||||
Bottom,
|
||||
Left,
|
||||
Right,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
using Gfx::TabPosition;
|
Loading…
Add table
Add a link
Reference in a new issue