10 #include <gvarprop.hpp>
13 class GPosValue :
public GPoint {
15 GPosValue() =
default;
16 GPosValue(
float x,
float y,
int layer);
17 GPosValue(GPoint
const&,
int layer);
18 GPosValue& operator=(GPoint
const&);
19 bool operator==(GPosValue
const&)
const;
20 bool operator!=(GPosValue
const&)
const;
21 static GPosValue blend(GPosValue
const& a, GPosValue
const& b,
float coeff);
22 GString stringValue()
const;
27 inline bool gconvert(GPosValue
const& from, GPosValue& to) {to = from;
return true;}
28 bool gconvert(GString
const& from, GPosValue& to);
29 bool gconvert(GPosValue
const& from, GString& to);
54 using Layer = uint8_t;
55 enum : Layer {MinLayer = 0, MaxLayer = 250};
59 GPos(
float x,
float y, Layer layer = 1);
62 GPos*
clone(
bool copy_value)
const override;
64 GPos* toPos()
override {
return this;}
65 GPos const* toPos()
const override {
return this;}
67 GPos& operator=(
GPos const& pos) {set(pos);
return *
this;}
68 GPos& operator=(
GPoint const& pos) {set(pos);
return *
this;}
69 GPos& operator=(GString
const& pos) {set(pos);
return *
this;}
72 void set(
float x,
float y);
73 void set(
float x,
float y, Layer layer);
74 void set(
GPoint const& pos);
75 void set(
GProp const&)
override;
77 virtual void blend(
GPos const& a,
GPos const& b,
float mix);
78 void blend(
GProp const& a,
GProp const& b,
float mix)
override;
84 virtual GPoint const& pos()
const {
return value_;}
85 virtual float x()
const {
return value_.x;}
86 virtual float y()
const {
return value_.y;}
87 virtual int layer()
const {
return value_.layer;}
93 auto xField() {
return GNumPropField<GPos,float>(*
this, value_.x);}
94 auto yField() {
return GNumPropField<GPos,float>(*
this, value_.y);}
95 auto layerField() {
return GNumPropField<GPos,int>(*
this, value_.layer);}
101 using GType = GPropType_<GPos,GProp>;
102 static GType& Type();
103 GType& type()
const override {
return Type();}
107 bool onAdd(Gadget*)
override;
109 void updateGadget(Gadget&)
override;
110 void apply(Gadget*, GRender&,
Specif) final;
117 GPos& Pos(GString const& value);
118 GPos& Pos(
float x,
float y, GPos::Layer layer = 1);
125 GDragPos(
float x,
float y, Layer layer = 1) : GPos(x,y,layer) {}
126 GDragPos(
GPoint const& pos = {}, Layer layer = 1) : GPos(pos,layer) {}
131 void fixX(
bool val =
true) {fixx_ = val;}
132 void fixY(
bool val =
true) {fixy_ = val;}
133 bool isXFixed()
const {
return fixx_;}
134 bool isYFixed()
const {
return fixy_;}
137 static GType& Type();
138 GType& type()
const override {
return Type();}
142 bool fixx_{}, fixy_{};
145 void fire(
GEvent&)
override;
156 GRelativePos(GString
const& =
"");
158 GRelativePos*
clone(
bool copy_value)
const override;
160 Gadget* relatedGadget()
const {
return related_;}
161 GPoint const& relatedPos()
const {
return relatedpos_;}
162 virtual void updatePos();
165 static GType& Type();
166 GType& type()
const override {
return Type();}