guit  0.1
 All Classes Functions Variables Typedefs Enumerations Friends
ginspector.hpp
1 
2 //
3 // Inspector
4 // guit GUI Toolkit
5 // Copyright © 2019/2020 Eric Lecolinet. All rights reserved.
6 // http://www.telecom-paris.fr/~elc
7 //
8 
9 #ifndef Guit_Inspector_hpp
10 #define Guit_Inspector_hpp
11 #include <list>
12 #include <gwindow.hpp>
13 #include <gtable.hpp>
14 #include <gscrollbox.hpp>
15 #include <gchoice.hpp>
16 #include <gtext.hpp>
17 #include <gstates.hpp>
18 namespace guit {
19 
20 class GCursor;
21 class GGlass;
22 
24 class GInspector : public GWindow {
25 public:
26  ~GInspector();
27  GInspector();
28 
29  static class GInspector& instance();
30 
31  void setInspecting(int mode);
32  static int inspecting();
33 
34  void inspect(Gadget*);
35  static Gadget* inspected();
36 
37  GInspector& show(bool show = true) override;
38  Gadget* target() {return target_;}
39 
40  void setInspectingCB( std::function< void(int) > const& fun);
41  void setInspectedCB( std::function< void(Gadget*) > const& fun);
42 
43 private:
44  friend class GBuilder;
45  void highlight(Gadget*, bool state);
46  void addGadget(GBox& box, Gadget& obj, int ix);
47  void deleteGadget(Gadget* obj, bool itself);
48  void addProperty(Gadget* parent, GProp* prop);
49  void deleteProperty(Gadget* parent, GProp* prop);
50  bool moveGadget(GCursor&, Gadget& moved);
51  void updateValues();
52  void updateChildValues();
53  void updatePropValues();
54  void moveTarget(Gadget* obj);
55  void moveTargetCB(GCursor&, Gadget&);
56 
57  GChoice inspectchoice_{0};
58  GShow hastarget_, hasparent_, hasundo_;
59  GText targettype_, targetext_, targetgeom_;
60  GText parenttype_, parentext_;
61  GTable propbox_{"#propbox"}, childbox_{"#childbox"};
62  GScrollBox propscroll_, childscroll_;
63  gprotect<Gadget> target_, targetparent_;
64  gptr<GGlass> targetglass_, highlightglass_;
65  std::function<void(int)> inspectingcb_{};
66  std::function<void(Gadget*)> inspectedcb_{};
67 
68  void addUndo(Gadget& obj, GBox* parent);
69  void addUndo(GProp& obj, Gadget* parent);
70  void undelete();
71 
72  struct UndoElem {
73  UndoElem(Gadget& obj, GBox* parent, int pos) :
74  obj(obj), parent(parent), pos(pos) {}
75 
76  UndoElem(GProp& obj, Gadget* parent)
77  : obj(obj), parent(parent) {}
78 
79  gptr<GObject> obj;
80  gptr<Gadget> parent;
81  int pos{};
82  };
83 
84  std::list<UndoElem> undolist_;
85 
86 };
87 
88 }
89 #endif