10 #include <gvarprop.hpp>
13 class GSizeValue :
public GDim {
16 GSizeValue(
float w,
float h,
char wunit,
char hunit);
17 GSizeValue(GDim
const&,
char wunit,
char hunit);
19 static GSizeValue blend(GSizeValue
const& a, GSizeValue
const& b,
float coeff);
21 bool operator==(GSizeValue
const&)
const;
22 bool operator!=(GSizeValue
const&)
const;
24 char wunit{}, hunit{};
27 inline bool gconvert(GSizeValue
const& from, GSizeValue& to) {to = from;
return true;}
28 bool gconvert(GString
const& from, GSizeValue& to);
29 bool gconvert(GSizeValue
const& from, GString& to);
50 enum Unit : int8_t {Undef, Pixels, Chars, Auto, Percent};
52 GSize* toSize()
override {
return this;}
53 GSize const* toSize()
const override {
return this;}
56 GSize(
float width,
float height, Unit wunit = Pixels, Unit hunit = Pixels);
57 GSize(
GDim const&, Unit wunit = Pixels, Unit hunit = Pixels);
59 GSize(GString
const& format);
62 GSize& operator=(
GSize const& from) {set(from);
return *
this;}
63 GSize& operator=(GString
const& format) {set(format);
return *
this;}
66 void set(
float width,
float height, Unit wunit = Pixels, Unit hunit = Pixels);
67 void set(
GProp const&)
override;
69 virtual void blend(
GSize const& a,
GSize const& b,
float alpha);
70 void blend(
GProp const& a,
GProp const& b,
float alpha)
override;
72 float w()
const {
return value_.w;}
73 float h()
const {
return value_.h;}
76 using Field = GNumPropField<GSize,float>;
82 Field hField() {
return Field(*
this, value_.h);}
85 using GType = GPropType_<GSize,GProp>;
87 GType& type()
const override {
return Type();}
91 bool onAdd(Gadget*)
override;
93 void apply(Gadget*, GRender&,
Specif) final;
94 void updateGadget(Gadget&) override;
100 GSize& Size(GString const&
value);
108 GDragSize(
float w,
float h) : GSize(w, h, Pixels, Pixels) {}
122 static GType& Type();
123 GType& type()
const override {
return Type();}
127 bool fixw_{}, fixh_{};
131 void fire(
GEvent&)
override;