mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
LibGUI: Store NumericInput value as an i64
Moar range = moar better. I'm hoping to use this for a size_t value later, so this almost covers that.
This commit is contained in:
parent
ea31c11aff
commit
4b96136803
|
@ -281,7 +281,7 @@ void PDFViewerWidget::initialize_toolbar(GUI::Toolbar& toolbar)
|
|||
m_page_text_box->set_fixed_width(30);
|
||||
m_page_text_box->set_min_number(1);
|
||||
|
||||
m_page_text_box->on_number_changed = [&](i32 number) {
|
||||
m_page_text_box->on_number_changed = [&](i64 number) {
|
||||
auto page_count = m_viewer->document()->get_page_count();
|
||||
auto new_page_number = static_cast<u32>(number);
|
||||
VERIFY(new_page_number >= 1 && new_page_number <= page_count);
|
||||
|
|
|
@ -55,14 +55,14 @@ NumericInput::NumericInput()
|
|||
on_escape_pressed = [&] { on_focus_lost(); };
|
||||
}
|
||||
|
||||
void NumericInput::set_min_number(i32 number)
|
||||
void NumericInput::set_min_number(i64 number)
|
||||
{
|
||||
m_min_number = number;
|
||||
if (m_current_number < number)
|
||||
set_current_number(number);
|
||||
}
|
||||
|
||||
void NumericInput::set_max_number(i32 number)
|
||||
void NumericInput::set_max_number(i64 number)
|
||||
{
|
||||
m_max_number = number;
|
||||
if (m_current_number > number)
|
||||
|
@ -79,7 +79,7 @@ void NumericInput::on_focus_lost()
|
|||
on_number_changed(m_current_number);
|
||||
}
|
||||
|
||||
void NumericInput::set_current_number(i32 number, GUI::AllowCallback allow_callback)
|
||||
void NumericInput::set_current_number(i64 number, GUI::AllowCallback allow_callback)
|
||||
{
|
||||
if (number == m_current_number)
|
||||
return;
|
||||
|
|
|
@ -16,20 +16,20 @@ class NumericInput final : public GUI::TextBox {
|
|||
public:
|
||||
virtual ~NumericInput() override = default;
|
||||
|
||||
Function<void(i32)> on_number_changed;
|
||||
Function<void(i64)> on_number_changed;
|
||||
|
||||
void set_min_number(i32 number);
|
||||
void set_max_number(i32 number);
|
||||
void set_current_number(i32 number, GUI::AllowCallback allow_callback = GUI::AllowCallback::Yes);
|
||||
void set_min_number(i64 number);
|
||||
void set_max_number(i64 number);
|
||||
void set_current_number(i64 number, GUI::AllowCallback allow_callback = GUI::AllowCallback::Yes);
|
||||
|
||||
private:
|
||||
NumericInput();
|
||||
void on_focus_lost();
|
||||
|
||||
bool m_needs_text_reset { false };
|
||||
i32 m_current_number { 0 };
|
||||
i32 m_min_number { NumericLimits<i32>::min() };
|
||||
i32 m_max_number { NumericLimits<i32>::max() };
|
||||
i64 m_current_number { 0 };
|
||||
i64 m_min_number { NumericLimits<i64>::min() };
|
||||
i64 m_max_number { NumericLimits<i64>::max() };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue