ASPiK SDK
ivalue.h
1 // This file is part of VSTGUI. It is subject to the license terms
2 // in the LICENSE file found in the top-level directory of this
3 // distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
4 
5 #pragma once
6 
7 #include "fwd.h"
8 #include "../../lib/cstring.h"
9 #include "interface.h"
10 
11 //------------------------------------------------------------------------
12 namespace VSTGUI {
13 namespace Standalone {
14 
15 //------------------------------------------------------------------------
20 class IValue : public Interface
21 {
22 public:
24  using Type = double;
26  static constexpr Type InvalidValue = std::numeric_limits<Type>::min ();
27 
29  virtual void beginEdit () = 0;
31  virtual bool performEdit (Type newValue) = 0;
33  virtual void endEdit () = 0;
34 
36  virtual void setActive (bool state) = 0;
38  virtual bool isActive () const = 0;
39 
41  virtual Type getValue () const = 0;
43  virtual bool isEditing () const = 0;
44 
46  virtual const UTF8String& getID () const = 0;
47 
49  virtual const IValueConverter& getConverter () const = 0;
50 
52  virtual void registerListener (IValueListener* listener) = 0;
54  virtual void unregisterListener (IValueListener* listener) = 0;
55 };
56 
57 //------------------------------------------------------------------------
62 class IStepValue : public Interface
63 {
64 public:
65  using StepType = uint32_t;
66  static constexpr StepType InvalidStep = std::numeric_limits<uint32_t>::max ();
67 
69  virtual StepType getSteps () const = 0;
71  virtual IValue::Type stepToValue (StepType step) const = 0;
73  virtual StepType valueToStep (IValue::Type) const = 0;
74 };
75 
76 //------------------------------------------------------------------------
81 class IValueConverter : public Interface
82 {
83 public:
85  virtual UTF8String valueAsString (IValue::Type value) const = 0;
87  virtual IValue::Type stringAsValue (const UTF8String& string) const = 0;
88 
90  virtual IValue::Type plainToNormalized (IValue::Type plain) const = 0;
92  virtual IValue::Type normalizedToPlain (IValue::Type normalized) const = 0;
93 };
94 
95 //------------------------------------------------------------------------
96 } // Standalone
97 } // VSTGUI
virtual void setActive(bool state)=0
virtual UTF8String valueAsString(IValue::Type value) const =0
virtual Type getValue() const =0
virtual IValue::Type plainToNormalized(IValue::Type plain) const =0
Definition: ivaluelistener.h:18
double Type
Definition: ivalue.h:24
Definition: interface.h:13
virtual const UTF8String & getID() const =0
virtual IValue::Type stringAsValue(const UTF8String &string) const =0
Definition: customcontrols.cpp:8
virtual StepType valueToStep(IValue::Type) const =0
static constexpr Type InvalidValue
Definition: ivalue.h:26
virtual IValue::Type normalizedToPlain(IValue::Type normalized) const =0
Definition: ivalue.h:20
virtual IValue::Type stepToValue(StepType step) const =0
holds an UTF8 encoded string and a platform representation of it
Definition: cstring.h:56
Definition: ivalue.h:62
virtual const IValueConverter & getConverter() const =0
virtual void beginEdit()=0
virtual void registerListener(IValueListener *listener)=0
virtual bool isActive() const =0
virtual StepType getSteps() const =0
virtual bool performEdit(Type newValue)=0
virtual void endEdit()=0
virtual bool isEditing() const =0
virtual void unregisterListener(IValueListener *listener)=0