Skip to content

Commit

Permalink
LibGUI+Applications: Default the SpinBox min/max to the full int range
Browse files Browse the repository at this point in the history
By default, a SpinBox's value should be unlimited, (or as close as we
can get to that,) and then the GML or code can impose a limit if
needed. This saves the developer from entering an arbitrary "big" max
value when they want the value to have no maximum.

I've audited the use of SpinBox and added `min: 0`, and removed a `max`,
where appropriate. All existing SpinBoxes constructed in code have a
range set explicitly as far as I can tell.
  • Loading branch information
AtkinsSJ committed Jan 14, 2024
1 parent cbd28c9 commit e0fd5be
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
1 change: 0 additions & 1 deletion Userland/Applications/Calendar/AddEventDialog.gml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@
name: "duration_hour"
fixed_size: [50, 20]
min: 0
max: 999999
}

@GUI::SpinBox {
Expand Down
1 change: 1 addition & 0 deletions Userland/Applications/FontEditor/FontEditorWindow.gml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
@GUI::SpinBox {
name: "glyph_editor_width_spinbox"
preferred_width: "fit"
min: 0
}

@GUI::CheckBox {
Expand Down
1 change: 1 addition & 0 deletions Userland/Libraries/LibGUI/FontPickerDialog.gml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

@GUI::SpinBox {
name: "size_spin_box"
min: 0
}

@GUI::ListView {
Expand Down
4 changes: 2 additions & 2 deletions Userland/Libraries/LibGUI/SpinBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class SpinBox : public Widget {
RefPtr<Button> m_increment_button;
RefPtr<Button> m_decrement_button;

int m_min { 0 };
int m_max { 100 };
int m_min { NumericLimits<int>::min() };
int m_max { NumericLimits<int>::max() };
int m_value { 0 };
};

Expand Down

0 comments on commit e0fd5be

Please sign in to comment.