summaryrefslogtreecommitdiff
path: root/Applications/Spreadsheet
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-01-04 18:42:50 +0100
committerAndreas Kling <kling@serenityos.org>2021-01-04 18:42:50 +0100
commit7124e6371140ec4ac1480000bde12aceda8a5145 (patch)
treea850951d3311b2f43b4ab1ff6d03d854178b268a /Applications/Spreadsheet
parentfa88a265546c04681d7c9bb0eb2bb27b657fbd83 (diff)
downloadserenity-7124e6371140ec4ac1480000bde12aceda8a5145.zip
Spreadsheet: Tidy up cell formatting dialog a bit
Use some of the recent features in LibGUI to simplify and tidy up the cell formatting interface. The widget layout API's are still not good enough to make this easy, but at least it's getting better.
Diffstat (limited to 'Applications/Spreadsheet')
-rw-r--r--Applications/Spreadsheet/CellTypeDialog.cpp35
-rw-r--r--Applications/Spreadsheet/CondFormatting.gml16
2 files changed, 23 insertions, 28 deletions
diff --git a/Applications/Spreadsheet/CellTypeDialog.cpp b/Applications/Spreadsheet/CellTypeDialog.cpp
index 2c591f8600..b94feab5e5 100644
--- a/Applications/Spreadsheet/CellTypeDialog.cpp
+++ b/Applications/Spreadsheet/CellTypeDialog.cpp
@@ -57,9 +57,9 @@ CellTypeDialog::CellTypeDialog(const Vector<Position>& positions, Sheet& sheet,
StringBuilder builder;
if (positions.size() == 1)
- builder.appendff("Format Cell {}{}", positions.first().column, positions.first().row);
+ builder.appendff("Format cell {}{}", positions.first().column, positions.first().row);
else
- builder.appendff("Format {} Cells", positions.size());
+ builder.appendff("Format {} cells", positions.size());
set_title(builder.string_view());
set_icon(parent->icon());
@@ -73,7 +73,7 @@ CellTypeDialog::CellTypeDialog(const Vector<Position>& positions, Sheet& sheet,
setup_tabs(tab_widget, positions, sheet);
auto& buttonbox = main_widget.add<GUI::Widget>();
- buttonbox.set_fixed_height(20);
+ buttonbox.set_shrink_to_fit(true);
auto& button_layout = buttonbox.set_layout<GUI::HorizontalBoxLayout>();
button_layout.set_spacing(10);
button_layout.add_spacer();
@@ -148,7 +148,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({ 2, 2, 2, 2 });
+ type_tab.set_layout<GUI::HorizontalBoxLayout>().set_margins({ 4, 4, 4, 4 });
{
auto& left_side = type_tab.add<GUI::Widget>();
left_side.set_layout<GUI::VerticalBoxLayout>();
@@ -177,9 +177,6 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, const Vector<Position>& po
if (m_length > -1)
spinbox.set_value(m_length);
- checkbox.set_fixed_height(20);
- spinbox.set_fixed_height(20);
-
checkbox.on_checked = [&](auto checked) {
spinbox.set_enabled(checked);
if (!checked) {
@@ -199,9 +196,6 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, const Vector<Position>& po
editor.set_enabled(!m_format.is_empty());
editor.set_text(m_format);
- checkbox.set_fixed_height(20);
- editor.set_fixed_height(20);
-
checkbox.on_checked = [&](auto checked) {
editor.set_enabled(checked);
if (!checked)
@@ -215,7 +209,7 @@ 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({ 2, 2, 2, 2 });
+ alignment_tab.set_layout<GUI::VerticalBoxLayout>().set_margins({ 4, 4, 4, 4 });
{
// FIXME: Frame?
// Horizontal alignment
@@ -227,10 +221,9 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, const Vector<Position>& po
auto& horizontal_alignment_label = horizontal_alignment_selection_container.add<GUI::Label>();
horizontal_alignment_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
- horizontal_alignment_label.set_text("Horizontal Text Alignment");
+ horizontal_alignment_label.set_text("Horizontal text alignment");
auto& horizontal_combobox = alignment_tab.add<GUI::ComboBox>();
- horizontal_combobox.set_fixed_height(22);
horizontal_combobox.set_only_allow_values_from_model(true);
horizontal_combobox.set_model(*GUI::ItemListModel<String>::create(g_horizontal_alignments));
horizontal_combobox.set_selected_index((int)m_horizontal_alignment);
@@ -260,10 +253,9 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, const Vector<Position>& po
auto& vertical_alignment_label = vertical_alignment_container.add<GUI::Label>();
vertical_alignment_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
- vertical_alignment_label.set_text("Vertical Text Alignment");
+ vertical_alignment_label.set_text("Vertical text alignment");
auto& vertical_combobox = alignment_tab.add<GUI::ComboBox>();
- vertical_combobox.set_fixed_height(22);
vertical_combobox.set_only_allow_values_from_model(true);
vertical_combobox.set_model(*GUI::ItemListModel<String>::create(g_vertical_alignments));
vertical_combobox.set_selected_index((int)m_vertical_alignment);
@@ -286,14 +278,13 @@ 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({ 2, 2, 2, 2 });
+ colors_tab.set_layout<GUI::VerticalBoxLayout>().set_margins({ 4, 4, 4, 4 });
{
// Static formatting
{
auto& static_formatting_container = colors_tab.add<GUI::Widget>();
static_formatting_container.set_layout<GUI::VerticalBoxLayout>();
- static_formatting_container.layout()->set_margins({ 0, 0, 0, 0 });
- static_formatting_container.set_fixed_height(44);
+ static_formatting_container.set_shrink_to_fit(true);
// Foreground
{
@@ -305,10 +296,9 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, const Vector<Position>& po
auto& foreground_label = foreground_container.add<GUI::Label>();
foreground_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
- foreground_label.set_text("Static Foreground Color");
+ foreground_label.set_text("Static foreground color");
auto& foreground_selector = foreground_container.add<GUI::ColorInput>();
- foreground_selector.set_fixed_height(22);
if (m_static_format.foreground_color.has_value())
foreground_selector.set_color(m_static_format.foreground_color.value());
foreground_selector.on_change = [&]() {
@@ -326,10 +316,9 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, const Vector<Position>& po
auto& background_label = background_container.add<GUI::Label>();
background_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
- background_label.set_text("Static Background Color");
+ background_label.set_text("Static background color");
auto& background_selector = background_container.add<GUI::ColorInput>();
- background_selector.set_fixed_height(22);
if (m_static_format.background_color.has_value())
background_selector.set_color(m_static_format.background_color.value());
background_selector.on_change = [&]() {
@@ -339,7 +328,7 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, const Vector<Position>& po
}
}
- auto& conditional_fmt_tab = tabs.add_tab<GUI::Widget>("Conditional Format");
+ auto& conditional_fmt_tab = tabs.add_tab<GUI::Widget>("Conditional format");
conditional_fmt_tab.load_from_gml(cond_fmt_gml);
{
auto& view = *conditional_fmt_tab.find_descendant_of_type_named<Spreadsheet::ConditionsView>("conditions_view");
diff --git a/Applications/Spreadsheet/CondFormatting.gml b/Applications/Spreadsheet/CondFormatting.gml
index 6e3d623270..437b5a1c3d 100644
--- a/Applications/Spreadsheet/CondFormatting.gml
+++ b/Applications/Spreadsheet/CondFormatting.gml
@@ -3,6 +3,7 @@
fill_with_background_color: true
layout: @GUI::VerticalBoxLayout {
+ margins: [4, 4, 4, 4]
spacing: 4
}
@@ -11,24 +12,29 @@
}
@GUI::Widget {
- fixed_height: 20
+ shrink_to_fit: true
layout: @GUI::HorizontalBoxLayout {
spacing: 10
}
+ @GUI::Widget {
+ }
+
@GUI::Button {
name: "add_button"
text: "Add"
- fixed_width: 100
- fixed_height: 20
+ fixed_width: 70
}
@GUI::Button {
name: "remove_button"
text: "Remove"
- fixed_width: 100
- fixed_height: 20
+ fixed_width: 70
}
+
+ @GUI::Widget {
+ }
+
}
}