mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:57:45 +00:00
Userland+LibGUI: Add shorthand versions of the Margins constructor
This allows for typing [8] instead of [8, 8, 8, 8] to specify the same margin on all edges, for example. The constructors follow CSS' style of specifying margins. The added constructors are: - Margins(int all): Sets the same margin on all edges. - Margins(int vertical, int horizontal): Sets the first argument to top and bottom margins, and the second argument to left and right margins. - Margins(int top, int vertical, int bottom): Sets the first argument to the top margin, the second argument to the left and right margins, and the third argument to the bottom margin.
This commit is contained in:
parent
9c9a5c55cb
commit
e11d177618
101 changed files with 232 additions and 201 deletions
|
@ -46,7 +46,7 @@ CellTypeDialog::CellTypeDialog(const Vector<Position>& positions, Sheet& sheet,
|
|||
resize(285, 360);
|
||||
|
||||
auto& main_widget = set_main_widget<GUI::Widget>();
|
||||
main_widget.set_layout<GUI::VerticalBoxLayout>().set_margins({ 4, 4, 4, 4 });
|
||||
main_widget.set_layout<GUI::VerticalBoxLayout>().set_margins(4);
|
||||
main_widget.set_fill_with_background_color(true);
|
||||
|
||||
auto& tab_widget = main_widget.add<GUI::TabWidget>();
|
||||
|
@ -130,7 +130,7 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, const Vector<Position>& po
|
|||
}
|
||||
|
||||
auto& type_tab = tabs.add_tab<GUI::Widget>("Type");
|
||||
type_tab.set_layout<GUI::HorizontalBoxLayout>().set_margins({ 4, 4, 4, 4 });
|
||||
type_tab.set_layout<GUI::HorizontalBoxLayout>().set_margins(4);
|
||||
{
|
||||
auto& left_side = type_tab.add<GUI::Widget>();
|
||||
left_side.set_layout<GUI::VerticalBoxLayout>();
|
||||
|
@ -192,14 +192,14 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, const Vector<Position>& po
|
|||
}
|
||||
|
||||
auto& alignment_tab = tabs.add_tab<GUI::Widget>("Alignment");
|
||||
alignment_tab.set_layout<GUI::VerticalBoxLayout>().set_margins({ 4, 4, 4, 4 });
|
||||
alignment_tab.set_layout<GUI::VerticalBoxLayout>().set_margins(4);
|
||||
{
|
||||
// FIXME: Frame?
|
||||
// Horizontal alignment
|
||||
{
|
||||
auto& horizontal_alignment_selection_container = alignment_tab.add<GUI::Widget>();
|
||||
horizontal_alignment_selection_container.set_layout<GUI::HorizontalBoxLayout>();
|
||||
horizontal_alignment_selection_container.layout()->set_margins({ 4, 0, 0, 0 });
|
||||
horizontal_alignment_selection_container.layout()->set_margins({ 4, 0, 0 });
|
||||
horizontal_alignment_selection_container.set_fixed_height(22);
|
||||
|
||||
auto& horizontal_alignment_label = horizontal_alignment_selection_container.add<GUI::Label>();
|
||||
|
@ -231,7 +231,7 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, const Vector<Position>& po
|
|||
{
|
||||
auto& vertical_alignment_container = alignment_tab.add<GUI::Widget>();
|
||||
vertical_alignment_container.set_layout<GUI::HorizontalBoxLayout>();
|
||||
vertical_alignment_container.layout()->set_margins({ 0, 4, 0, 0 });
|
||||
vertical_alignment_container.layout()->set_margins({ 4, 0, 0 });
|
||||
vertical_alignment_container.set_fixed_height(22);
|
||||
|
||||
auto& vertical_alignment_label = vertical_alignment_container.add<GUI::Label>();
|
||||
|
@ -261,7 +261,7 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, const Vector<Position>& po
|
|||
}
|
||||
|
||||
auto& colors_tab = tabs.add_tab<GUI::Widget>("Color");
|
||||
colors_tab.set_layout<GUI::VerticalBoxLayout>().set_margins({ 4, 4, 4, 4 });
|
||||
colors_tab.set_layout<GUI::VerticalBoxLayout>().set_margins(4);
|
||||
{
|
||||
// Static formatting
|
||||
{
|
||||
|
@ -273,7 +273,7 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, const Vector<Position>& po
|
|||
// FIXME: Somehow allow unsetting these.
|
||||
auto& foreground_container = static_formatting_container.add<GUI::Widget>();
|
||||
foreground_container.set_layout<GUI::HorizontalBoxLayout>();
|
||||
foreground_container.layout()->set_margins({ 4, 0, 0, 0 });
|
||||
foreground_container.layout()->set_margins({ 4, 0, 0 });
|
||||
foreground_container.set_shrink_to_fit(true);
|
||||
|
||||
auto& foreground_label = foreground_container.add<GUI::Label>();
|
||||
|
@ -293,7 +293,7 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, const Vector<Position>& po
|
|||
// FIXME: Somehow allow unsetting these.
|
||||
auto& background_container = static_formatting_container.add<GUI::Widget>();
|
||||
background_container.set_layout<GUI::HorizontalBoxLayout>();
|
||||
background_container.layout()->set_margins({ 4, 0, 0, 0 });
|
||||
background_container.layout()->set_margins({ 4, 0, 0 });
|
||||
background_container.set_shrink_to_fit(true);
|
||||
|
||||
auto& background_label = background_container.add<GUI::Label>();
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
fill_with_background_color: true
|
||||
|
||||
layout: @GUI::VerticalBoxLayout {
|
||||
margins: [4, 4, 4, 4]
|
||||
margins: [4]
|
||||
spacing: 4
|
||||
}
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ SpreadsheetView::SpreadsheetView(Sheet& sheet)
|
|||
: m_sheet(sheet)
|
||||
, m_sheet_model(SheetModel::create(*m_sheet))
|
||||
{
|
||||
set_layout<GUI::VerticalBoxLayout>().set_margins({ 2, 2, 2, 2 });
|
||||
set_layout<GUI::VerticalBoxLayout>().set_margins(2);
|
||||
m_table_view = add<InfinitelyScrollableTableView>();
|
||||
m_table_view->set_grid_style(GUI::TableView::GridStyle::Both);
|
||||
m_table_view->set_selection_behavior(GUI::AbstractView::SelectionBehavior::SelectItems);
|
||||
|
|
|
@ -26,7 +26,7 @@ SpreadsheetWidget::SpreadsheetWidget(NonnullRefPtrVector<Sheet>&& sheets, bool s
|
|||
: m_workbook(make<Workbook>(move(sheets)))
|
||||
{
|
||||
set_fill_with_background_color(true);
|
||||
set_layout<GUI::VerticalBoxLayout>().set_margins({ 2, 2, 2, 2 });
|
||||
set_layout<GUI::VerticalBoxLayout>().set_margins(2);
|
||||
auto& container = add<GUI::VerticalSplitter>();
|
||||
|
||||
auto& top_bar = container.add<GUI::Frame>();
|
||||
|
@ -71,7 +71,7 @@ SpreadsheetWidget::SpreadsheetWidget(NonnullRefPtrVector<Sheet>&& sheets, bool s
|
|||
m_inline_documentation_window->set_resizable(false);
|
||||
auto& inline_widget = m_inline_documentation_window->set_main_widget<GUI::Frame>();
|
||||
inline_widget.set_fill_with_background_color(true);
|
||||
inline_widget.set_layout<GUI::VerticalBoxLayout>().set_margins({ 4, 4, 4, 4 });
|
||||
inline_widget.set_layout<GUI::VerticalBoxLayout>().set_margins(4);
|
||||
inline_widget.set_frame_shape(Gfx::FrameShape::Box);
|
||||
m_inline_documentation_label = inline_widget.add<GUI::Label>();
|
||||
m_inline_documentation_label->set_fill_with_background_color(true);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
@GUI::Widget {
|
||||
layout: @GUI::VerticalBoxLayout {
|
||||
margins: [20, 20, 20, 20]
|
||||
margins: [20]
|
||||
}
|
||||
|
||||
@GUI::HorizontalSplitter {
|
||||
|
@ -19,7 +19,7 @@
|
|||
|
||||
layout: @GUI::VerticalBoxLayout {
|
||||
// FIXME: This is working around the fact that group boxes don't allocate space for their title and border!
|
||||
margins: [20, 10, 10, 10]
|
||||
margins: [20, 10, 10]
|
||||
}
|
||||
|
||||
@GUI::RadioButton {
|
||||
|
@ -70,7 +70,7 @@
|
|||
|
||||
layout: @GUI::VerticalBoxLayout {
|
||||
// FIXME: This is working around the fact that group boxes don't allocate space for their title and border!
|
||||
margins: [20, 10, 10, 10]
|
||||
margins: [20, 10, 10]
|
||||
}
|
||||
|
||||
@GUI::RadioButton {
|
||||
|
@ -152,7 +152,7 @@
|
|||
|
||||
layout: @GUI::VerticalBoxLayout {
|
||||
// FIXME: This is working around the fact that group boxes don't allocate space for their title and border!
|
||||
margins: [20, 10, 10, 10]
|
||||
margins: [20, 10, 10]
|
||||
}
|
||||
|
||||
@GUI::TextEditor {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
@GUI::Widget {
|
||||
layout: @GUI::VerticalBoxLayout {
|
||||
margins: [20, 20, 20, 20]
|
||||
margins: [20]
|
||||
}
|
||||
|
||||
@GUI::HorizontalSplitter {
|
||||
|
@ -19,7 +19,7 @@
|
|||
|
||||
layout: @GUI::VerticalBoxLayout {
|
||||
// FIXME: This is working around the fact that group boxes don't allocate space for their title and border!
|
||||
margins: [20, 10, 10, 10]
|
||||
margins: [20, 10, 10]
|
||||
}
|
||||
|
||||
@GUI::RadioButton {
|
||||
|
@ -70,7 +70,7 @@
|
|||
|
||||
layout: @GUI::VerticalBoxLayout {
|
||||
// FIXME: This is working around the fact that group boxes don't allocate space for their title and border!
|
||||
margins: [20, 10, 10, 10]
|
||||
margins: [20, 10, 10]
|
||||
}
|
||||
|
||||
@GUI::RadioButton {
|
||||
|
@ -133,7 +133,7 @@
|
|||
fixed_height: 40
|
||||
|
||||
layout: @GUI::VerticalBoxLayout {
|
||||
margins: [6, 6, 0, 6]
|
||||
margins: [6, 6, 0]
|
||||
}
|
||||
|
||||
@GUI::Widget {
|
||||
|
@ -165,7 +165,7 @@
|
|||
|
||||
layout: @GUI::VerticalBoxLayout {
|
||||
// FIXME: This is working around the fact that group boxes don't allocate space for their title and border!
|
||||
margins: [20, 10, 10, 10]
|
||||
margins: [20, 10, 10]
|
||||
}
|
||||
|
||||
@GUI::StackWidget {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
name: "select_format"
|
||||
|
||||
layout: @GUI::VerticalBoxLayout {
|
||||
margins: [20, 20, 20, 20]
|
||||
margins: [20]
|
||||
}
|
||||
|
||||
@GUI::Label {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue