mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:47:34 +00:00
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
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
|
set(SOURCES
|
||||||
NumericInput.cpp
|
|
||||||
OutlineModel.cpp
|
OutlineModel.cpp
|
||||||
PDFViewer.cpp
|
PDFViewer.cpp
|
||||||
PDFViewerWidget.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_prev_page_action);
|
||||||
toolbar.add_action(*m_go_to_next_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_enabled(false);
|
||||||
m_page_text_box->set_fixed_width(30);
|
m_page_text_box->set_fixed_width(30);
|
||||||
m_page_text_box->set_min_number(1);
|
m_page_text_box->set_min_number(1);
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "NumericInput.h"
|
|
||||||
#include "PDFViewer.h"
|
#include "PDFViewer.h"
|
||||||
#include "SidebarWidget.h"
|
#include "SidebarWidget.h"
|
||||||
#include <AK/NonnullRefPtr.h>
|
#include <AK/NonnullRefPtr.h>
|
||||||
|
@ -14,6 +13,7 @@
|
||||||
#include <LibGUI/Action.h>
|
#include <LibGUI/Action.h>
|
||||||
#include <LibGUI/ActionGroup.h>
|
#include <LibGUI/ActionGroup.h>
|
||||||
#include <LibGUI/CheckBox.h>
|
#include <LibGUI/CheckBox.h>
|
||||||
|
#include <LibGUI/NumericInput.h>
|
||||||
#include <LibGUI/Widget.h>
|
#include <LibGUI/Widget.h>
|
||||||
|
|
||||||
class PDFViewer;
|
class PDFViewer;
|
||||||
|
@ -40,7 +40,7 @@ private:
|
||||||
RefPtr<SidebarWidget> m_sidebar;
|
RefPtr<SidebarWidget> m_sidebar;
|
||||||
NonnullRefPtr<PagedErrorsModel> m_paged_errors_model;
|
NonnullRefPtr<PagedErrorsModel> m_paged_errors_model;
|
||||||
RefPtr<GUI::TreeView> m_errors_tree_view;
|
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::Label> m_total_page_label;
|
||||||
RefPtr<GUI::Action> m_go_to_prev_page_action;
|
RefPtr<GUI::Action> m_go_to_prev_page_action;
|
||||||
RefPtr<GUI::Action> m_go_to_next_page_action;
|
RefPtr<GUI::Action> m_go_to_next_page_action;
|
||||||
|
|
|
@ -86,6 +86,7 @@ set(SOURCES
|
||||||
MouseTracker.cpp
|
MouseTracker.cpp
|
||||||
MultiView.cpp
|
MultiView.cpp
|
||||||
Notification.cpp
|
Notification.cpp
|
||||||
|
NumericInput.cpp
|
||||||
Object.cpp
|
Object.cpp
|
||||||
OpacitySlider.cpp
|
OpacitySlider.cpp
|
||||||
Painter.cpp
|
Painter.cpp
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
#include "NumericInput.h"
|
#include "NumericInput.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
namespace GUI {
|
||||||
|
|
||||||
NumericInput::NumericInput()
|
NumericInput::NumericInput()
|
||||||
{
|
{
|
||||||
set_text("0"sv);
|
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)
|
if (on_number_changed && allow_callback == GUI::AllowCallback::Yes)
|
||||||
on_number_changed(m_current_number);
|
on_number_changed(m_current_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -9,6 +9,8 @@
|
||||||
#include <AK/NumericLimits.h>
|
#include <AK/NumericLimits.h>
|
||||||
#include <LibGUI/TextBox.h>
|
#include <LibGUI/TextBox.h>
|
||||||
|
|
||||||
|
namespace GUI {
|
||||||
|
|
||||||
class NumericInput final : public GUI::TextBox {
|
class NumericInput final : public GUI::TextBox {
|
||||||
C_OBJECT(NumericInput)
|
C_OBJECT(NumericInput)
|
||||||
public:
|
public:
|
||||||
|
@ -29,3 +31,5 @@ private:
|
||||||
i32 m_min_number { NumericLimits<i32>::min() };
|
i32 m_min_number { NumericLimits<i32>::min() };
|
||||||
i32 m_max_number { NumericLimits<i32>::max() };
|
i32 m_max_number { NumericLimits<i32>::max() };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue