#ifndef MSP_GLTK_ARRANGEMENT_H_
#define MSP_GLTK_ARRANGEMENT_H_
-#include <list>
#include <stdexcept>
+#include <vector>
#include <msp/core/noncopyable.h>
#include "layout.h"
#include "mspgltk_api.h"
struct Edge
{
- std::list<Widget *> widgets;
+ std::vector<Widget *> widgets;
bool aligned = false;
bool empty() { return widgets.empty(); }
child.set_geometry(determine_child_geometry(child, part));
}
-list<Widget *> Container::get_children() const
+vector<Widget *> Container::get_children() const
{
- list<Widget *> result;
+ vector<Widget *> result;
for(const Child *c: children)
result.push_back(c->widget);
return result;
if(i==children.end())
throw hierarchy_error("widget not in container");
- children.splice(children.end(), children, i);
+ Child *c = *i;
+ children.erase(i);
+ children.push_back(c);
}
void Container::set_pointer_focus(Widget *wdg, bool grab)
#ifndef MSP_GLTK_CONTAINER_H_
#define MSP_GLTK_CONTAINER_H_
-#include <list>
#include <stdexcept>
+#include <vector>
#include <sigc++/trackable.h>
#include "mspgltk_api.h"
#include "widget.h"
void rebuild_needed();
};
- std::list<Child *> children;
+ std::vector<Child *> children;
Widget *click_focus = nullptr;
unsigned click_button = 0;
Widget *pointer_focus = nullptr;
void autosize_child(const Widget &, const Part &, Geometry &) const;
void reposition_child(Widget &, const Part &) const;
public:
- std::list<Widget *> get_children() const;
+ std::vector<Widget *> get_children() const;
Widget *find_child_at(int, int) const;
Widget *find_descendant_at(int, int) const;
void raise(Widget &);
{
for(auto k=s->constraints.begin(); k!=s->constraints.end(); )
{
- if(&k->target==*i)
- s->constraints.erase(k++);
+ if(k->target==*i)
+ k = s->constraints.erase(k);
else
++k;
}
}
for(const Constraint &c: s->constraints)
- if(c.target.index>s->index && (c.type&SLACK))
+ if(c.target->index>s->index && (c.type&SLACK))
++n_slack_vars[c.type&1];
}
}
Slot &tgt_slot = get_slot_for_widget(tgt);
for(const Constraint &c: src_slot.constraints)
- if(c.type==type && &c.target==&tgt_slot)
+ if(c.type==type && c.target==&tgt_slot)
return;
src_slot.constraints.push_back(Constraint(type, tgt_slot));
/* Add rows for user-defined constraints. Constraints are always added
in pairs, so it's only necessary to create a row for one half. */
for(const Constraint &c: s->constraints)
- if(c.target.index>s->index && (c.type&1)==dir)
+ if(c.target->index>s->index && (c.type&1)==dir)
{
LinearProgram::Row row = linprog.add_row();
float polarity = ((c.type&SELF_DIM) ? -1 : 1);
if(c.type&SELF_DIM)
row[s->index*5+1] = polarity*dim_weight;
if(c.type&TARGET_POS)
- row[c.target.index*5] = -polarity;
+ row[c.target->index*5] = -polarity;
if(c.type&TARGET_DIM)
- row[c.target.index*5+1] = -polarity*dim_weight;
+ row[c.target->index*5+1] = -polarity*dim_weight;
if(c.type&SPACING)
row.back() = (c.spacing>=0 ? c.spacing : this->*(ptrs.spacing));
if(c.type&SLACK)
Layout::Constraint::Constraint(ConstraintType t, Slot &s):
type(t),
- target(s)
+ target(&s)
{ }
#ifndef MSP_GLTK_LAYOUT_H_
#define MSP_GLTK_LAYOUT_H_
-#include <list>
#include <set>
+#include <vector>
#include <sigc++/trackable.h>
#include <msp/strings/lexicalcast.h>
#include "geometry.h"
struct Constraint
{
ConstraintType type;
- Slot ⌖
+ Slot *target = nullptr;
int spacing = -1;
Constraint(ConstraintType, Slot &);
Widget &widget;
Geometry autosize_geom;
Geometry geom;
- std::list<Constraint> constraints;
+ std::vector<Constraint> constraints;
Packing horiz_pack;
Packing vert_pack;
bool ghost = false;
struct Pointers;
Container *container = nullptr;
- std::list<Slot *> slots;
+ std::vector<Slot *> slots;
unsigned n_active_slots = 0;
unsigned n_slack_vars[2] = { 0, 0 };
Sides margin{ 8 };
unsigned row_spacing = 5;
unsigned col_spacing = 4;
Geometry autosize_geom;
- std::list<Arrangement *> arrangement_stack;
+ std::vector<Arrangement *> arrangement_stack;
static Pointers pointers[2];
~Rebuild() { cache.end_rebuild(); }
};
- typedef std::list<CachedPart> PartList;
-
private:
bool rebuilding = false;
- PartList parts;
- PartList::iterator next;
- PartList::iterator current;
+ std::vector<CachedPart> parts;
+ std::vector<CachedPart>::iterator next;
+ std::vector<CachedPart>::iterator current;
public:
void begin_rebuild();
GL::Mesh &create_mesh(const Part &, const GL::Texture2D &);
void end_rebuild();
- const PartList &get_parts() const { return parts; }
+ const std::vector<CachedPart> &get_parts() const { return parts; }
};
} // namespace GLtk
void unnamed_part();
};
- typedef std::list<Part> PartSeq;
-
private:
const GL::Font *font = nullptr;
unsigned font_size = 0;
GL::Color font_color[N_STATES_];
const GL::Sampler *sampler = nullptr;
- PartSeq parts;
+ std::vector<Part> parts;
public:
const GL::Font &get_font() const;
unsigned get_font_size() const { return font_size; }
const GL::Color &get_font_color(State) const;
const GL::Sampler &get_sampler() const;
- const PartSeq &get_parts() const { return parts; }
+ const std::vector<Part> &get_parts() const { return parts; }
const Part *find_part(const std::string &) const;
bool compare_states(State, State) const;
};