mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 16:37:47 +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
|
@ -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