LibGUI+PDFViewer: Move NumericInput into LibGUI
A text box that is restricted to numbers within a range, is generally useful. Let's make it available for use!
This commit is contained in:
parent
4fd5d450be
commit
ea31c11aff
Notes:
sideshowbarker
2024-07-17 01:21:02 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/ea31c11aff Pull-request: https://github.com/SerenityOS/serenity/pull/22660
7 changed files with 31 additions and 4 deletions
19
Base/usr/share/man/man5/GML/Widget/NumericInput.md
Normal file
19
Base/usr/share/man/man5/GML/Widget/NumericInput.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
## Name
|
||||
|
||||
GML Numeric Input Widget
|
||||
|
||||
## Description
|
||||
|
||||
Defines a GUI text box that only allows integers within a specified range.
|
||||
|
||||
## Synopsis
|
||||
|
||||
`@GUI::NumericInput`
|
||||
|
||||
## Examples
|
||||
|
||||
```gml
|
||||
@GUI::NumericInput {
|
||||
text: "23"
|
||||
}
|
||||
```
|
|
@ -4,7 +4,6 @@ serenity_component(
|
|||
)
|
||||
|
||||
set(SOURCES
|
||||
NumericInput.cpp
|
||||
OutlineModel.cpp
|
||||
PDFViewer.cpp
|
||||
PDFViewerWidget.cpp
|
||||
|
|
|
@ -276,7 +276,7 @@ void PDFViewerWidget::initialize_toolbar(GUI::Toolbar& toolbar)
|
|||
toolbar.add_action(*m_go_to_prev_page_action);
|
||||
toolbar.add_action(*m_go_to_next_page_action);
|
||||
|
||||
m_page_text_box = toolbar.add<NumericInput>();
|
||||
m_page_text_box = toolbar.add<GUI::NumericInput>();
|
||||
m_page_text_box->set_enabled(false);
|
||||
m_page_text_box->set_fixed_width(30);
|
||||
m_page_text_box->set_min_number(1);
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "NumericInput.h"
|
||||
#include "PDFViewer.h"
|
||||
#include "SidebarWidget.h"
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
|
@ -14,6 +13,7 @@
|
|||
#include <LibGUI/Action.h>
|
||||
#include <LibGUI/ActionGroup.h>
|
||||
#include <LibGUI/CheckBox.h>
|
||||
#include <LibGUI/NumericInput.h>
|
||||
#include <LibGUI/Widget.h>
|
||||
|
||||
class PDFViewer;
|
||||
|
@ -40,7 +40,7 @@ private:
|
|||
RefPtr<SidebarWidget> m_sidebar;
|
||||
NonnullRefPtr<PagedErrorsModel> m_paged_errors_model;
|
||||
RefPtr<GUI::TreeView> m_errors_tree_view;
|
||||
RefPtr<NumericInput> m_page_text_box;
|
||||
RefPtr<GUI::NumericInput> m_page_text_box;
|
||||
RefPtr<GUI::Label> m_total_page_label;
|
||||
RefPtr<GUI::Action> m_go_to_prev_page_action;
|
||||
RefPtr<GUI::Action> m_go_to_next_page_action;
|
||||
|
|
|
@ -86,6 +86,7 @@ set(SOURCES
|
|||
MouseTracker.cpp
|
||||
MultiView.cpp
|
||||
Notification.cpp
|
||||
NumericInput.cpp
|
||||
Object.cpp
|
||||
OpacitySlider.cpp
|
||||
Painter.cpp
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include "NumericInput.h"
|
||||
#include <ctype.h>
|
||||
|
||||
namespace GUI {
|
||||
|
||||
NumericInput::NumericInput()
|
||||
{
|
||||
set_text("0"sv);
|
||||
|
@ -87,3 +89,5 @@ void NumericInput::set_current_number(i32 number, GUI::AllowCallback allow_callb
|
|||
if (on_number_changed && allow_callback == GUI::AllowCallback::Yes)
|
||||
on_number_changed(m_current_number);
|
||||
}
|
||||
|
||||
}
|
|
@ -9,6 +9,8 @@
|
|||
#include <AK/NumericLimits.h>
|
||||
#include <LibGUI/TextBox.h>
|
||||
|
||||
namespace GUI {
|
||||
|
||||
class NumericInput final : public GUI::TextBox {
|
||||
C_OBJECT(NumericInput)
|
||||
public:
|
||||
|
@ -29,3 +31,5 @@ private:
|
|||
i32 m_min_number { NumericLimits<i32>::min() };
|
||||
i32 m_max_number { NumericLimits<i32>::max() };
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue