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.
This commit is contained in:
thankyouverycool 2023-04-29 16:47:52 -04:00 committed by Andreas Kling
parent 4c9933bfb7
commit f7e034d4b2
58 changed files with 148 additions and 208 deletions

View file

@ -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");

View file

@ -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);

View file

@ -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);
}
}
}

View file

@ -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>();

View file

@ -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));

View file

@ -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"

View file

@ -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));

View file

@ -63,9 +63,7 @@
}
@GUI::Label {
shape: "Container"
thickness: 2
shadow: "Sunken"
style: "SunkenContainer"
name: "clock_preview"
text: "12:34:56"
}

View file

@ -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"
}

View file

@ -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);

View file

@ -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();

View file

@ -8,9 +8,7 @@
layout: @GUI::VerticalBoxLayout {
margins: [4]
}
shape: "Box"
shadow: "Sunken"
thickness: 2
style: "SunkenBox"
@GUI::Label {
name: "preview_label"

View file

@ -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

View file

@ -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);

View file

@ -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)

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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"
}

View file

@ -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()

View file

@ -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
}

View file

@ -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

View file

@ -35,10 +35,8 @@
@GUI::HorizontalSeparator {}
@GUI::Frame {
shape: "Panel"
shadow: "Sunken"
style: "SunkenPanel"
preferred_height: "fit"
thickness: 1
layout: @GUI::VerticalBoxLayout {
margins: [1]
}

View file

@ -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());

View file

@ -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;

View file

@ -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
}
}

View file

@ -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);

View file

@ -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();

View file

@ -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)

View file

@ -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>();

View file

@ -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);
}

View file

@ -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) {

View file

@ -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());

View file

@ -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);

View file

@ -1,5 +1,5 @@
@GUI::Frame {
shape: "Window"
style: "Window"
fill_with_background_color: true
layout: @GUI::VerticalBoxLayout {
margins: [4]

View file

@ -16,40 +16,51 @@ namespace GUI {
Frame::Frame()
{
set_frame_thickness(2);
set_frame_shape(Gfx::FrameShape::Container);
set_frame_shadow(Gfx::FrameShadow::Sunken);
set_frame_style(Gfx::FrameStyle::SunkenContainer);
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" });
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

View file

@ -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 };
};
}

View file

@ -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() };

View file

@ -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);

View file

@ -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);

View file

@ -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();

View file

@ -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

View file

@ -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

View file

@ -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);

View file

@ -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); }

View file

@ -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) {

View file

@ -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);
}

View file

@ -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) {

View file

@ -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.

View file

@ -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;

View file

@ -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)

View file

@ -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);

View file

@ -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();

View file

@ -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);
}
}

View file

@ -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);

View file

@ -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);
}

View file

@ -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>());

View file

@ -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);
}