2 #include "common/common.hpp"
3 #include "util/uuid.hpp"
4 #include "util/layer_range.hpp"
19 enum class Flag { SELECTED = 1, PRELIGHT = 2, ALWAYS = 4, PREVIEW = 8 };
20 bool get_flag(Flag f)
const;
21 void set_flag(Flag f,
bool v);
23 Selectable(
const Coordf ¢er,
const Coordf &box_center,
const Coordf &box_dim,
float angle = 0,
25 bool inside(
const Coordf &c,
float expand = 0)
const;
28 bool is_point()
const;
30 std::array<Coordf, 4> get_corners()
const;
31 } __attribute__((packed));
39 SelectableRef(
const UUID &uu, ObjectType ty,
unsigned int v = 0, LayerRange la = 10000)
40 : uuid(uu), type(ty), vertex(v), layer(la)
43 bool operator<(
const SelectableRef &other)
const
45 if (type < other.type) {
48 if (type > other.type) {
51 if (uuid < other.uuid) {
54 else if (uuid > other.uuid) {
57 return vertex < other.vertex;
59 bool operator==(
const SelectableRef &other)
const
61 return (uuid == other.uuid) && (vertex == other.vertex) && (type == other.type);
67 friend class CanvasGL;
68 friend class DragSelection;
69 friend class SelectablesRenderer;
72 Selectables(
const class Canvas &ca);
74 void append(
const UUID &uu, ObjectType ot,
const Coordf ¢er,
const Coordf &a,
const Coordf &b,
75 unsigned int vertex = 0, LayerRange layer = 10000,
bool always =
false);
76 void append(
const UUID &uu, ObjectType ot,
const Coordf ¢er,
unsigned int vertex = 0, LayerRange layer = 10000,
78 void append_angled(
const UUID &uu, ObjectType ot,
const Coordf ¢er,
const Coordf &box_center,
79 const Coordf &box_dim,
float angle,
unsigned int vertex = 0, LayerRange layer = 10000,
81 void append_line(
const UUID &uu, ObjectType ot,
const Coordf &p0,
const Coordf &p1,
float width,
82 unsigned int vertex = 0, LayerRange layer = 10000,
bool always =
false);
83 void update_preview(
const std::set<SelectableRef> &sel);
90 std::vector<Selectable> items;
91 std::vector<SelectableRef> items_ref;
92 std::map<SelectableRef, unsigned int> items_map;
93 std::vector<int> items_group;
96 int group_current = -1;