mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:27:46 +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
|
@ -15,7 +15,7 @@ InterruptsWidget::InterruptsWidget()
|
|||
{
|
||||
on_first_show = [this](auto&) {
|
||||
set_layout<GUI::VerticalBoxLayout>();
|
||||
layout()->set_margins({ 4, 4, 4, 4 });
|
||||
layout()->set_margins(4);
|
||||
|
||||
Vector<GUI::JsonArrayModel::FieldSpec> interrupts_field;
|
||||
interrupts_field.empend("interrupt_line", "Line", Gfx::TextAlignment::CenterRight);
|
||||
|
|
|
@ -31,7 +31,7 @@ MemoryStatsWidget::MemoryStatsWidget(GraphWidget& graph)
|
|||
set_fixed_height(110);
|
||||
|
||||
set_layout<GUI::VerticalBoxLayout>();
|
||||
layout()->set_margins({ 8, 0, 0, 0 });
|
||||
layout()->set_margins({ 8, 0, 0 });
|
||||
layout()->set_spacing(3);
|
||||
|
||||
auto build_widgets_for_label = [this](const String& description) -> RefPtr<GUI::Label> {
|
||||
|
|
|
@ -16,7 +16,7 @@ NetworkStatisticsWidget::NetworkStatisticsWidget()
|
|||
{
|
||||
on_first_show = [this](auto&) {
|
||||
set_layout<GUI::VerticalBoxLayout>();
|
||||
layout()->set_margins({ 4, 4, 4, 4 });
|
||||
layout()->set_margins(4);
|
||||
set_fill_with_background_color(true);
|
||||
|
||||
m_network_connected_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/network-connected.png");
|
||||
|
@ -32,7 +32,7 @@ NetworkStatisticsWidget::NetworkStatisticsWidget()
|
|||
|
||||
auto& adapters_group_box = add<GUI::GroupBox>("Adapters");
|
||||
adapters_group_box.set_layout<GUI::VerticalBoxLayout>();
|
||||
adapters_group_box.layout()->set_margins({ 16, 6, 6, 6 });
|
||||
adapters_group_box.layout()->set_margins({ 16, 6, 6 });
|
||||
adapters_group_box.set_fixed_height(120);
|
||||
|
||||
m_adapter_table_view = adapters_group_box.add<GUI::TableView>();
|
||||
|
@ -69,7 +69,7 @@ NetworkStatisticsWidget::NetworkStatisticsWidget()
|
|||
|
||||
auto& tcp_sockets_group_box = add<GUI::GroupBox>("TCP Sockets");
|
||||
tcp_sockets_group_box.set_layout<GUI::VerticalBoxLayout>();
|
||||
tcp_sockets_group_box.layout()->set_margins({ 16, 6, 6, 6 });
|
||||
tcp_sockets_group_box.layout()->set_margins({ 16, 6, 6 });
|
||||
|
||||
m_tcp_socket_table_view = tcp_sockets_group_box.add<GUI::TableView>();
|
||||
|
||||
|
@ -90,7 +90,7 @@ NetworkStatisticsWidget::NetworkStatisticsWidget()
|
|||
|
||||
auto& udp_sockets_group_box = add<GUI::GroupBox>("UDP Sockets");
|
||||
udp_sockets_group_box.set_layout<GUI::VerticalBoxLayout>();
|
||||
udp_sockets_group_box.layout()->set_margins({ 16, 6, 6, 6 });
|
||||
udp_sockets_group_box.layout()->set_margins({ 16, 6, 6 });
|
||||
|
||||
m_udp_socket_table_view = udp_sockets_group_box.add<GUI::TableView>();
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
ProcessFileDescriptorMapWidget::ProcessFileDescriptorMapWidget()
|
||||
{
|
||||
set_layout<GUI::VerticalBoxLayout>();
|
||||
layout()->set_margins({ 4, 4, 4, 4 });
|
||||
layout()->set_margins(4);
|
||||
m_table_view = add<GUI::TableView>();
|
||||
|
||||
Vector<GUI::JsonArrayModel::FieldSpec> pid_fds_fields;
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
ProcessMemoryMapWidget::ProcessMemoryMapWidget()
|
||||
{
|
||||
set_layout<GUI::VerticalBoxLayout>();
|
||||
layout()->set_margins({ 4, 4, 4, 4 });
|
||||
layout()->set_margins(4);
|
||||
m_table_view = add<GUI::TableView>();
|
||||
Vector<GUI::JsonArrayModel::FieldSpec> pid_vm_fields;
|
||||
pid_vm_fields.empend(
|
||||
|
|
|
@ -84,7 +84,7 @@ private:
|
|||
ProcessStateWidget::ProcessStateWidget(pid_t pid)
|
||||
{
|
||||
set_layout<GUI::VerticalBoxLayout>();
|
||||
layout()->set_margins({ 4, 4, 4, 4 });
|
||||
layout()->set_margins(4);
|
||||
m_table_view = add<GUI::TableView>();
|
||||
m_table_view->set_model(adopt_ref(*new ProcessStateModel(ProcessModel::the(), pid)));
|
||||
m_table_view->column_header().set_visible(false);
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
ProcessUnveiledPathsWidget::ProcessUnveiledPathsWidget()
|
||||
{
|
||||
set_layout<GUI::VerticalBoxLayout>();
|
||||
layout()->set_margins({ 4, 4, 4, 4 });
|
||||
layout()->set_margins(4);
|
||||
m_table_view = add<GUI::TableView>();
|
||||
|
||||
Vector<GUI::JsonArrayModel::FieldSpec> pid_unveil_fields;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
ThreadStackWidget::ThreadStackWidget()
|
||||
{
|
||||
set_layout<GUI::VerticalBoxLayout>();
|
||||
layout()->set_margins({ 4, 4, 4, 4 });
|
||||
layout()->set_margins(4);
|
||||
m_stack_editor = add<GUI::TextEditor>();
|
||||
m_stack_editor->set_mode(GUI::TextEditor::ReadOnly);
|
||||
m_stack_editor->set_text("Symbolicating...");
|
||||
|
|
|
@ -179,7 +179,7 @@ int main(int argc, char** argv)
|
|||
|
||||
auto& tabwidget_container = main_widget.add<GUI::Widget>();
|
||||
tabwidget_container.set_layout<GUI::VerticalBoxLayout>();
|
||||
tabwidget_container.layout()->set_margins({ 0, 4, 4, 4 });
|
||||
tabwidget_container.layout()->set_margins({ 0, 4, 4 });
|
||||
auto& tabwidget = tabwidget_container.add<GUI::TabWidget>();
|
||||
|
||||
statusbar = main_widget.add<GUI::Statusbar>(3);
|
||||
|
@ -214,7 +214,7 @@ int main(int argc, char** argv)
|
|||
tabwidget.add_widget("Interrupts", interrupts_widget);
|
||||
|
||||
process_table_container.set_layout<GUI::VerticalBoxLayout>();
|
||||
process_table_container.layout()->set_margins({ 4, 4, 4, 4 });
|
||||
process_table_container.layout()->set_margins(4);
|
||||
process_table_container.layout()->set_spacing(0);
|
||||
|
||||
auto& process_table_view = process_table_container.add<GUI::TableView>();
|
||||
|
@ -434,7 +434,7 @@ NonnullRefPtr<GUI::Window> build_process_window(pid_t pid)
|
|||
auto& hero_container = main_widget.add<GUI::Widget>();
|
||||
hero_container.set_shrink_to_fit(true);
|
||||
hero_container.set_layout<GUI::HorizontalBoxLayout>();
|
||||
hero_container.layout()->set_margins({ 4, 4, 4, 4 });
|
||||
hero_container.layout()->set_margins(4);
|
||||
hero_container.layout()->set_spacing(8);
|
||||
|
||||
auto& icon_label = hero_container.add<GUI::Label>();
|
||||
|
@ -493,7 +493,7 @@ NonnullRefPtr<GUI::Widget> build_file_systems_tab()
|
|||
|
||||
fs_widget->on_first_show = [](GUI::LazyWidget& self) {
|
||||
self.set_layout<GUI::VerticalBoxLayout>();
|
||||
self.layout()->set_margins({ 4, 4, 4, 4 });
|
||||
self.layout()->set_margins(4);
|
||||
auto& fs_table_view = self.add<GUI::TableView>();
|
||||
|
||||
Vector<GUI::JsonArrayModel::FieldSpec> df_fields;
|
||||
|
@ -589,7 +589,7 @@ NonnullRefPtr<GUI::Widget> build_pci_devices_tab()
|
|||
|
||||
pci_widget->on_first_show = [](GUI::LazyWidget& self) {
|
||||
self.set_layout<GUI::VerticalBoxLayout>();
|
||||
self.layout()->set_margins({ 4, 4, 4, 4 });
|
||||
self.layout()->set_margins(4);
|
||||
auto& pci_table_view = self.add<GUI::TableView>();
|
||||
|
||||
auto db = PCIDB::Database::open();
|
||||
|
@ -648,7 +648,7 @@ NonnullRefPtr<GUI::Widget> build_devices_tab()
|
|||
|
||||
devices_widget->on_first_show = [](GUI::LazyWidget& self) {
|
||||
self.set_layout<GUI::VerticalBoxLayout>();
|
||||
self.layout()->set_margins({ 4, 4, 4, 4 });
|
||||
self.layout()->set_margins(4);
|
||||
|
||||
auto& devices_table_view = self.add<GUI::TableView>();
|
||||
devices_table_view.set_model(GUI::SortingProxyModel::create(DevicesModel::create()));
|
||||
|
@ -665,11 +665,11 @@ NonnullRefPtr<GUI::Widget> build_graphs_tab()
|
|||
graphs_container->set_fill_with_background_color(true);
|
||||
graphs_container->set_background_role(ColorRole::Button);
|
||||
graphs_container->set_layout<GUI::VerticalBoxLayout>();
|
||||
graphs_container->layout()->set_margins({ 4, 4, 4, 4 });
|
||||
graphs_container->layout()->set_margins(4);
|
||||
|
||||
auto& cpu_graph_group_box = graphs_container->add<GUI::GroupBox>("CPU usage");
|
||||
cpu_graph_group_box.set_layout<GUI::HorizontalBoxLayout>();
|
||||
cpu_graph_group_box.layout()->set_margins({ 16, 6, 6, 6 });
|
||||
cpu_graph_group_box.layout()->set_margins({ 16, 6, 6 });
|
||||
cpu_graph_group_box.set_fixed_height(120);
|
||||
Vector<GraphWidget&> cpu_graphs;
|
||||
for (size_t i = 0; i < ProcessModel::the().cpus().size(); i++) {
|
||||
|
@ -701,7 +701,7 @@ NonnullRefPtr<GUI::Widget> build_graphs_tab()
|
|||
|
||||
auto& memory_graph_group_box = graphs_container->add<GUI::GroupBox>("Memory usage");
|
||||
memory_graph_group_box.set_layout<GUI::VerticalBoxLayout>();
|
||||
memory_graph_group_box.layout()->set_margins({ 16, 6, 6, 6 });
|
||||
memory_graph_group_box.layout()->set_margins({ 16, 6, 6 });
|
||||
memory_graph_group_box.set_fixed_height(120);
|
||||
auto& memory_graph = memory_graph_group_box.add<GraphWidget>();
|
||||
memory_graph.set_stack_values(true);
|
||||
|
@ -734,7 +734,7 @@ NonnullRefPtr<GUI::Widget> build_processors_tab()
|
|||
|
||||
processors_widget->on_first_show = [](GUI::LazyWidget& self) {
|
||||
self.set_layout<GUI::VerticalBoxLayout>();
|
||||
self.layout()->set_margins({ 4, 4, 4, 4 });
|
||||
self.layout()->set_margins(4);
|
||||
|
||||
Vector<GUI::JsonArrayModel::FieldSpec> processors_field;
|
||||
processors_field.empend("processor", "Processor", Gfx::TextAlignment::CenterRight);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue