diff options
author | thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> | 2023-04-29 16:47:52 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-04-30 05:49:46 +0200 |
commit | f7e034d4b257a22b898252d62652587601fa7f99 (patch) | |
tree | a69511f055f54e0215a63d6082637d38293e97f6 /Userland | |
parent | 4c9933bfb701c43a2f9aeadf8d06398fd6327749 (diff) | |
download | serenity-f7e034d4b257a22b898252d62652587601fa7f99.zip |
LibGfx+Userland: Merge FrameShape and FrameShadow into FrameStyle
Previously, Frames could set both these properties along with a
thickness to confusing effect: Most shapes of the same shadowing only
differentiated at a thickness >= 2, and some not at all. This led
to a lot of creative but ultimately superfluous choices in the code.
Instead let's streamline our options, automate thickness, and get
the right look without so much guesswork.
Plain shadowing has been consolidated into a single Plain style,
and 0 thickness can be had by setting style to NoFrame.
Diffstat (limited to 'Userland')
58 files changed, 149 insertions, 209 deletions
diff --git a/Userland/Applets/Audio/main.cpp b/Userland/Applets/Audio/main.cpp index 149a8cc29f..229b22ebd7 100644 --- a/Userland/Applets/Audio/main.cpp +++ b/Userland/Applets/Audio/main.cpp @@ -83,7 +83,7 @@ private: m_root_container = TRY(m_slider_window->set_main_widget<GUI::Frame>()); m_root_container->set_fill_with_background_color(true); m_root_container->set_layout<GUI::VerticalBoxLayout>(4, 0); - m_root_container->set_frame_shape(Gfx::FrameShape::Window); + m_root_container->set_frame_style(Gfx::FrameStyle::Window); m_percent_box = m_root_container->add<GUI::CheckBox>("\xE2\x84\xB9"_short_string); m_percent_box->set_tooltip(m_show_percent ? "Hide percent" : "Show percent"); diff --git a/Userland/Applets/ResourceGraph/main.cpp b/Userland/Applets/ResourceGraph/main.cpp index 91e5115460..836a1e7d39 100644 --- a/Userland/Applets/ResourceGraph/main.cpp +++ b/Userland/Applets/ResourceGraph/main.cpp @@ -35,7 +35,7 @@ private: GraphWidget(GraphType graph_type, Optional<Gfx::Color> graph_color, Optional<Gfx::Color> graph_error_color) : m_graph_type(graph_type) { - set_frame_thickness(1); + set_frame_style(Gfx::FrameStyle::SunkenPanel); m_graph_color = graph_color.value_or(palette().menu_selection()); m_graph_error_color = graph_error_color.value_or(Color::Red); start_timer(1000); diff --git a/Userland/Applets/WorkspacePicker/DesktopStatusWindow.cpp b/Userland/Applets/WorkspacePicker/DesktopStatusWindow.cpp index 03997022f2..c2094b9d71 100644 --- a/Userland/Applets/WorkspacePicker/DesktopStatusWindow.cpp +++ b/Userland/Applets/WorkspacePicker/DesktopStatusWindow.cpp @@ -55,7 +55,7 @@ public: auto rect = rect_for_desktop(row, column); painter.fill_rect(rect, (row == current_row() && column == current_column()) ? active_color : inactive_color); - Gfx::StylePainter::current().paint_frame(painter, rect, palette(), Gfx::FrameShape::Container, Gfx::FrameShadow::Sunken, 1); + Gfx::StylePainter::current().paint_frame(painter, rect, palette(), Gfx::FrameStyle::SunkenPanel); } } } diff --git a/Userland/Applications/Assistant/main.cpp b/Userland/Applications/Assistant/main.cpp index 35f316c291..0242f98097 100644 --- a/Userland/Applications/Assistant/main.cpp +++ b/Userland/Applications/Assistant/main.cpp @@ -176,7 +176,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) auto container = TRY(window->set_main_widget<GUI::Frame>()); container->set_fill_with_background_color(true); - container->set_frame_shape(Gfx::FrameShape::Window); + container->set_frame_style(Gfx::FrameStyle::Window); container->set_layout<GUI::VerticalBoxLayout>(8); auto& text_box = container->add<GUI::TextBox>(); diff --git a/Userland/Applications/Browser/BrowserWindow.cpp b/Userland/Applications/Browser/BrowserWindow.cpp index b04742e7aa..717da93e38 100644 --- a/Userland/Applications/Browser/BrowserWindow.cpp +++ b/Userland/Applications/Browser/BrowserWindow.cpp @@ -206,11 +206,10 @@ void BrowserWindow::build_menus() tab.m_toolbar_container->set_visible(!is_fullscreen); tab.m_statusbar->set_visible(!is_fullscreen); - if (is_fullscreen) { - tab.view().set_frame_thickness(0); - } else { - tab.view().set_frame_thickness(2); - } + if (is_fullscreen) + tab.view().set_frame_style(Gfx::FrameStyle::NoFrame); + else + tab.view().set_frame_style(Gfx::FrameStyle::SunkenContainer); }, this)); diff --git a/Userland/Applications/Browser/Tab.gml b/Userland/Applications/Browser/Tab.gml index 8d09e39052..5593de41d8 100644 --- a/Userland/Applications/Browser/Tab.gml +++ b/Userland/Applications/Browser/Tab.gml @@ -13,9 +13,7 @@ @GUI::Frame { name: "webdriver_banner" - shape: "Box" - shadow: "Sunken" - thickness: 1 + style: "SunkenPanel" preferred_height: "shrink" foreground_role: "TooltipText" background_role: "Tooltip" diff --git a/Userland/Applications/Calculator/CalculatorWidget.cpp b/Userland/Applications/Calculator/CalculatorWidget.cpp index 2c7d959007..64a93717a3 100644 --- a/Userland/Applications/Calculator/CalculatorWidget.cpp +++ b/Userland/Applications/Calculator/CalculatorWidget.cpp @@ -25,10 +25,7 @@ CalculatorWidget::CalculatorWidget() m_entry->set_text_alignment(Gfx::TextAlignment::CenterRight); m_label = *find_descendant_of_type_named<GUI::Label>("label"); - - m_label->set_frame_shadow(Gfx::FrameShadow::Sunken); - m_label->set_frame_shape(Gfx::FrameShape::Container); - m_label->set_frame_thickness(2); + m_label->set_frame_style(Gfx::FrameStyle::SunkenContainer); for (int i = 0; i < 10; i++) { m_digit_button[i] = *find_descendant_of_type_named<GUI::Button>(DeprecatedString::formatted("{}_button", i)); diff --git a/Userland/Applications/ClockSettings/ClockSettingsWidget.gml b/Userland/Applications/ClockSettings/ClockSettingsWidget.gml index e4b2723838..6754f82e94 100644 --- a/Userland/Applications/ClockSettings/ClockSettingsWidget.gml +++ b/Userland/Applications/ClockSettings/ClockSettingsWidget.gml @@ -63,9 +63,7 @@ } @GUI::Label { - shape: "Container" - thickness: 2 - shadow: "Sunken" + style: "SunkenContainer" name: "clock_preview" text: "12:34:56" } diff --git a/Userland/Applications/DisplaySettings/FontSettings.gml b/Userland/Applications/DisplaySettings/FontSettings.gml index dfcf434397..1988536eb1 100644 --- a/Userland/Applications/DisplaySettings/FontSettings.gml +++ b/Userland/Applications/DisplaySettings/FontSettings.gml @@ -19,9 +19,7 @@ @GUI::Label { background_role: "Base" - shadow: "Sunken" - shape: "Container" - thickness: 2 + style: "SunkenContainer" fill_with_background_color: true name: "default_font_label" } @@ -47,9 +45,7 @@ @GUI::Label { background_role: "Base" - shadow: "Sunken" - shape: "Container" - thickness: 2 + style: "SunkenContainer" fill_with_background_color: true name: "window_title_font_label" } @@ -75,9 +71,7 @@ @GUI::Label { background_role: "Base" - shadow: "Sunken" - shape: "Container" - thickness: 2 + style: "SunkenContainer" fill_with_background_color: true name: "fixed_width_font_label" } diff --git a/Userland/Applications/FileManager/DirectoryView.cpp b/Userland/Applications/FileManager/DirectoryView.cpp index d55a8dbe21..453679290d 100644 --- a/Userland/Applications/FileManager/DirectoryView.cpp +++ b/Userland/Applications/FileManager/DirectoryView.cpp @@ -223,8 +223,7 @@ void DirectoryView::setup_icon_view() }; if (is_desktop()) { - m_icon_view->set_frame_shape(Gfx::FrameShape::NoFrame); - m_icon_view->set_frame_thickness(0); + m_icon_view->set_frame_style(Gfx::FrameStyle::NoFrame); m_icon_view->set_scrollbars_enabled(false); m_icon_view->set_fill_with_background_color(false); m_icon_view->set_draw_item_text_with_shadow(true); diff --git a/Userland/Applications/FileManager/main.cpp b/Userland/Applications/FileManager/main.cpp index 466be2b2e4..f0b876158a 100644 --- a/Userland/Applications/FileManager/main.cpp +++ b/Userland/Applications/FileManager/main.cpp @@ -661,9 +661,7 @@ ErrorOr<int> run_in_windowed_mode(DeprecatedString const& initial_location, Depr auto& progressbar = *widget->find_descendant_of_type_named<GUI::Progressbar>("progressbar"); progressbar.set_format(GUI::Progressbar::Format::ValueSlashMax); - progressbar.set_frame_shape(Gfx::FrameShape::Panel); - progressbar.set_frame_shadow(Gfx::FrameShadow::Sunken); - progressbar.set_frame_thickness(1); + progressbar.set_frame_style(Gfx::FrameStyle::SunkenPanel); auto refresh_tree_view = [&] { directories_model->invalidate(); diff --git a/Userland/Applications/FontEditor/FontPreviewWindow.gml b/Userland/Applications/FontEditor/FontPreviewWindow.gml index b91908d882..9deadc3d50 100644 --- a/Userland/Applications/FontEditor/FontPreviewWindow.gml +++ b/Userland/Applications/FontEditor/FontPreviewWindow.gml @@ -8,9 +8,7 @@ layout: @GUI::VerticalBoxLayout { margins: [4] } - shape: "Box" - shadow: "Sunken" - thickness: 2 + style: "SunkenBox" @GUI::Label { name: "preview_label" diff --git a/Userland/Applications/ImageViewer/main.cpp b/Userland/Applications/ImageViewer/main.cpp index a932eef9bb..bf23daa3f2 100644 --- a/Userland/Applications/ImageViewer/main.cpp +++ b/Userland/Applications/ImageViewer/main.cpp @@ -115,7 +115,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) widget->on_doubleclick = [&] { window->set_fullscreen(!window->is_fullscreen()); toolbar_container->set_visible(!window->is_fullscreen()); - widget->set_frame_thickness(window->is_fullscreen() ? 0 : 2); + widget->set_frame_style(window->is_fullscreen() ? Gfx::FrameStyle::NoFrame : Gfx::FrameStyle::SunkenContainer); }; // Actions diff --git a/Userland/Applications/PixelPaint/FilterParams.h b/Userland/Applications/PixelPaint/FilterParams.h index 1e8df1918e..8a685b6d45 100644 --- a/Userland/Applications/PixelPaint/FilterParams.h +++ b/Userland/Applications/PixelPaint/FilterParams.h @@ -49,8 +49,7 @@ private: resize(200, 250); auto main_widget = set_main_widget<GUI::Frame>().release_value_but_fixme_should_propagate_errors(); - main_widget->set_frame_shape(Gfx::FrameShape::Container); - main_widget->set_frame_shadow(Gfx::FrameShadow::Raised); + main_widget->set_frame_style(Gfx::FrameStyle::RaisedContainer); main_widget->set_fill_with_background_color(true); main_widget->template set_layout<GUI::VerticalBoxLayout>(4); diff --git a/Userland/Applications/PixelPaint/LayerListWidget.cpp b/Userland/Applications/PixelPaint/LayerListWidget.cpp index a3857a9817..108877b81a 100644 --- a/Userland/Applications/PixelPaint/LayerListWidget.cpp +++ b/Userland/Applications/PixelPaint/LayerListWidget.cpp @@ -183,7 +183,7 @@ void LayerListWidget::paint_event(GUI::PaintEvent& event) if (m_moving_gadget_index.has_value()) paint_gadget(m_gadgets[m_moving_gadget_index.value()]); - Gfx::StylePainter::paint_frame(painter, rect(), palette(), Gfx::FrameShape::Box, Gfx::FrameShadow::Sunken, 2); + Gfx::StylePainter::paint_frame(painter, rect(), palette(), Gfx::FrameStyle::SunkenBox); } Optional<size_t> LayerListWidget::gadget_at(Gfx::IntPoint position) diff --git a/Userland/Applications/PixelPaint/PaletteWidget.cpp b/Userland/Applications/PixelPaint/PaletteWidget.cpp index ef558b165a..d8454d2e5c 100644 --- a/Userland/Applications/PixelPaint/PaletteWidget.cpp +++ b/Userland/Applications/PixelPaint/PaletteWidget.cpp @@ -94,9 +94,7 @@ private: PaletteWidget::PaletteWidget() { - set_frame_shape(Gfx::FrameShape::Panel); - set_frame_shadow(Gfx::FrameShadow::Raised); - set_frame_thickness(0); + set_frame_style(Gfx::FrameStyle::NoFrame); set_fill_with_background_color(true); set_fixed_height(35); diff --git a/Userland/Applications/Presenter/PresenterWidget.cpp b/Userland/Applications/Presenter/PresenterWidget.cpp index 99d8e8dbc8..d0cc55b48f 100644 --- a/Userland/Applications/Presenter/PresenterWidget.cpp +++ b/Userland/Applications/Presenter/PresenterWidget.cpp @@ -22,7 +22,7 @@ PresenterWidget::PresenterWidget() set_min_size(200, 120); set_fill_with_background_color(true); m_web_view = add<WebView::OutOfProcessWebView>(); - m_web_view->set_frame_thickness(0); + m_web_view->set_frame_style(Gfx::FrameStyle::NoFrame); m_web_view->set_scrollbars_enabled(false); m_web_view->set_focus_policy(GUI::FocusPolicy::NoFocus); m_web_view->set_content_scales_to_viewport(true); diff --git a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp index 76edfaec2d..4180dd8ff6 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp @@ -84,7 +84,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, Vector<NonnullR auto inline_widget = m_inline_documentation_window->set_main_widget<GUI::Frame>().release_value_but_fixme_should_propagate_errors(); inline_widget->set_fill_with_background_color(true); inline_widget->set_layout<GUI::VerticalBoxLayout>(4); - inline_widget->set_frame_shape(Gfx::FrameShape::Box); + inline_widget->set_frame_style(Gfx::FrameStyle::Plain); m_inline_documentation_label = inline_widget->add<GUI::Label>(); m_inline_documentation_label->set_fill_with_background_color(true); m_inline_documentation_label->set_autosize(false); diff --git a/Userland/Applications/TerminalSettings/TerminalSettingsView.gml b/Userland/Applications/TerminalSettings/TerminalSettingsView.gml index 21bd43c73d..a46f271dda 100644 --- a/Userland/Applications/TerminalSettings/TerminalSettingsView.gml +++ b/Userland/Applications/TerminalSettings/TerminalSettingsView.gml @@ -27,9 +27,7 @@ @GUI::Label { background_role: "Base" - shape: "Container" - shadow: "Sunken" - thickness: 2 + style: "SunkenContainer" fill_with_background_color: true name: "terminal_font_label" } diff --git a/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp b/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp index e9854bd200..db0368f149 100644 --- a/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp +++ b/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp @@ -321,7 +321,7 @@ void VideoPlayerWidget::toggle_fullscreen() auto* bottom_container = find_descendant_of_type_named<GUI::Widget>("bottom_container"); bottom_container->set_visible(!parent_window->is_fullscreen()); auto* video_frame = find_descendant_of_type_named<VideoFrameWidget>("video_frame"); - video_frame->set_frame_thickness(parent_window->is_fullscreen() ? 0 : 2); + video_frame->set_frame_style(parent_window->is_fullscreen() ? Gfx::FrameStyle::NoFrame : Gfx::FrameStyle::SunkenContainer); } void VideoPlayerWidget::update_title() diff --git a/Userland/Demos/ModelGallery/BasicModelTab.gml b/Userland/Demos/ModelGallery/BasicModelTab.gml index 347d6852e5..9859acc23f 100644 --- a/Userland/Demos/ModelGallery/BasicModelTab.gml +++ b/Userland/Demos/ModelGallery/BasicModelTab.gml @@ -7,7 +7,6 @@ @GUI::Label { text: "Here is a basic model, displayed on a table widget. Its clients are updated via granular updates. You can add or remove items with the widgets below." text_alignment: "CenterLeft" - thickness: 2 fixed_height: 34 } diff --git a/Userland/Demos/WidgetGallery/GalleryGML/BasicsTab.gml b/Userland/Demos/WidgetGallery/GalleryGML/BasicsTab.gml index deca9112fc..c5cbeb1288 100644 --- a/Userland/Demos/WidgetGallery/GalleryGML/BasicsTab.gml +++ b/Userland/Demos/WidgetGallery/GalleryGML/BasicsTab.gml @@ -17,9 +17,7 @@ @GUI::Frame { name: "label_frame" - shape: "Panel" - shadow: "Sunken" - thickness: 1 + style: "SunkenPanel" layout: @GUI::VerticalBoxLayout { margins: [3, 4] } @@ -59,7 +57,7 @@ layout: @GUI::HorizontalBoxLayout {} @GUI::ComboBox { - name: "frame_shape_combobox" + name: "frame_style_combobox" placeholder: "Combo box" } @@ -70,11 +68,7 @@ @GUI::VerticalSeparator {} - @GUI::SpinBox { - name: "thickness_spinbox" - min: 0 - max: 2 - } + @GUI::SpinBox {} @GUI::SpinBox { enabled: false diff --git a/Userland/Demos/WidgetGallery/GalleryGML/SlidersTab.gml b/Userland/Demos/WidgetGallery/GalleryGML/SlidersTab.gml index 0996171f50..ea27006b34 100644 --- a/Userland/Demos/WidgetGallery/GalleryGML/SlidersTab.gml +++ b/Userland/Demos/WidgetGallery/GalleryGML/SlidersTab.gml @@ -35,10 +35,8 @@ @GUI::HorizontalSeparator {} @GUI::Frame { - shape: "Panel" - shadow: "Sunken" + style: "SunkenPanel" preferred_height: "fit" - thickness: 1 layout: @GUI::VerticalBoxLayout { margins: [1] } diff --git a/Userland/Demos/WidgetGallery/GalleryWidget.cpp b/Userland/Demos/WidgetGallery/GalleryWidget.cpp index 1555f0577e..184ae49411 100644 --- a/Userland/Demos/WidgetGallery/GalleryWidget.cpp +++ b/Userland/Demos/WidgetGallery/GalleryWidget.cpp @@ -43,22 +43,20 @@ GalleryWidget::GalleryWidget() m_label_frame = basics_tab->find_descendant_of_type_named<GUI::Frame>("label_frame"); m_frame_shapes.append("No Frame"); - m_frame_shapes.append("Plain Box"); - m_frame_shapes.append("Plain Container"); - m_frame_shapes.append("Plain Panel"); + m_frame_shapes.append("Window"); + m_frame_shapes.append("Plain"); m_frame_shapes.append("Raised Box"); - m_frame_shapes.append("Raised Container"); - m_frame_shapes.append("Raised Panel"); m_frame_shapes.append("Sunken Box"); + m_frame_shapes.append("Raised Container"); m_frame_shapes.append("Sunken Container"); + m_frame_shapes.append("Raised Panel"); m_frame_shapes.append("Sunken Panel"); - m_frame_shape_combobox = basics_tab->find_descendant_of_type_named<GUI::ComboBox>("frame_shape_combobox"); + m_frame_shape_combobox = basics_tab->find_descendant_of_type_named<GUI::ComboBox>("frame_style_combobox"); m_frame_shape_combobox->set_model(*GUI::ItemListModel<DeprecatedString>::create(m_frame_shapes)); m_frame_shape_combobox->on_change = [&](auto&, auto const& index) { - m_label_frame->set_frame_shape(static_cast<Gfx::FrameShape>((index.row() - 1) % 3 + 1)); - m_label_frame->set_frame_shadow(static_cast<Gfx::FrameShadow>((index.row() - 1) / 3)); + m_label_frame->set_frame_style(static_cast<Gfx::FrameStyle>(index.row())); m_label_frame->update(); }; @@ -66,13 +64,6 @@ GalleryWidget::GalleryWidget() m_enabled_label->set_text(String::from_deprecated_string(m_frame_shape_combobox->text()).release_value_but_fixme_should_propagate_errors()); }; - m_thickness_spinbox = basics_tab->find_descendant_of_type_named<GUI::SpinBox>("thickness_spinbox"); - m_thickness_spinbox->set_value(1); - - m_thickness_spinbox->on_change = [&](auto value) { - m_label_frame->set_frame_thickness(value); - }; - m_button_icons.append(Gfx::Bitmap::load_from_file("/res/icons/16x16/book-open.png"sv).release_value_but_fixme_should_propagate_errors()); m_button_icons.append(Gfx::Bitmap::load_from_file("/res/icons/16x16/inspector-object.png"sv).release_value_but_fixme_should_propagate_errors()); m_button_icons.append(Gfx::Bitmap::load_from_file("/res/icons/16x16/ladybug.png"sv).release_value_but_fixme_should_propagate_errors()); diff --git a/Userland/Demos/WidgetGallery/GalleryWidget.h b/Userland/Demos/WidgetGallery/GalleryWidget.h index 206b0a5f8d..1b271a3d61 100644 --- a/Userland/Demos/WidgetGallery/GalleryWidget.h +++ b/Userland/Demos/WidgetGallery/GalleryWidget.h @@ -53,7 +53,6 @@ private: RefPtr<GUI::Frame> m_label_frame; RefPtr<GUI::Label> m_enabled_label; - RefPtr<GUI::SpinBox> m_thickness_spinbox; RefPtr<GUI::ColorInput> m_font_colorinput; RefPtr<GUI::TableView> m_icons_tableview; RefPtr<GUI::TableView> m_cursors_tableview; diff --git a/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.gml b/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.gml index 13fd492300..6597397819 100644 --- a/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.gml +++ b/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.gml @@ -18,9 +18,7 @@ @GUI::Label { name: "description_label" text_alignment: "CenterLeft" - thickness: 2 - shadow: "Sunken" - shape: "Container" + style: "SunkenContainer" max_height: 24 } @@ -75,9 +73,7 @@ name: "full_path_label" text_alignment: "CenterLeft" text: "" - thickness: 2 - shadow: "Sunken" - shape: "Container" + style: "SunkenContainer" max_height: 22 } } diff --git a/Userland/DevTools/Profiler/FlameGraphView.cpp b/Userland/DevTools/Profiler/FlameGraphView.cpp index 363627831d..d624c8166e 100644 --- a/Userland/DevTools/Profiler/FlameGraphView.cpp +++ b/Userland/DevTools/Profiler/FlameGraphView.cpp @@ -44,7 +44,7 @@ FlameGraphView::FlameGraphView(GUI::Model& model, int text_column, int width_col set_fill_with_background_color(true); set_background_role(Gfx::ColorRole::Base); set_scrollbars_enabled(true); - set_frame_thickness(0); + set_frame_style(Gfx::FrameStyle::NoFrame); set_should_hide_unnecessary_scrollbars(false); horizontal_scrollbar().set_visible(false); diff --git a/Userland/DevTools/Profiler/TimelineHeader.cpp b/Userland/DevTools/Profiler/TimelineHeader.cpp index 4a4e99ab74..b45e26320a 100644 --- a/Userland/DevTools/Profiler/TimelineHeader.cpp +++ b/Userland/DevTools/Profiler/TimelineHeader.cpp @@ -19,8 +19,7 @@ TimelineHeader::TimelineHeader(Profile& profile, Process const& process) : m_profile(profile) , m_process(process) { - set_frame_shape(Gfx::FrameShape::Panel); - set_frame_shadow(Gfx::FrameShadow::Raised); + set_frame_style(Gfx::FrameStyle::RaisedPanel); set_fixed_size(200, 40); update_selection(); diff --git a/Userland/DevTools/Profiler/TimelineTrack.cpp b/Userland/DevTools/Profiler/TimelineTrack.cpp index 8bd8ae5995..600f1817d6 100644 --- a/Userland/DevTools/Profiler/TimelineTrack.cpp +++ b/Userland/DevTools/Profiler/TimelineTrack.cpp @@ -23,7 +23,7 @@ TimelineTrack::TimelineTrack(TimelineView const& view, Profile const& profile, P set_background_role(Gfx::ColorRole::Base); set_fixed_height(40); set_scale(view.scale()); - set_frame_thickness(1); + set_frame_style(Gfx::FrameStyle::SunkenPanel); } void TimelineTrack::set_scale(float scale) diff --git a/Userland/Games/Chess/PromotionDialog.cpp b/Userland/Games/Chess/PromotionDialog.cpp index 58121312d1..fdb77100ea 100644 --- a/Userland/Games/Chess/PromotionDialog.cpp +++ b/Userland/Games/Chess/PromotionDialog.cpp @@ -18,7 +18,7 @@ PromotionDialog::PromotionDialog(ChessWidget& chess_widget) resize(70 * 4, 70); auto main_widget = set_main_widget<GUI::Frame>().release_value_but_fixme_should_propagate_errors(); - main_widget->set_frame_shape(Gfx::FrameShape::Container); + main_widget->set_frame_style(Gfx::FrameStyle::SunkenContainer); main_widget->set_fill_with_background_color(true); main_widget->set_layout<GUI::HorizontalBoxLayout>(); diff --git a/Userland/Libraries/LibGUI/Application.cpp b/Userland/Libraries/LibGUI/Application.cpp index f5be7b95ac..1fc3c107a4 100644 --- a/Userland/Libraries/LibGUI/Application.cpp +++ b/Userland/Libraries/LibGUI/Application.cpp @@ -49,9 +49,7 @@ private: m_label->set_background_role(Gfx::ColorRole::Tooltip); m_label->set_foreground_role(Gfx::ColorRole::TooltipText); m_label->set_fill_with_background_color(true); - m_label->set_frame_thickness(1); - m_label->set_frame_shape(Gfx::FrameShape::Container); - m_label->set_frame_shadow(Gfx::FrameShadow::Plain); + m_label->set_frame_style(Gfx::FrameStyle::Plain); m_label->set_autosize(true); } diff --git a/Userland/Libraries/LibGUI/AutocompleteProvider.cpp b/Userland/Libraries/LibGUI/AutocompleteProvider.cpp index 60ac4744d1..6f554671ad 100644 --- a/Userland/Libraries/LibGUI/AutocompleteProvider.cpp +++ b/Userland/Libraries/LibGUI/AutocompleteProvider.cpp @@ -97,8 +97,7 @@ AutocompleteBox::AutocompleteBox(TextEditor& editor) main_widget->set_layout<GUI::VerticalBoxLayout>(); m_suggestion_view = main_widget->add<GUI::TableView>(); - m_suggestion_view->set_frame_shadow(Gfx::FrameShadow::Plain); - m_suggestion_view->set_frame_thickness(1); + m_suggestion_view->set_frame_style(Gfx::FrameStyle::Plain); m_suggestion_view->set_column_headers_visible(false); m_suggestion_view->set_visible(false); m_suggestion_view->on_activation = [&](GUI::ModelIndex const& index) { diff --git a/Userland/Libraries/LibGUI/ComboBox.cpp b/Userland/Libraries/LibGUI/ComboBox.cpp index fc80fd1fc8..508127301c 100644 --- a/Userland/Libraries/LibGUI/ComboBox.cpp +++ b/Userland/Libraries/LibGUI/ComboBox.cpp @@ -65,7 +65,7 @@ ComboBox::ComboBox() set_preferred_size({ SpecialDimension::OpportunisticGrow, 22 }); m_editor = add<ComboBoxEditor>(); - m_editor->set_frame_thickness(0); + m_editor->set_frame_style(Gfx::FrameStyle::NoFrame); m_editor->on_return_pressed = [this] { if (on_return_pressed) on_return_pressed(); @@ -120,8 +120,7 @@ ComboBox::ComboBox() m_list_view->set_should_hide_unnecessary_scrollbars(true); m_list_view->set_alternating_row_colors(false); m_list_view->set_hover_highlighting(true); - m_list_view->set_frame_thickness(1); - m_list_view->set_frame_shadow(Gfx::FrameShadow::Plain); + m_list_view->set_frame_style(Gfx::FrameStyle::Plain); m_list_view->set_activates_on_selection(true); m_list_view->on_selection_change = [this] { VERIFY(model()); diff --git a/Userland/Libraries/LibGUI/CommandPalette.cpp b/Userland/Libraries/LibGUI/CommandPalette.cpp index c18eb3215d..14220804c9 100644 --- a/Userland/Libraries/LibGUI/CommandPalette.cpp +++ b/Userland/Libraries/LibGUI/CommandPalette.cpp @@ -183,7 +183,7 @@ CommandPalette::CommandPalette(GUI::Window& parent_window, ScreenPosition screen collect_actions(parent_window); auto main_widget = set_main_widget<GUI::Frame>().release_value_but_fixme_should_propagate_errors(); - main_widget->set_frame_shape(Gfx::FrameShape::Window); + main_widget->set_frame_style(Gfx::FrameStyle::Window); main_widget->set_fill_with_background_color(true); main_widget->set_layout<GUI::VerticalBoxLayout>(4); diff --git a/Userland/Libraries/LibGUI/EmojiInputDialog.gml b/Userland/Libraries/LibGUI/EmojiInputDialog.gml index 3f63c09b67..9671391995 100644 --- a/Userland/Libraries/LibGUI/EmojiInputDialog.gml +++ b/Userland/Libraries/LibGUI/EmojiInputDialog.gml @@ -1,5 +1,5 @@ @GUI::Frame { - shape: "Window" + style: "Window" fill_with_background_color: true layout: @GUI::VerticalBoxLayout { margins: [4] diff --git a/Userland/Libraries/LibGUI/Frame.cpp b/Userland/Libraries/LibGUI/Frame.cpp index 209db1d9ce..2ecaff705d 100644 --- a/Userland/Libraries/LibGUI/Frame.cpp +++ b/Userland/Libraries/LibGUI/Frame.cpp @@ -16,40 +16,51 @@ namespace GUI { Frame::Frame() { - set_frame_thickness(2); - set_frame_shape(Gfx::FrameShape::Container); - set_frame_shadow(Gfx::FrameShadow::Sunken); - - REGISTER_INT_PROPERTY("thickness", frame_thickness, set_frame_thickness); - REGISTER_ENUM_PROPERTY("shadow", frame_shadow, set_frame_shadow, Gfx::FrameShadow, - { Gfx::FrameShadow::Plain, "Plain" }, - { Gfx::FrameShadow::Raised, "Raised" }, - { Gfx::FrameShadow::Sunken, "Sunken" }); - REGISTER_ENUM_PROPERTY("shape", frame_shape, set_frame_shape, Gfx::FrameShape, - { Gfx::FrameShape::NoFrame, "NoFrame" }, - { Gfx::FrameShape::Box, "Box" }, - { Gfx::FrameShape::Container, "Container" }, - { Gfx::FrameShape::Panel, "Panel" }, - { Gfx::FrameShape::Window, "Window" }); + set_frame_style(Gfx::FrameStyle::SunkenContainer); + + REGISTER_ENUM_PROPERTY("style", frame_style, set_frame_style, Gfx::FrameStyle, + { Gfx::FrameStyle::NoFrame, "NoFrame" }, + { Gfx::FrameStyle::Window, "Window" }, + { Gfx::FrameStyle::Plain, "Plain" }, + { Gfx::FrameStyle::RaisedBox, "RaisedBox" }, + { Gfx::FrameStyle::SunkenBox, "SunkenBox" }, + { Gfx::FrameStyle::RaisedContainer, "RaisedContainer" }, + { Gfx::FrameStyle::SunkenContainer, "SunkenContainer" }, + { Gfx::FrameStyle::RaisedPanel, "RaisedPanel" }, + { Gfx::FrameStyle::SunkenPanel, "SunkenPanel" }); } -void Frame::set_frame_thickness(int thickness) +void Frame::set_frame_style(Gfx::FrameStyle style) { - if (m_thickness == thickness) + if (m_style == style) return; - m_thickness = thickness; - set_grabbable_margins(thickness); + m_style = style; + set_grabbable_margins(frame_thickness()); layout_relevant_change_occurred(); } +int Frame::frame_thickness() const +{ + switch (m_style) { + case Gfx::FrameStyle::NoFrame: + return 0; + case Gfx::FrameStyle::Plain: + case Gfx::FrameStyle::RaisedPanel: + case Gfx::FrameStyle::SunkenPanel: + return 1; + default: + return 2; + } +} + void Frame::paint_event(PaintEvent& event) { - if (m_shape == Gfx::FrameShape::NoFrame) + if (m_style == Gfx::FrameStyle::NoFrame) return; Painter painter(*this); painter.add_clip_rect(event.rect()); - Gfx::StylePainter::paint_frame(painter, rect(), palette(), m_shape, m_shadow, m_thickness, spans_entire_window_horizontally()); + Gfx::StylePainter::paint_frame(painter, rect(), palette(), m_style, spans_entire_window_horizontally()); } Gfx::IntRect Frame::children_clip_rect() const diff --git a/Userland/Libraries/LibGUI/Frame.h b/Userland/Libraries/LibGUI/Frame.h index e1be22501b..c0dd9ef6f6 100644 --- a/Userland/Libraries/LibGUI/Frame.h +++ b/Userland/Libraries/LibGUI/Frame.h @@ -17,18 +17,14 @@ class Frame : public Widget { public: virtual ~Frame() override = default; - int frame_thickness() const { return m_thickness; } - void set_frame_thickness(int thickness); + int frame_thickness() const; virtual Margins content_margins() const override { return { frame_thickness() }; } - Gfx::FrameShadow frame_shadow() const { return m_shadow; } - void set_frame_shadow(Gfx::FrameShadow shadow) { m_shadow = shadow; } + Gfx::FrameStyle frame_style() const { return m_style; } + void set_frame_style(Gfx::FrameStyle); - Gfx::FrameShape frame_shape() const { return m_shape; } - void set_frame_shape(Gfx::FrameShape shape) { m_shape = shape; } - - Gfx::IntRect frame_inner_rect_for_size(Gfx::IntSize size) const { return { m_thickness, m_thickness, size.width() - m_thickness * 2, size.height() - m_thickness * 2 }; } + Gfx::IntRect frame_inner_rect_for_size(Gfx::IntSize size) const { return { frame_thickness(), frame_thickness(), size.width() - frame_thickness() * 2, size.height() - frame_thickness() * 2 }; } Gfx::IntRect frame_inner_rect() const { return frame_inner_rect_for_size(size()); } virtual Gfx::IntRect children_clip_rect() const override; @@ -38,9 +34,7 @@ protected: void paint_event(PaintEvent&) override; private: - int m_thickness { 0 }; - Gfx::FrameShadow m_shadow { Gfx::FrameShadow::Plain }; - Gfx::FrameShape m_shape { Gfx::FrameShape::NoFrame }; + Gfx::FrameStyle m_style { Gfx::FrameStyle::NoFrame }; }; } diff --git a/Userland/Libraries/LibGUI/GroupBox.cpp b/Userland/Libraries/LibGUI/GroupBox.cpp index d45ae0c0fa..5878d11bdc 100644 --- a/Userland/Libraries/LibGUI/GroupBox.cpp +++ b/Userland/Libraries/LibGUI/GroupBox.cpp @@ -40,7 +40,7 @@ void GroupBox::paint_event(PaintEvent& event) 0, (!m_title.is_empty() ? font().pixel_size_rounded_up() / 2 : 0), width(), height() - (!m_title.is_empty() ? font().pixel_size_rounded_up() / 2 : 0) }; - Gfx::StylePainter::paint_frame(painter, frame_rect, palette(), Gfx::FrameShape::Box, Gfx::FrameShadow::Sunken, 2); + Gfx::StylePainter::paint_frame(painter, frame_rect, palette(), Gfx::FrameStyle::SunkenBox); if (!m_title.is_empty()) { Gfx::IntRect text_rect { 6, 1, font().width_rounded_up(m_title) + 6, font().pixel_size_rounded_up() }; diff --git a/Userland/Libraries/LibGUI/ImageWidget.cpp b/Userland/Libraries/LibGUI/ImageWidget.cpp index 2e6d9efbad..4b422b0f76 100644 --- a/Userland/Libraries/LibGUI/ImageWidget.cpp +++ b/Userland/Libraries/LibGUI/ImageWidget.cpp @@ -20,9 +20,7 @@ ImageWidget::ImageWidget(StringView) : m_timer(Core::Timer::try_create().release_value_but_fixme_should_propagate_errors()) { - set_frame_thickness(0); - set_frame_shadow(Gfx::FrameShadow::Plain); - set_frame_shape(Gfx::FrameShape::NoFrame); + set_frame_style(Gfx::FrameStyle::NoFrame); set_auto_resize(true); REGISTER_BOOL_PROPERTY("auto_resize", auto_resize, set_auto_resize); diff --git a/Userland/Libraries/LibGUI/Label.cpp b/Userland/Libraries/LibGUI/Label.cpp index 6cddff3f01..59e8af5412 100644 --- a/Userland/Libraries/LibGUI/Label.cpp +++ b/Userland/Libraries/LibGUI/Label.cpp @@ -24,11 +24,7 @@ Label::Label(String text) set_preferred_size({ SpecialDimension::OpportunisticGrow }); set_min_size({ SpecialDimension::Shrink }); - - set_frame_thickness(0); - set_frame_shadow(Gfx::FrameShadow::Plain); - set_frame_shape(Gfx::FrameShape::NoFrame); - + set_frame_style(Gfx::FrameStyle::NoFrame); set_foreground_role(Gfx::ColorRole::WindowText); REGISTER_STRING_PROPERTY("text", text, set_text); diff --git a/Userland/Libraries/LibGUI/ModelEditingDelegate.h b/Userland/Libraries/LibGUI/ModelEditingDelegate.h index 71a9ca2c70..09e6edf3f8 100644 --- a/Userland/Libraries/LibGUI/ModelEditingDelegate.h +++ b/Userland/Libraries/LibGUI/ModelEditingDelegate.h @@ -79,7 +79,7 @@ public: virtual RefPtr<Widget> create_widget() override { auto textbox = TextBox::construct(); - textbox->set_frame_shape(Gfx::FrameShape::NoFrame); + textbox->set_frame_style(Gfx::FrameStyle::NoFrame); textbox->on_return_pressed = [this] { commit(); diff --git a/Userland/Libraries/LibGUI/OpacitySlider.cpp b/Userland/Libraries/LibGUI/OpacitySlider.cpp index 5b005d1cc7..a554017ffd 100644 --- a/Userland/Libraries/LibGUI/OpacitySlider.cpp +++ b/Userland/Libraries/LibGUI/OpacitySlider.cpp @@ -132,7 +132,7 @@ void OpacitySlider::paint_event(PaintEvent& event) painter.draw_text(inner_rect, percent_text, Gfx::TextAlignment::Center, Color::White); // Frame - Gfx::StylePainter::paint_frame(painter, rect(), palette(), Gfx::FrameShape::Container, Gfx::FrameShadow::Sunken, 2); + Gfx::StylePainter::paint_frame(painter, rect(), palette(), Gfx::FrameStyle::SunkenContainer); } int OpacitySlider::value_at(Gfx::IntPoint position) const diff --git a/Userland/Libraries/LibGUI/Slider.cpp b/Userland/Libraries/LibGUI/Slider.cpp index 3ff67bee33..8dfaef568e 100644 --- a/Userland/Libraries/LibGUI/Slider.cpp +++ b/Userland/Libraries/LibGUI/Slider.cpp @@ -44,7 +44,7 @@ void Slider::paint_event(PaintEvent& event) track_rect = { 0, inner_rect().y(), track_size(), inner_rect().height() - shadow_thickness }; track_rect.center_horizontally_within(inner_rect()); } - Gfx::StylePainter::paint_frame(painter, track_rect, palette(), Gfx::FrameShape::Panel, Gfx::FrameShadow::Sunken, shadow_thickness); + Gfx::StylePainter::paint_frame(painter, track_rect, palette(), Gfx::FrameStyle::SunkenPanel); if (is_enabled()) Gfx::StylePainter::paint_button(painter, knob_rect(), palette(), Gfx::ButtonStyle::Normal, false, m_knob_hovered); else diff --git a/Userland/Libraries/LibGUI/Statusbar.cpp b/Userland/Libraries/LibGUI/Statusbar.cpp index 93dfaecec3..cf5d8c927d 100644 --- a/Userland/Libraries/LibGUI/Statusbar.cpp +++ b/Userland/Libraries/LibGUI/Statusbar.cpp @@ -85,7 +85,7 @@ void Statusbar::update_segment(size_t index) m_segments[i]->set_visible(true); } segment->set_text(String::from_utf8(segment->restored_text()).release_value_but_fixme_should_propagate_errors()); - segment->set_frame_shape(Gfx::FrameShape::Panel); + segment->set_frame_style(Gfx::FrameStyle::SunkenPanel); if (segment->mode() != Segment::Mode::Proportional) segment->set_fixed_width(segment->restored_width()); } else { @@ -94,7 +94,7 @@ void Statusbar::update_segment(size_t index) m_segments[i]->set_visible(false); } segment->set_text(String::from_utf8(segment->override_text()).release_value_but_fixme_should_propagate_errors()); - segment->set_frame_shape(Gfx::FrameShape::NoFrame); + segment->set_frame_style(Gfx::FrameStyle::NoFrame); if (segment->mode() != Segment::Mode::Proportional) segment->set_fixed_width(SpecialDimension::Grow); } @@ -152,7 +152,7 @@ void Statusbar::Segment::paint_event(PaintEvent& event) painter.add_clip_rect(event.rect()); bool skip_vertical_lines = window()->is_maximized() && spans_entire_window_horizontally(); - Gfx::StylePainter::current().paint_frame(painter, rect(), palette(), m_shape, Gfx::FrameShadow::Sunken, m_thickness, skip_vertical_lines); + Gfx::StylePainter::current().paint_frame(painter, rect(), palette(), m_style, skip_vertical_lines); if (is_clickable()) Button::paint_event(event); diff --git a/Userland/Libraries/LibGUI/Statusbar.h b/Userland/Libraries/LibGUI/Statusbar.h index 0720c7a396..916f59cf14 100644 --- a/Userland/Libraries/LibGUI/Statusbar.h +++ b/Userland/Libraries/LibGUI/Statusbar.h @@ -48,7 +48,7 @@ public: private: Segment(); - void set_frame_shape(Gfx::FrameShape shape) { m_shape = shape; } + void set_frame_style(Gfx::FrameStyle style) { m_style = style; } void set_restored_width(int width) { m_restored_width = width; } int restored_width() const { return m_restored_width; } DeprecatedString const& override_text() const { return m_override_text; } @@ -58,9 +58,8 @@ public: DeprecatedString m_restored_text; bool m_clickable { false }; int m_restored_width { 0 }; - int m_thickness { 1 }; Mode m_mode { Mode::Proportional }; - Gfx::FrameShape m_shape { Gfx::FrameShape::Panel }; + Gfx::FrameStyle m_style { Gfx::FrameStyle::SunkenPanel }; }; Segment& segment(size_t index) { return m_segments.at(index); } diff --git a/Userland/Libraries/LibGUI/TabWidget.cpp b/Userland/Libraries/LibGUI/TabWidget.cpp index 91b82301b8..069eb37a1b 100644 --- a/Userland/Libraries/LibGUI/TabWidget.cpp +++ b/Userland/Libraries/LibGUI/TabWidget.cpp @@ -243,7 +243,7 @@ void TabWidget::paint_event(PaintEvent& event) painter.fill_rect(event.rect(), palette().button()); if (!m_container_margins.is_null()) { - Gfx::StylePainter::paint_frame(painter, container_rect(), palette(), Gfx::FrameShape::Container, Gfx::FrameShadow::Raised, 2); + Gfx::StylePainter::paint_frame(painter, container_rect(), palette(), Gfx::FrameStyle::RaisedContainer); } auto paint_tab_icon_if_needed = [&](auto& icon, auto& button_rect, auto& text_rect) { @@ -284,7 +284,7 @@ void TabWidget::paint_event(PaintEvent& event) auto close_button_rect = this->close_button_rect(i); if (hovered_close_button) - Gfx::StylePainter::paint_frame(painter, close_button_rect, palette(), Gfx::FrameShape::Box, pressed_close_button ? Gfx::FrameShadow::Sunken : Gfx::FrameShadow::Raised, 1); + Gfx::StylePainter::paint_frame(painter, close_button_rect, palette(), pressed_close_button ? Gfx::FrameStyle::SunkenPanel : Gfx::FrameStyle::RaisedPanel); Gfx::IntRect icon_rect { close_button_rect.x() + 3, close_button_rect.y() + 3, 6, 6 }; if (!m_tabs[i].modified) { @@ -358,7 +358,7 @@ void TabWidget::paint_event(PaintEvent& event) } if (hovered_close_button) - Gfx::StylePainter::paint_frame(painter, close_button_rect, palette(), Gfx::FrameShape::Box, pressed_close_button ? Gfx::FrameShadow::Sunken : Gfx::FrameShadow::Raised, 1); + Gfx::StylePainter::paint_frame(painter, close_button_rect, palette(), pressed_close_button ? Gfx::FrameStyle::SunkenPanel : Gfx::FrameStyle::RaisedPanel); Gfx::IntRect icon_rect { close_button_rect.x() + 3, close_button_rect.y() + 3, 6, 6 }; if (!m_tabs[i].modified) { diff --git a/Userland/Libraries/LibGUI/ToolbarContainer.cpp b/Userland/Libraries/LibGUI/ToolbarContainer.cpp index 49c63b104b..5744036706 100644 --- a/Userland/Libraries/LibGUI/ToolbarContainer.cpp +++ b/Userland/Libraries/LibGUI/ToolbarContainer.cpp @@ -18,11 +18,7 @@ ToolbarContainer::ToolbarContainer(Gfx::Orientation orientation) : m_orientation(orientation) { set_fill_with_background_color(true); - - set_frame_thickness(2); - set_frame_shape(Gfx::FrameShape::Box); - set_frame_shadow(Gfx::FrameShadow::Sunken); - + set_frame_style(Gfx::FrameStyle::SunkenBox); set_layout<VerticalBoxLayout>(GUI::Margins {}, 2); set_shrink_to_fit(true); } diff --git a/Userland/Libraries/LibGUI/ValueSlider.cpp b/Userland/Libraries/LibGUI/ValueSlider.cpp index 0410d0a484..0749852951 100644 --- a/Userland/Libraries/LibGUI/ValueSlider.cpp +++ b/Userland/Libraries/LibGUI/ValueSlider.cpp @@ -87,7 +87,7 @@ void ValueSlider::paint_event(PaintEvent& event) unfilled_rect.set_left(knob_rect().right()); painter.fill_rect(unfilled_rect, palette().base()); - Gfx::StylePainter::paint_frame(painter, bar_rect(), palette(), Gfx::FrameShape::Container, Gfx::FrameShadow::Sunken, 2); + Gfx::StylePainter::paint_frame(painter, bar_rect(), palette(), Gfx::FrameStyle::SunkenContainer); Gfx::StylePainter::paint_button(painter, knob_rect(), palette(), Gfx::ButtonStyle::Normal, false, m_hovered); auto paint_knurl = [&](int x, int y) { diff --git a/Userland/Libraries/LibGfx/ClassicStylePainter.cpp b/Userland/Libraries/LibGfx/ClassicStylePainter.cpp index 007febdbb2..426ca14c01 100644 --- a/Userland/Libraries/LibGfx/ClassicStylePainter.cpp +++ b/Userland/Libraries/LibGfx/ClassicStylePainter.cpp @@ -241,12 +241,12 @@ void ClassicStylePainter::paint_button(Painter& painter, IntRect const& rect, Pa } } -void ClassicStylePainter::paint_frame(Painter& painter, IntRect const& rect, Palette const& palette, FrameShape shape, FrameShadow shadow, int thickness, bool skip_vertical_lines) +void ClassicStylePainter::paint_frame(Painter& painter, IntRect const& rect, Palette const& palette, FrameStyle style, bool skip_vertical_lines) { - if (shape == Gfx::FrameShape::NoFrame) + if (style == Gfx::FrameStyle::NoFrame) return; - if (shape == FrameShape::Window) { + if (style == FrameStyle::Window) { StylePainter::paint_window_frame(painter, rect, palette); return; } @@ -256,48 +256,50 @@ void ClassicStylePainter::paint_frame(Painter& painter, IntRect const& rect, Pal Color dark_shade = palette.threed_shadow1(); Color light_shade = palette.threed_highlight(); - if (shape == FrameShape::Container && thickness >= 2) { - if (shadow == FrameShadow::Raised) { - dark_shade = palette.threed_shadow2(); - } - } + if (style == FrameStyle::RaisedContainer) + dark_shade = palette.threed_shadow2(); - if (shadow == FrameShadow::Raised) { + switch (style) { + case FrameStyle::RaisedContainer: + case FrameStyle::RaisedBox: + case FrameStyle::RaisedPanel: top_left_color = light_shade; bottom_right_color = dark_shade; - } else if (shadow == FrameShadow::Sunken) { + break; + case FrameStyle::SunkenContainer: + case FrameStyle::SunkenBox: + case FrameStyle::SunkenPanel: top_left_color = dark_shade; bottom_right_color = light_shade; - } else if (shadow == FrameShadow::Plain) { + break; + case FrameStyle::Plain: top_left_color = dark_shade; bottom_right_color = dark_shade; + break; + default: + VERIFY_NOT_REACHED(); } - if (thickness >= 1) { - painter.draw_line(rect.top_left(), rect.top_right(), top_left_color); - painter.draw_line(rect.bottom_left(), rect.bottom_right(), bottom_right_color); + painter.draw_line(rect.top_left(), rect.top_right(), top_left_color); + painter.draw_line(rect.bottom_left(), rect.bottom_right(), bottom_right_color); - if (shape != FrameShape::Panel || !skip_vertical_lines) { - painter.draw_line(rect.top_left().translated(0, 1), rect.bottom_left().translated(0, -1), top_left_color); - painter.draw_line(rect.top_right(), rect.bottom_right().translated(0, -1), bottom_right_color); - } + if ((style != FrameStyle::SunkenPanel && style != FrameStyle::RaisedPanel) || !skip_vertical_lines) { + painter.draw_line(rect.top_left().translated(0, 1), rect.bottom_left().translated(0, -1), top_left_color); + painter.draw_line(rect.top_right(), rect.bottom_right().translated(0, -1), bottom_right_color); } - if (shape == FrameShape::Container && thickness >= 2) { + if (style == FrameStyle::RaisedContainer || style == FrameStyle::SunkenContainer) { Color top_left_color; Color bottom_right_color; Color dark_shade = palette.threed_shadow2(); Color light_shade = palette.button(); - if (shadow == FrameShadow::Raised) { + if (style == FrameStyle::RaisedContainer) { dark_shade = palette.threed_shadow1(); top_left_color = light_shade; bottom_right_color = dark_shade; - } else if (shadow == FrameShadow::Sunken) { + } else if (style == FrameStyle::SunkenContainer) { top_left_color = dark_shade; bottom_right_color = light_shade; - } else if (shadow == FrameShadow::Plain) { - top_left_color = dark_shade; - bottom_right_color = dark_shade; } IntRect inner_container_frame_rect = rect.shrunken(2, 2); painter.draw_line(inner_container_frame_rect.top_left(), inner_container_frame_rect.top_right(), top_left_color); @@ -306,7 +308,7 @@ void ClassicStylePainter::paint_frame(Painter& painter, IntRect const& rect, Pal painter.draw_line(inner_container_frame_rect.top_right(), inner_container_frame_rect.bottom_right().translated(0, -1), bottom_right_color); } - if (shape == FrameShape::Box && thickness >= 2) { + if (style == FrameStyle::RaisedBox || style == FrameStyle::SunkenBox) { swap(top_left_color, bottom_right_color); IntRect inner_rect = rect.shrunken(2, 2); painter.draw_line(inner_rect.top_left(), inner_rect.top_right(), top_left_color); @@ -555,7 +557,7 @@ static constexpr Gfx::CharacterBitmap s_checked_bitmap { void ClassicStylePainter::paint_check_box(Painter& painter, IntRect const& rect, Palette const& palette, bool is_enabled, bool is_checked, bool is_being_pressed) { painter.fill_rect(rect, is_enabled ? palette.base() : palette.window()); - paint_frame(painter, rect, palette, Gfx::FrameShape::Container, Gfx::FrameShadow::Sunken, 2); + paint_frame(painter, rect, palette, Gfx::FrameStyle::SunkenContainer); if (is_being_pressed) { // FIXME: This color should not be hard-coded. diff --git a/Userland/Libraries/LibGfx/ClassicStylePainter.h b/Userland/Libraries/LibGfx/ClassicStylePainter.h index 4c9fe615ff..1a9b98e69f 100644 --- a/Userland/Libraries/LibGfx/ClassicStylePainter.h +++ b/Userland/Libraries/LibGfx/ClassicStylePainter.h @@ -17,7 +17,7 @@ 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_frame(Painter&, IntRect const&, Palette const&, FrameShape, FrameShadow, int thickness, bool skip_vertical_lines = false) 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; virtual void paint_radio_button(Painter&, IntRect const&, Palette const&, bool is_checked, bool is_being_pressed) override; diff --git a/Userland/Libraries/LibGfx/StylePainter.cpp b/Userland/Libraries/LibGfx/StylePainter.cpp index 37106f5b14..256aed6305 100644 --- a/Userland/Libraries/LibGfx/StylePainter.cpp +++ b/Userland/Libraries/LibGfx/StylePainter.cpp @@ -28,9 +28,9 @@ void StylePainter::paint_button(Painter& painter, IntRect const& rect, Palette c current().paint_button(painter, rect, palette, button_style, pressed, hovered, checked, enabled, focused, default_button); } -void StylePainter::paint_frame(Painter& painter, IntRect const& rect, Palette const& palette, FrameShape shape, FrameShadow shadow, int thickness, bool skip_vertical_lines) +void StylePainter::paint_frame(Painter& painter, IntRect const& rect, Palette const& palette, FrameStyle style, bool skip_vertical_lines) { - current().paint_frame(painter, rect, palette, shape, shadow, thickness, skip_vertical_lines); + current().paint_frame(painter, rect, palette, style, skip_vertical_lines); } void StylePainter::paint_window_frame(Painter& painter, IntRect const& rect, Palette const& palette) diff --git a/Userland/Libraries/LibGfx/StylePainter.h b/Userland/Libraries/LibGfx/StylePainter.h index 8951a2afb5..9a7de46282 100644 --- a/Userland/Libraries/LibGfx/StylePainter.h +++ b/Userland/Libraries/LibGfx/StylePainter.h @@ -19,17 +19,17 @@ enum class ButtonStyle { Coolbar, Tray, }; -enum class FrameShadow { - Plain, - Raised, - Sunken -}; -enum class FrameShape { + +enum class FrameStyle { NoFrame, - Box, - Container, - Panel, Window, + Plain, + RaisedBox, + SunkenBox, + RaisedContainer, + SunkenContainer, + RaisedPanel, + SunkenPanel, }; // FIXME: should this be in its own header? @@ -39,7 +39,7 @@ 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) = 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_frame(Painter&, IntRect const&, Palette const&, FrameShape, FrameShadow, int thickness, bool skip_vertical_lines = false) = 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; virtual void paint_radio_button(Painter&, IntRect const&, Palette const&, bool is_checked, bool is_being_pressed) = 0; @@ -58,7 +58,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_frame(Painter&, IntRect const&, Palette const&, FrameShape, FrameShadow, int thickness, bool skip_vertical_lines = false); + 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); static void paint_radio_button(Painter&, IntRect const&, Palette const&, bool is_checked, bool is_being_pressed); diff --git a/Userland/Libraries/LibWeb/Painting/ImagePaintable.cpp b/Userland/Libraries/LibWeb/Painting/ImagePaintable.cpp index 01c084a8f2..f9e9841ad5 100644 --- a/Userland/Libraries/LibWeb/Painting/ImagePaintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/ImagePaintable.cpp @@ -44,7 +44,7 @@ void ImagePaintable::paint(PaintContext& context, PaintPhase phase) const auto& image_element = verify_cast<HTML::HTMLImageElement>(*dom_node()); auto enclosing_rect = context.enclosing_device_rect(absolute_rect()).to_type<int>(); context.painter().set_font(Platform::FontPlugin::the().default_font()); - Gfx::StylePainter::paint_frame(context.painter(), enclosing_rect, context.palette(), Gfx::FrameShape::Container, Gfx::FrameShadow::Sunken, 2); + Gfx::StylePainter::paint_frame(context.painter(), enclosing_rect, context.palette(), Gfx::FrameStyle::SunkenContainer); auto alt = image_element.alt(); if (alt.is_empty()) alt = image_element.src(); diff --git a/Userland/Libraries/LibWeb/Painting/ProgressPaintable.cpp b/Userland/Libraries/LibWeb/Painting/ProgressPaintable.cpp index dc97977c45..63b2e5719b 100644 --- a/Userland/Libraries/LibWeb/Painting/ProgressPaintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/ProgressPaintable.cpp @@ -36,7 +36,7 @@ void ProgressPaintable::paint(PaintContext& context, PaintPhase phase) const Gfx::StylePainter::paint_progressbar(context.painter(), progress_rect.shrunken(frame_thickness, frame_thickness).to_type<int>(), context.palette(), 0, round_to<int>(layout_box().dom_node().max()), round_to<int>(layout_box().dom_node().value()), ""sv); - Gfx::StylePainter::paint_frame(context.painter(), progress_rect.to_type<int>(), context.palette(), Gfx::FrameShape::Box, Gfx::FrameShadow::Raised, frame_thickness.value()); + Gfx::StylePainter::paint_frame(context.painter(), progress_rect.to_type<int>(), context.palette(), Gfx::FrameStyle::RaisedBox); } } diff --git a/Userland/Services/Taskbar/ClockWidget.cpp b/Userland/Services/Taskbar/ClockWidget.cpp index 1241c7f9b3..bbc37136f9 100644 --- a/Userland/Services/Taskbar/ClockWidget.cpp +++ b/Userland/Services/Taskbar/ClockWidget.cpp @@ -20,9 +20,7 @@ namespace Taskbar { ClockWidget::ClockWidget() { - set_frame_shape(Gfx::FrameShape::Box); - set_frame_shadow(Gfx::FrameShadow::Sunken); - set_frame_thickness(1); + set_frame_style(Gfx::FrameStyle::SunkenPanel); update_format(Config::read_string("Taskbar"sv, "Clock"sv, "TimeFormat"sv, "%T"sv)); @@ -44,7 +42,7 @@ ClockWidget::ClockWidget() auto root_container = m_calendar_window->set_main_widget<GUI::Frame>().release_value_but_fixme_should_propagate_errors(); root_container->set_fill_with_background_color(true); root_container->set_layout<GUI::VerticalBoxLayout>(GUI::Margins { 2, 0 }, 0); - root_container->set_frame_shape(Gfx::FrameShape::Window); + root_container->set_frame_style(Gfx::FrameStyle::Window); auto& navigation_container = root_container->add<GUI::Widget>(); navigation_container.set_fixed_height(24); diff --git a/Userland/Services/Taskbar/QuickLaunchWidget.cpp b/Userland/Services/Taskbar/QuickLaunchWidget.cpp index fb331fc4ab..090b39a81d 100644 --- a/Userland/Services/Taskbar/QuickLaunchWidget.cpp +++ b/Userland/Services/Taskbar/QuickLaunchWidget.cpp @@ -106,7 +106,7 @@ QuickLaunchWidget::QuickLaunchWidget() { set_shrink_to_fit(true); set_layout<GUI::HorizontalBoxLayout>(GUI::Margins {}, 0); - set_frame_thickness(0); + set_frame_style(Gfx::FrameStyle::NoFrame); set_fixed_height(24); } diff --git a/Userland/Services/Taskbar/TaskbarWindow.cpp b/Userland/Services/Taskbar/TaskbarWindow.cpp index 0663e6af87..428176a643 100644 --- a/Userland/Services/Taskbar/TaskbarWindow.cpp +++ b/Userland/Services/Taskbar/TaskbarWindow.cpp @@ -84,9 +84,7 @@ ErrorOr<void> TaskbarWindow::populate_taskbar() m_default_icon = TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/window.png"sv)); m_applet_area_container = TRY(main_widget->try_add<GUI::Frame>()); - m_applet_area_container->set_frame_thickness(1); - m_applet_area_container->set_frame_shape(Gfx::FrameShape::Box); - m_applet_area_container->set_frame_shadow(Gfx::FrameShadow::Sunken); + m_applet_area_container->set_frame_style(Gfx::FrameStyle::SunkenPanel); m_clock_widget = TRY(main_widget->try_add<Taskbar::ClockWidget>()); diff --git a/Userland/Services/WindowServer/WindowSwitcher.cpp b/Userland/Services/WindowServer/WindowSwitcher.cpp index 7cf11923b7..bbeeee594b 100644 --- a/Userland/Services/WindowServer/WindowSwitcher.cpp +++ b/Userland/Services/WindowServer/WindowSwitcher.cpp @@ -191,7 +191,7 @@ void WindowSwitcher::draw() rect_text_color = palette.selection_text().with_alpha(0xcc); } else { if (static_cast<int>(index) == m_hovered_index) - Gfx::StylePainter::paint_frame(painter, item_rect, palette, Gfx::FrameShape::Panel, Gfx::FrameShadow::Raised, 2); + Gfx::StylePainter::paint_frame(painter, item_rect, palette, Gfx::FrameStyle::RaisedPanel); text_color = Color::White; rect_text_color = Color(Color::White).with_alpha(0xcc); } |