Remove more int16_t

This commit is contained in:
Bertrand Songis
2020-10-29 11:59:45 +01:00
parent 8c6550f8f1
commit 6c489a81d1
9 changed files with 52 additions and 49 deletions
+13 -13
View File
@@ -24,8 +24,8 @@
class BaseNumberEdit : public FormField class BaseNumberEdit : public FormField
{ {
public: public:
BaseNumberEdit(Window * parent, const rect_t &rect, int32_t vmin, int32_t vmax, BaseNumberEdit(Window * parent, const rect_t &rect, int vmin, int vmax,
std::function<int32_t()> getValue, std::function<void(int32_t)> setValue = nullptr, WindowFlags windowFlags = 0, LcdFlags textFlags = 0): std::function<int()> getValue, std::function<void(int)> setValue = nullptr, WindowFlags windowFlags = 0, LcdFlags textFlags = 0):
FormField(parent, rect, windowFlags, textFlags), FormField(parent, rect, windowFlags, textFlags),
vmin(vmin), vmin(vmin),
vmax(vmax), vmax(vmax),
@@ -34,17 +34,17 @@ class BaseNumberEdit : public FormField
{ {
} }
void setMin(int32_t value) void setMin(int value)
{ {
vmin = value; vmin = value;
} }
void setMax(int32_t value) void setMax(int value)
{ {
vmax = value; vmax = value;
} }
void setDefault(int32_t value) void setDefault(int value)
{ {
vdefault = value; vdefault = value;
} }
@@ -64,7 +64,7 @@ class BaseNumberEdit : public FormField
return vdefault; return vdefault;
} }
void setStep(int32_t value) void setStep(int value)
{ {
step = value; step = value;
} }
@@ -74,7 +74,7 @@ class BaseNumberEdit : public FormField
return step; return step;
} }
void setValue(int32_t value) void setValue(int value)
{ {
_setValue(limit(vmin, value, vmax)); _setValue(limit(vmin, value, vmax));
invalidate(); invalidate();
@@ -91,11 +91,11 @@ class BaseNumberEdit : public FormField
} }
protected: protected:
int32_t vdefault = 0; int vdefault = 0;
int32_t vmin; int vmin;
int32_t vmax; int vmax;
int32_t step = 1; int step = 1;
std::function<int32_t()> _getValue; std::function<int()> _getValue;
std::function<void(int32_t)> _setValue; std::function<void(int)> _setValue;
}; };
+8 -8
View File
@@ -21,8 +21,8 @@
#include "menu.h" #include "menu.h"
#include "theme.h" #include "theme.h"
Choice::Choice(FormGroup * parent, const rect_t & rect, int16_t vmin, int16_t vmax, Choice::Choice(FormGroup * parent, const rect_t & rect, int vmin, int vmax,
std::function<int16_t()> getValue, std::function<void(int16_t)> setValue, WindowFlags windowFlags) : std::function<int()> getValue, std::function<void(int)> setValue, WindowFlags windowFlags) :
ChoiceBase(parent, rect, CHOICE_TYPE_DROPOWN, windowFlags), ChoiceBase(parent, rect, CHOICE_TYPE_DROPOWN, windowFlags),
vmin(vmin), vmin(vmin),
vmax(vmax), vmax(vmax),
@@ -31,8 +31,8 @@ Choice::Choice(FormGroup * parent, const rect_t & rect, int16_t vmin, int16_t vm
{ {
} }
Choice::Choice(FormGroup * parent, const rect_t & rect, const char * const values[], int16_t vmin, int16_t vmax, Choice::Choice(FormGroup * parent, const rect_t & rect, const char * const values[], int vmin, int vmax,
std::function<int16_t()> getValue, std::function<void(int16_t)> setValue, WindowFlags windowFlags) : std::function<int()> getValue, std::function<void(int)> setValue, WindowFlags windowFlags) :
ChoiceBase(parent, rect, CHOICE_TYPE_DROPOWN, windowFlags), ChoiceBase(parent, rect, CHOICE_TYPE_DROPOWN, windowFlags),
vmin(vmin), vmin(vmin),
vmax(vmax), vmax(vmax),
@@ -42,8 +42,8 @@ Choice::Choice(FormGroup * parent, const rect_t & rect, const char * const value
setValues(values); setValues(values);
} }
Choice::Choice(FormGroup * parent, const rect_t & rect, std::vector<std::string> values, int16_t vmin, int16_t vmax, Choice::Choice(FormGroup * parent, const rect_t & rect, std::vector<std::string> values, int vmin, int vmax,
std::function<int16_t()> getValue, std::function<void(int16_t)> setValue, WindowFlags windowFlags) : std::function<int()> getValue, std::function<void(int)> setValue, WindowFlags windowFlags) :
ChoiceBase(parent, rect, CHOICE_TYPE_DROPOWN, windowFlags), ChoiceBase(parent, rect, CHOICE_TYPE_DROPOWN, windowFlags),
values(std::move(values)), values(std::move(values)),
vmin(vmin), vmin(vmin),
@@ -53,8 +53,8 @@ Choice::Choice(FormGroup * parent, const rect_t & rect, std::vector<std::string>
{ {
} }
Choice::Choice(FormGroup * parent, const rect_t & rect, const char * values, int16_t vmin, int16_t vmax, Choice::Choice(FormGroup * parent, const rect_t & rect, const char * values, int vmin, int vmax,
std::function<int16_t()> getValue, std::function<void(int16_t)> setValue, WindowFlags windowFlags) : std::function<int()> getValue, std::function<void(int)> setValue, WindowFlags windowFlags) :
ChoiceBase(parent, rect, CHOICE_TYPE_DROPOWN, windowFlags), ChoiceBase(parent, rect, CHOICE_TYPE_DROPOWN, windowFlags),
vmin(vmin), vmin(vmin),
vmax(vmax), vmax(vmax),
+13 -12
View File
@@ -27,7 +27,8 @@ enum ChoiceType {
CHOICE_TYPE_FOLDER, CHOICE_TYPE_FOLDER,
}; };
class ChoiceBase : public FormField { class ChoiceBase : public FormField
{
public: public:
ChoiceBase(FormGroup * parent, const rect_t & rect, ChoiceType type = CHOICE_TYPE_DROPOWN, WindowFlags windowFlags = 0): ChoiceBase(FormGroup * parent, const rect_t & rect, ChoiceType type = CHOICE_TYPE_DROPOWN, WindowFlags windowFlags = 0):
FormField(parent, rect, windowFlags), FormField(parent, rect, windowFlags),
@@ -46,10 +47,10 @@ class ChoiceBase : public FormField {
class Choice : public ChoiceBase { class Choice : public ChoiceBase {
public: public:
Choice(FormGroup * parent, const rect_t & rect, int16_t vmin, int16_t vmax, std::function<int16_t()> getValue, std::function<void(int16_t)> setValue = nullptr, WindowFlags windowFlags = 0); Choice(FormGroup * parent, const rect_t & rect, int vmin, int vmax, std::function<int()> getValue, std::function<void(int)> setValue = nullptr, WindowFlags windowFlags = 0);
Choice(FormGroup * parent, const rect_t & rect, std::vector<std::string> values, int16_t vmin, int16_t vmax, std::function<int16_t()> getValue, std::function<void(int16_t)> setValue = nullptr, WindowFlags windowFlags = 0); Choice(FormGroup * parent, const rect_t & rect, std::vector<std::string> values, int vmin, int vmax, std::function<int()> getValue, std::function<void(int)> setValue = nullptr, WindowFlags windowFlags = 0);
Choice(FormGroup * parent, const rect_t & rect, const char * const values[], int16_t vmin, int16_t vmax, std::function<int16_t()> getValue, std::function<void(int16_t)> setValue = nullptr, WindowFlags windowFlags = 0); Choice(FormGroup * parent, const rect_t & rect, const char * const values[], int vmin, int vmax, std::function<int()> getValue, std::function<void(int)> setValue = nullptr, WindowFlags windowFlags = 0);
Choice(FormGroup * parent, const rect_t & rect, const char * values, int16_t vmin, int16_t vmax, std::function<int16_t()> getValue, std::function<void(int16_t)> setValue = nullptr, WindowFlags windowFlags = 0); Choice(FormGroup * parent, const rect_t & rect, const char * values, int vmin, int vmax, std::function<int()> getValue, std::function<void(int)> setValue = nullptr, WindowFlags windowFlags = 0);
void addValue(const char * value); void addValue(const char * value);
@@ -133,13 +134,13 @@ class Choice : public ChoiceBase {
menuTitle = std::move(value); menuTitle = std::move(value);
} }
void setMin(int16_t value) void setMin(int value)
{ {
vmin = value; vmin = value;
invalidate(); invalidate();
} }
void setMax(int16_t value) void setMax(int value)
{ {
vmax = value; vmax = value;
invalidate(); invalidate();
@@ -147,13 +148,13 @@ class Choice : public ChoiceBase {
protected: protected:
std::vector<std::string> values; std::vector<std::string> values;
int16_t vmin = 0; int vmin = 0;
int16_t vmax = 0; int vmax = 0;
std::string menuTitle; std::string menuTitle;
std::function<int16_t()> getValue; std::function<int()> getValue;
std::function<void(int16_t)> setValue; std::function<void(int)> setValue;
std::function<bool(int)> isValueAvailable; std::function<bool(int)> isValueAvailable;
std::function<std::string(int32_t)> textHandler; std::function<std::string(int)> textHandler;
virtual void openMenu(); virtual void openMenu();
}; };
+2 -1
View File
@@ -22,7 +22,8 @@
#include "choice.h" #include "choice.h"
#include <string> #include <string>
class FileChoice: public ChoiceBase { class FileChoice: public ChoiceBase
{
public: public:
FileChoice(FormGroup * parent, const rect_t & rect, std::string folder, const char * extension, int maxlen, std::function<std::string()> getValue, std::function<void(std::string)> setValue); FileChoice(FormGroup * parent, const rect_t & rect, std::string folder, const char * extension, int maxlen, std::function<std::string()> getValue, std::function<void(std::string)> setValue);
+1 -1
View File
@@ -23,7 +23,7 @@
#include "keyboard_number.h" #include "keyboard_number.h"
#endif #endif
NumberEdit::NumberEdit(Window * parent, const rect_t & rect, int32_t vmin, int32_t vmax, std::function<int32_t()> getValue, std::function<void(int32_t)> setValue, WindowFlags windowFlags, LcdFlags textFlags): NumberEdit::NumberEdit(Window * parent, const rect_t & rect, int vmin, int vmax, std::function<int()> getValue, std::function<void(int)> setValue, WindowFlags windowFlags, LcdFlags textFlags):
BaseNumberEdit(parent, rect, vmin, vmax, std::move(getValue), std::move(setValue), windowFlags, textFlags) BaseNumberEdit(parent, rect, vmin, vmax, std::move(getValue), std::move(setValue), windowFlags, textFlags)
{ {
} }
+5 -5
View File
@@ -22,10 +22,10 @@
#include "basenumberedit.h" #include "basenumberedit.h"
#include <string> #include <string>
class NumberEdit : public BaseNumberEdit { class NumberEdit : public BaseNumberEdit
{
public: public:
NumberEdit(Window * parent, const rect_t & rect, int32_t vmin, int32_t vmax, NumberEdit(Window * parent, const rect_t & rect, int vmin, int vmax, std::function<int()> getValue, std::function<void(int)> setValue = nullptr, WindowFlags windowFlags = 0, LcdFlags textFlags = 0);
std::function<int32_t()> getValue, std::function<void(int32_t)> setValue = nullptr, WindowFlags windowFlags = 0, LcdFlags textFlags = 0);
#if defined(DEBUG_WINDOWS) #if defined(DEBUG_WINDOWS)
std::string getName() const override std::string getName() const override
@@ -56,7 +56,7 @@ class NumberEdit : public BaseNumberEdit {
zeroText = std::move(value); zeroText = std::move(value);
} }
void setDisplayHandler(std::function<void(BitmapBuffer *, LcdFlags, int32_t)> function) void setDisplayHandler(std::function<void(BitmapBuffer *, LcdFlags, int)> function)
{ {
displayFunction = std::move(function); displayFunction = std::move(function);
} }
@@ -70,7 +70,7 @@ class NumberEdit : public BaseNumberEdit {
void onFocusLost() override; void onFocusLost() override;
protected: protected:
std::function<void(BitmapBuffer *, LcdFlags, int32_t)> displayFunction; std::function<void(BitmapBuffer *, LcdFlags, int)> displayFunction;
std::string prefix; std::string prefix;
std::string suffix; std::string suffix;
std::string zeroText; std::string zeroText;
+4 -4
View File
@@ -33,13 +33,13 @@ constexpr coord_t SCROLL_POSITION_INVALIDATED = INT_MIN;
class Roller: public Choice class Roller: public Choice
{ {
public: public:
Roller(FormGroup * parent, const rect_t & rect, const char * label, const char * const * values, int16_t vmin, int16_t vmax, std::function<int16_t()> getValue, std::function<void(int16_t)> setValue = nullptr, WindowFlags windowFlags = ROLLER_SEPARATION_LINES): Roller(FormGroup * parent, const rect_t & rect, const char * label, const char * const * values, int vmin, int vmax, std::function<int()> getValue, std::function<void(int)> setValue = nullptr, WindowFlags windowFlags = ROLLER_SEPARATION_LINES):
Choice(parent, rect, values, vmin, vmax, std::move(getValue), std::move(setValue), windowFlags | NO_SCROLLBAR) Choice(parent, rect, values, vmin, vmax, std::move(getValue), std::move(setValue), windowFlags | NO_SCROLLBAR)
{ {
init(label); init(label);
} }
Roller(FormGroup * parent, const rect_t & rect, const char * label, std::vector<std::string> values, int16_t vmin, int16_t vmax, std::function<int16_t()> getValue, std::function<void(int16_t)> setValue = nullptr, WindowFlags windowFlags = ROLLER_SEPARATION_LINES): Roller(FormGroup * parent, const rect_t & rect, const char * label, std::vector<std::string> values, int vmin, int vmax, std::function<int()> getValue, std::function<void(int)> setValue = nullptr, WindowFlags windowFlags = ROLLER_SEPARATION_LINES):
Choice(parent, rect, std::move(values), vmin, vmax, std::move(getValue), std::move(setValue), windowFlags | NO_SCROLLBAR) Choice(parent, rect, std::move(values), vmin, vmax, std::move(getValue), std::move(setValue), windowFlags | NO_SCROLLBAR)
{ {
init(label); init(label);
@@ -127,14 +127,14 @@ class Roller: public Choice
} }
// virtual not needed until now // virtual not needed until now
void setMin(int16_t value) void setMin(int value)
{ {
Choice::setMin(value); Choice::setMin(value);
invalidateScrollPosition(); invalidateScrollPosition();
} }
// virtual not needed until now // virtual not needed until now
void setMax(int16_t value) void setMax(int value)
{ {
Choice::setMax(value); Choice::setMax(value);
invalidateScrollPosition(); invalidateScrollPosition();
+4 -4
View File
@@ -23,7 +23,7 @@
class Slider: public FormField { class Slider: public FormField {
public: public:
Slider(Window * parent, const rect_t & rect, int32_t vmin, int32_t vmax, std::function<int32_t()> getValue, std::function<void(int32_t)> setValue): Slider(Window * parent, const rect_t & rect, int32_t vmin, int32_t vmax, std::function<int()> getValue, std::function<void(int)> setValue):
FormField(parent, rect), FormField(parent, rect),
vmin(vmin), vmin(vmin),
vmax(vmax), vmax(vmax),
@@ -39,7 +39,7 @@ class Slider: public FormField {
} }
#endif #endif
void setValue(int32_t value) void setValue(int value)
{ {
_setValue(limit(vmin, value, vmax)); _setValue(limit(vmin, value, vmax));
invalidate(); invalidate();
@@ -64,7 +64,7 @@ class Slider: public FormField {
int32_t vmin; int32_t vmin;
int32_t vmax; int32_t vmax;
bool sliding = false; bool sliding = false;
std::function<int32_t()> getValue; std::function<int()> getValue;
std::function<void(int32_t)> _setValue; std::function<void(int)> _setValue;
}; };
+2 -1
View File
@@ -25,7 +25,8 @@
#include "libopenui_config.h" #include "libopenui_config.h"
#include "font.h" #include "font.h"
class Table: public FormField { class Table: public FormField
{
public: public:
class Cell { class Cell {
public: public: