8 #ifndef Guit_PropWrapper_hpp
9 #define Guit_PropWrapper_hpp
11 #include <gtrigger.hpp>
14 class GPropWrapper :
public GProp {
16 GPropWrapper(GProp& p) : prop_(p) {}
17 GPropWrapper* toPropWrapper()
override {
return this;}
18 GProp* prop() {
return prop_;}
20 GString stringValue()
const override;
21 float floatValue()
const override;
25 template <
class T,
class F>
26 class GFieldWrapper :
public GPropWrapper {
29 GFieldWrapper(T& prop, F& field) : GPropWrapper(prop), field_(field) {}
30 GString stringValue()
const override {
return *field_;}
33 template <
class T,
class F>
34 class GNumFieldWrapper :
public GPropWrapper {
37 GNumFieldWrapper(T& prop, F& field) : GPropWrapper(prop), field_(field) {}
38 float floatValue()
const override {
return field_;}
42 class GVectorWrapper :
public GPropWrapper {
43 std::vector<T>& vect_;
45 GVectorWrapper(GProp& index, std::vector<T>& v) : GPropWrapper(index), vect_(v) {}
46 GString stringValue()
const override {
return vect_.at(
int(prop_->floatValue()));}
50 class GNumVectorWrapper :
public GPropWrapper {
51 std::vector<T>& vect_;
53 GNumVectorWrapper(GProp& index, std::vector<T>& v) : GPropWrapper(index), vect_(v) {}
54 float floatValue()
const override {
return vect_.at(
int(prop_->floatValue()));}
59 template <
class P,
class F>
60 GPropRef GPropField<P,F>::operator~() {
61 return GPropRef(*
new GFieldWrapper<P,F>(this->prop_, this->field_));
64 template <
class P,
class F>
65 GNumPropRef GNumPropField<P,F>::operator~() {
66 return GNumPropRef(*
new GNumFieldWrapper<P,F>(this->prop_, this->field_));
69 class GExprWrapper :
public GProp {
72 GExprWrapper* toExprWrapper()
override {
return this;}
74 static GPropType& Type();
75 GPropType& type()
const override {
return Type();}
77 bool bindWith(GVarProp&);
78 float floatValue()
const override;
79 GString stringValue()
const override;
81 bool isEquivalent(
const GProp& other)
const override {
return false;}
83 void onRemove(Gadget*)
override;
84 void removeNotifiers(
void* obj)
override;
86 enum Type {TNone, TBool, TNum, TString, TText} type_{};
88 gptr<class GExprNotifier> notifier_;