psychic-ui 0.0.0
Loading...
Searching...
No Matches
psychic_ui::NumberStepper Class Reference

#include <NumberStepper.hpp>

Inheritance diagram for psychic_ui::NumberStepper:
psychic_ui::TextField< NumberStepperSkin > psychic_ui::Component< NumberStepperSkin, TextFieldBase > psychic_ui::TextFieldBase psychic_ui::Div psychic_ui::Observer

Public Member Functions

 NumberStepper (double value=0, std::function< void(double)> onChangeCallback=nullptr)
double value () const
template<class Self>
Self & value (this Self &self, double value)
double min () const
template<class Self>
Self & min (this Self &self, double min)
double max () const
template<class Self>
Self & max (this Self &self, double max)
template<class Self>
Self & range (this Self &self, double min, double max)
double step () const
template<class Self>
Self & step (this Self &self, double step)
int decimals () const
template<class Self>
Self & decimals (this Self &self, int decimals)
void stepBy (int count)
std::string valueString () const
MouseEventStatus handleMouseScroll (const MouseEvent &event) override
bool takesEscape () const override
Public Member Functions inherited from psychic_ui::Component< NumberStepperSkin, TextFieldBase >
std::shared_ptr< NumberStepperSkin > skin () const
Public Member Functions inherited from psychic_ui::TextFieldBase
std::string text () const
template<class Self>
Self & text (this Self &self, const std::string &text)
bool readOnly () const
template<class Self>
Self & readOnly (this Self &self, detail::BoolArg readOnly)
std::pair< unsigned int, unsigned int > selection () const
template<class Self>
Self & selection (this Self &self, unsigned int anchor, unsigned int caret)
unsigned int caret () const
Public Member Functions inherited from psychic_ui::Div
 Div (const Div &)=delete
Div & operator= (const Div &)=delete
 Div (Div &&)=delete
Div & operator= (Div &&)=delete
std::string toString () const
virtual Window * window ()
virtual const Window * window () const
Div * parent ()
const Div * parent () const
int depth () const
unsigned int childCount () const
const std::vector< std::shared_ptr< Div > > & children () const
template<class T, class... Args>
requires (std::derived_from<T, Div> && std::constructible_from<T, Args...>)
T & add (Args &&... args)
template<class T>
requires std::derived_from<T, Div>
T & add (unsigned int index, std::shared_ptr< T > child)
template<class T>
requires std::derived_from<T, Div>
T & add (std::shared_ptr< T > child)
void remove (unsigned int index)
void remove (const std::shared_ptr< Div > &child)
void remove (const Div &child)
void removeAll ()
const Div * at (unsigned int index) const
Div * at (unsigned int index)
int childIndex (const std::shared_ptr< Div > &child) const
int childIndex (const Div *child) const
template<class Self>
Self & transition (this Self &self, Property property, const Timing &timing)
template<class Self>
Self & transition (this Self &self, std::initializer_list< Property > properties, const Timing &timing)
template<class Self>
Self & row (this Self &self)
template<class Self>
Self & column (this Self &self)
template<class Self>
Self & size (this Self &self, Length width, Length height)
template<class Self>
Self & style (this Self &self, const Style &style)
const Style & style () const
const Style & computedStyle () const
Style targetStyle () const
bool transitioning () const
bool transitioning (Property property) const
void animate (float from, float to, const Timing &timing, std::function< void(float)> update)
template<class Self>
Self & startingClass (this Self &self, detail::StringArg className)
const std::string & startingClass () const
bool starting () const
void exit (const std::string &className, std::function< void()> done)
bool exiting () const
void cancelExit ()
bool subtreeTransitioning () const
float layoutOffsetX () const
float layoutOffsetY () const
bool layoutSliding () const
bool visible () const
bool enabled () const
template<class Self>
Self & enabled (this Self &self, detail::BoolArg enabled)
virtual bool active () const
bool focusEnabled () const
template<class Self>
Self & focusEnabled (this Self &self, detail::BoolArg focusEnabled)
bool hasFocus () const
void setFocused (bool focused)
const std::string & tooltip () const
template<class Self>
Self & tooltip (this Self &self, const std::string &text)
const std::vector< std::shared_ptr< MenuItem > > & contextMenu () const
template<class Self>
Self & contextMenu (this Self &self, std::vector< std::shared_ptr< MenuItem > > items)
void localToGlobal (int &gx, int &gy, int x=0, int y=0) const
void globalToLocal (int &lx, int &ly, int x=0, int y=0) const
int x () const
int y () const
int getWidth () const
int getHeight () const
int boundsLeft () const
int boundsTop () const
int boundsRight () const
int boundsBottom () const
int contentWidth () const
int contentHeight () const
int scrollX () const
template<class Self>
Self & scrollX (this Self &self, int scrollX)
int scrollY () const
template<class Self>
Self & scrollY (this Self &self, int scrollY)
void scroll (double scrollX, double scrollY)
bool scrollBy (int deltaX, int deltaY)
void scrollIntoView (const SkRect &rect)
StyleManager * styleManager () const
void setStyleManager (std::shared_ptr< StyleManager > styleManager)
void updateStyle ()
void updateStyleRecursive ()
void updateDirtyStyles ()
bool styleDirty () const
const std::vector< std::string > & tags () const
const std::string & internalId () const
const std::string & id () const
template<class Self>
Self & id (this Self &self, std::string id)
const std::unordered_set< std::string > & classNames () const
template<class Self>
Self & classNames (this Self &self, const std::unordered_set< std::string > &classNames)
template<class Self>
Self & addClassName (this Self &self, std::string className)
template<class Self>
Self & removeClassName (this Self &self, std::string className)
virtual const PropertyMask & inheritedProperties () const
bool mouseChildren () const
template<class Self>
Self & mouseChildren (this Self &self, detail::BoolArg mouseChildren)
bool mouseEnabled () const
template<class Self>
Self & mouseEnabled (this Self &self, detail::BoolArg mouseEnabled)
bool mouseOver () const
void setMouseOver (bool over)
bool getMouseDown () const
void setMouseDown (bool down)
bool contains (float x, float y) const
bool boundsContains (float x, float y) const
virtual MouseEventStatus handleMouseMove (const MouseEvent &event, bool handled)
virtual bool handleMouseExit (const MouseEvent &event)
virtual MouseEventStatus handleMouseButtonChange (const MouseEvent &event)
virtual MouseEventStatus handleMousePress (const MouseEvent &event)
virtual MouseEventStatus handleMouseRelease (const MouseEvent &event)
virtual MouseEventStatus handleClick (const MouseEvent &event)
virtual MouseEventStatus handleDoubleClick (const MouseEvent &event)
virtual MouseEventStatus handleContextMenuRequest (const MouseEvent &event)
MouseEvent mouseEventAtCenter ()
MouseEvent localMouseEvent (const MouseEvent &event) const
Public Member Functions inherited from psychic_ui::Observer
 Observer (const Observer &)=delete
Observer & operator= (const Observer &)=delete
 Observer (Observer &&)=delete
Observer & operator= (Observer &&)=delete

Public Attributes

Signal< double > changed {}
Public Attributes inherited from psychic_ui::Div
Signal< int, int > scrolled {}
Signal< int, int > resized {}
bool dashed {false}
Signal< MouseEvent > mouseButtonChanged {}
Signal< MouseEvent > mousePressed {}
Signal< MouseEvent > mouseReleased {}
Signal< MouseEvent > mouseReleasedOutside {}
Signal< MouseEvent > mouseMoved {}
Signal< MouseEvent > mouseEntered {}
Signal< MouseEvent > mouseExited {}
Signal< MouseEvent > mouseScrolled {}
Signal< MouseEvent > clicked {}
Signal< MouseEvent > doubleClicked {}
Signal< MouseEvent > contextMenuRequested {}
Signal< Key, Mod > keyPressed {}
Signal< Key, Mod > keyRepeated {}
Signal< Key, Mod > keyReleased {}
Signal< icu::UnicodeString > typed {}
Signal focused {}
Signal blurred {}

Protected Member Functions

void updateValue (double value)
void updateRange (double min, double max)
void updateStep (double step)
void updateDecimals (int decimals)
double scale () const
void commit ()
void refresh ()
bool fieldKey (Key key, Mod mod) override
bool fieldPress (const MouseEvent &event) override
void skinChanged () override
void enabledChanged () override
Protected Member Functions inherited from psychic_ui::TextField< NumberStepperSkin >
 TextField (const std::string &text, const bool multiline)
Text * view () const override
void skinChanged () override
Protected Member Functions inherited from psychic_ui::Component< NumberStepperSkin, TextFieldBase >
NumberStepperSkin & add (Args &&... args)
NumberStepperSkin & add (unsigned int index, std::shared_ptr< NumberStepperSkin > child)
NumberStepperSkin & add (std::shared_ptr< NumberStepperSkin > child)
void remove (unsigned int index)
void remove (const std::shared_ptr< Div > &child)
void remove (const Div &child)
void removeAll ()
void updateSkin (std::shared_ptr< NumberStepperSkin > skin)
void draw (SkCanvas *) override
void styleUpdated () override
Protected Member Functions inherited from psychic_ui::TextFieldBase
virtual void textChanged ()
virtual void textEdited ()
void apply (TextEditing::Edit edit)
void show ()
void viewChanged ()
void revealCaret ()
void updateText (const std::string &text)
void updateReadOnly (bool readOnly)
void handleKey (Key key, Mod mod)
void handlePress (const MouseEvent &event)
bool editable () const
void enabledChanged () override
void layoutUpdated () override
void removedFromRender () override
Protected Member Functions inherited from psychic_ui::Div
void updateContextMenu (std::vector< std::shared_ptr< MenuItem > > items)
void setParent (Div *parent)
virtual void added ()
virtual void removed ()
virtual void childAdded (Div &child)
virtual void childRemoved (Div &child)
template<class T>
requires std::derived_from<T, Div>
T * trackChild (std::vector< std::shared_ptr< T > > &list, Div &child) const
virtual void addedToRender ()
std::vector< std::shared_ptr< Div > > childrenTopmostFirst () const
void invalidateEndChildrenStyle ()
void insertChild (unsigned int index, std::shared_ptr< Div > child)
void updateEnabled (bool enabled)
void updateId (std::string id)
void updateClassNames (const std::unordered_set< std::string > &classNames)
void updateClassName (std::string className, bool present)
void scrollTo (int scrollX, int scrollY)
template<class Self>
Self & tag (this Self &self, std::string tag)
void addTag (std::string tag)
void updateLayoutSlides (const SlideWalk &walk)
void updateSlidingClass ()
void releaseStartingClass ()
void finishExit ()
void updateTransitions (Style &computed)
bool advanceTransitions (std::chrono::nanoseconds now)
void finishTransitions ()
void cancelTransitions ()
void transitionsChanged (const PropertyMask &changed)
void invalidateStyle ()
void updateRuntimeStyles ()
virtual void createStyles ()
void setMeasurable ()
void updateLayout (const PropertyMask &changed)
void invalidate ()
bool isValid () const
virtual Size measure (Constraint width, Constraint height)
virtual void render (SkCanvas *canvas)
void clip (SkCanvas *canvas)
void drawShadow (SkCanvas *canvas)
void drawDotGrid (SkCanvas *canvas)
void drawOutline (SkCanvas *canvas)
Protected Member Functions inherited from psychic_ui::Observer
template<class... T, class F>
std::shared_ptr< Slot< T... > > subscribeTo (Signal< T... > &signal, F &&callback)

Protected Attributes

double _value {0}
double _min {-1e9}
double _max {1e9}
double _step {1}
int _decimals {-1}
Protected Attributes inherited from psychic_ui::Component< NumberStepperSkin, TextFieldBase >
Atom _skinName
std::size_t _skinsGeneration
bool _skinByHand
std::shared_ptr< NumberStepperSkin > _skin
Protected Attributes inherited from psychic_ui::TextFieldBase
TextEditing _editing {}
bool _revealCaret {false}
ScopedSlot _onMouseMove {}
Protected Attributes inherited from psychic_ui::Div
std::string _tooltip {}
std::vector< std::shared_ptr< MenuItem > > _contextMenu {}
ScopedSlot _contextMenuSlot {}
bool _enabled {true}
bool _visible {true}
int _x {0}
int _y {0}
int _width {0}
int _height {0}
int _boundsLeft {0}
int _boundsTop {0}
int _boundsRight {0}
int _boundsBottom {0}
bool _focusEnabled {false}
bool _focused {false}
int _depth {0}
Div * _parent {nullptr}
std::vector< std::shared_ptr< Div > > _children {}
std::vector< std::string > _tags {}
std::string _internalId {}
std::string _id {}
std::unordered_set< std::string > _classNames {}
std::shared_ptr< StyleManager > _styleManager {nullptr}
Style _defaultStyle
Style _inlineStyle
Style _computedStyle {}
bool _layoutInitialized {false}
bool _styleDirty {true}
bool _descendantStyleDirty {false}
Window * _styledIn {nullptr}
std::size_t _styledGeneration {0}
std::shared_ptr< detail::StyleTransitions > _transitions {}
std::vector< std::shared_ptr< Animation > > _animations {}
std::string _startingClass {}
bool _startingApplied {false}
std::unique_ptr< Exit > _exit {}
std::unique_ptr< LayoutSlide > _layoutSlide {}
YGNode * _yogaNode {nullptr}
SkRect _rect {}
SkRect _marginRect {}
float _marginLeft {0.0f}
float _marginRight {0.0f}
float _marginTop {0.0f}
float _marginBottom {0.0f}
SkRect _paddedRect {}
SkRRect _roundRect {}
SkRect _boundsRect {}
float _paintOutset {0.0f}
bool _ignoreInternalLayoutContraints {false}
bool layoutReady {false}
bool _drawBackground {false}
bool _drawBorder {false}
bool _drawComplexBorders {false}
bool _drawRoundRect {false}
bool _drawComplexRoundRect {false}
float _radiusTopLeft {0.0f}
float _radiusTopRight {0.0f}
float _radiusBottomLeft {0.0f}
float _radiusBottomRight {0.0f}
std::array< SkVector, 4 > _radii {}
float _borderLeft {0.0f}
float _borderRight {0.0f}
float _borderTop {0.0f}
float _borderBottom {0.0f}
int _scrollX {0}
int _scrollY {0}
bool _mouseEnabled {true}
bool _mouseChildren {true}
bool _mouseOver {false}
bool _mouseDown {false}
Protected Attributes inherited from psychic_ui::Observer
std::vector< ScopedSlot > slots {}

Additional Inherited Members

Static Public Attributes inherited from psychic_ui::Div
static bool debugLayout {false}
Static Protected Member Functions inherited from psychic_ui::Div
template<class T>
requires std::derived_from<T, Div>
static T * untrackChild (std::vector< std::shared_ptr< T > > &list, const Div &child)
Static Protected Attributes inherited from psychic_ui::Div
static int idCounter = 0

Detailed Description

A number with − and + on either side: the buttons, Up and Down (Shift for ten steps), and the mouse wheel while it has the focus step it; typing a number and pressing Enter (or leaving the field) sets it, Escape gives the typed text up. The value stays within min() and max(), and what is typed or stepped is rounded to the decimals shown; a button at its bound is disabled. There is no press-and-hold repeat (no timer yet): holding Up or Down repeats instead. Its skin shows the buttons (.decrement, .increment) and the text (.value), and says which button a press is on.

Member Function Documentation

◆ commit()

void psychic_ui::NumberStepper::commit ( )
protected

Set the value from what was typed, rounded to the decimals shown, or show the value again if it isn't a number

◆ decimals()

int psychic_ui::NumberStepper::decimals ( ) const

How many decimals the value shows; -1 (the default) takes as many as the step has

◆ enabledChanged()

void psychic_ui::NumberStepper::enabledChanged ( )
overrideprotectedvirtual

Called when enabled(bool) changes the enabled state

Reimplemented from psychic_ui::Div.

◆ fieldKey()

bool psychic_ui::NumberStepper::fieldKey ( Key key,
Mod mod )
overrideprotectedvirtual

A key, before editing has it; the field is kept alive meanwhile

Returns
Whether it was used (then editing doesn't see it)

Reimplemented from psychic_ui::TextFieldBase.

◆ fieldPress()

bool psychic_ui::NumberStepper::fieldPress ( const MouseEvent & event)
overrideprotectedvirtual

A left press, before it places the caret or starts a selection (a button part of the skin's); the field is kept alive meanwhile

Returns
Whether it was used (then the text doesn't see it)

Reimplemented from psychic_ui::TextFieldBase.

◆ handleMouseScroll()

MouseEventStatus psychic_ui::NumberStepper::handleMouseScroll ( const MouseEvent & event)
overridevirtual

With the focus, the wheel steps it; otherwise it scrolls what is around it

Reimplemented from psychic_ui::Div.

◆ range()

template<class Self>
Self & psychic_ui::NumberStepper::range ( this Self & self,
double min,
double max )
inline

Set the minimum and maximum (swapped if reversed), clamping the value

◆ refresh()

void psychic_ui::NumberStepper::refresh ( )
protected

Show the value, and the bounds

◆ scale()

double psychic_ui::NumberStepper::scale ( ) const
protected

10 to the power of the decimals shown

◆ skinChanged()

void psychic_ui::NumberStepper::skinChanged ( )
overrideprotectedvirtual

◆ step()

template<class Self>
Self & psychic_ui::NumberStepper::step ( this Self & self,
double step )
inline

How much a button, key or wheel notch changes the value (1 by default)

◆ stepBy()

void psychic_ui::NumberStepper::stepBy ( int count)

Step the value up (or down with a negative count) by count steps, clamped and rounded to the decimals shown; a step finer than them moves by one of their units

◆ takesEscape()

bool psychic_ui::NumberStepper::takesEscape ( ) const
overridevirtual

While what is typed isn't the value shown: Escape reverts it before closing a popup

Reimplemented from psychic_ui::Div.

◆ value()

template<class Self>
Self & psychic_ui::NumberStepper::value ( this Self & self,
double value )
inline

Set the value, clamped to the range

◆ valueString()

std::string psychic_ui::NumberStepper::valueString ( ) const

The value as the field shows it

Member Data Documentation

◆ changed

Signal<double> psychic_ui::NumberStepper::changed {}

The value changed, with the new value (the text's own edits aren't changes until they are set)


The documentation for this class was generated from the following files: