}
-Arrangement::Edge::Edge():
- aligned(false)
-{ }
-
void Arrangement::Edge::clear()
{
widgets.clear();
struct Edge
{
std::list<Widget *> widgets;
- bool aligned;
-
- Edge();
+ bool aligned = false;
bool empty() { return widgets.empty(); }
void clear();
};
Layout &layout;
- Arrangement *parent;
+ Arrangement *parent = 0;
Edge edges[4];
Arrangement(Layout &);
namespace Msp {
namespace GLtk {
-Button::Button(const std::string &t):
- text(),
- icon(0),
- pressed(false)
+Button::Button(const std::string &t)
{
input_type = INPUT_NAVIGATION;
set_text(t);
private:
Text text;
- const GL::Texture2D *icon;
- bool pressed;
+ const GL::Texture2D *icon = 0;
+ bool pressed = false;
public:
Button(const std::string & = std::string());
{ }
-Container::Container():
- click_focus(0),
- click_button(0),
- pointer_focus(0),
- pointer_grabbed(false),
- input_focus(0),
- saved_input_focus(0),
- touch_focus(0),
- children_rebuild_needed(false)
-{ }
-
Container::~Container()
{
while(!children.empty())
struct Child: public sigc::trackable
{
Container &container;
- Widget *widget;
+ Widget *widget = 0;
Time::TimeDelta time_since_animate;
Child(Container &, Widget *);
};
std::list<Child *> children;
- Widget *click_focus;
- unsigned click_button;
- Widget *pointer_focus;
- bool pointer_grabbed;
- Widget *input_focus;
- Widget *saved_input_focus;
- Widget *touch_focus;
- bool children_rebuild_needed;
-
- Container();
+ Widget *click_focus = 0;
+ unsigned click_button = 0;
+ Widget *pointer_focus = 0;
+ bool pointer_grabbed = false;
+ Widget *input_focus = 0;
+ Widget *saved_input_focus = 0;
+ Widget *touch_focus = 0;
+ bool children_rebuild_needed = false;
+
+ Container() = default;
public:
virtual ~Container();
namespace Msp {
namespace GLtk {
-Dialog::Dialog():
- stale(false)
-{ }
-
void Dialog::add_button(Button &button, int code)
{
add(button);
sigc::signal<void, int> signal_response;
private:
- bool stale;
+ bool stale = false;
public:
- Dialog();
-
virtual const char *get_class() const { return "dialog"; }
/** Adds an action button to the dialog. Pressing the button will invoke
namespace Msp {
namespace GLtk {
-DragHandle::DragHandle():
- dragging(false),
- drag_x(0),
- drag_y(0)
-{ }
-
void DragHandle::button_press(int x, int y, unsigned btn)
{
if(btn==1 && parent)
class MSPGLTK_API DragHandle: public Widget
{
private:
- bool dragging;
- int drag_x;
- int drag_y;
+ bool dragging = false;
+ int drag_x = 0;
+ int drag_y = 0;
public:
- DragHandle();
-
virtual const char *get_class() const { return "draghandle"; }
virtual void button_press(int, int, unsigned);
{
input_type = INPUT_NAVIGATION;
- dropped = false;
-
add(list);
list.set_visible(false);
list.set_view_all();
private:
List list;
- bool dropped;
+ bool dropped = false;
Text text;
public:
namespace Msp {
namespace GLtk {
-Entry::Entry(const string &t):
- text(),
- multiline(false),
- edit_width(10),
- edit_height(1),
- edit_pos(0),
- first_row(0),
- visible_rows(1),
- text_part(0),
- slider(0),
- got_key_press(false),
- cursor_blink(true),
- selection_active(false),
- selection_pos(0)
+Entry::Entry(const string &t)
{
input_type = INPUT_TEXT;
set_text(t);
private:
Text text;
- bool multiline;
- unsigned edit_width;
- unsigned edit_height;
- unsigned edit_pos;
- unsigned first_row;
- unsigned visible_rows;
- const Part *text_part;
- VSlider *slider;
- bool got_key_press;
- bool cursor_blink;
- bool selection_active;
- unsigned selection_pos;
+ bool multiline = false;
+ unsigned edit_width = 10;
+ unsigned edit_height = 1;
+ unsigned edit_pos = 0;
+ unsigned first_row = 0;
+ unsigned visible_rows = 1;
+ const Part *text_part = 0;
+ VSlider *slider = 0;
+ bool got_key_press = false;
+ bool cursor_blink = true;
+ bool selection_active = false;
+ unsigned selection_pos = 0;
public:
Entry(const std::string & = std::string());
}
-Sides::Sides():
- top(0),
- right(0),
- bottom(0),
- left(0)
-{ }
-
Sides::Sides(unsigned s):
top(s),
right(s),
*/
struct MSPGLTK_API Geometry
{
- int x, y;
- unsigned w, h;
+ int x = 0;
+ int y = 0;
+ unsigned w = 1;
+ unsigned h = 1;
- Geometry(): x(0), y(0), w(1), h(1) { }
+ Geometry() = default;
Geometry(int x_, int y_, unsigned w_, unsigned h_): x(x_), y(y_), w(w_), h(h_) { }
bool is_inside(int, int) const;
bool is_inside_relative(int, int) const;
void vertical(unsigned);
};
- unsigned top;
- unsigned right;
- unsigned bottom;
- unsigned left;
+ unsigned top = 0;
+ unsigned right = 0;
+ unsigned bottom = 0;
+ unsigned left = 0;
- Sides();
+ Sides() = default;
Sides(unsigned);
Sides(unsigned, unsigned);
Sides(unsigned, unsigned, unsigned);
*/
struct MSPGLTK_API Alignment
{
- float x, y;
- float w, h;
+ float x = 0.0f;
+ float y = 0.0f;
+ float w = 1.0f;
+ float h = 1.0f;
- Alignment(): x(0), y(0), w(1), h(1) { }
void apply(Geometry &, const Geometry &) const;
void apply(Geometry &, const Geometry &, const Sides &) const;
};
namespace Msp {
namespace GLtk {
-Graphic::Graphic():
- texture(0),
- repeat(false)
-{ }
-
void Graphic::build(unsigned wd, unsigned ht, GL::PrimitiveBuilder &bld) const
{
vector<float> x, y;
private:
Sides border;
Sides shadow;
- const GL::Texture2D *texture;
+ const GL::Texture2D *texture = 0;
Geometry slice;
- bool repeat;
+ bool repeat = false;
public:
- Graphic();
const Sides &get_border() const { return border; }
const Sides &get_shadow() const { return shadow; }
const GL::Texture2D *get_texture() const { return texture; }
Grid::Grid(Layout &l, unsigned c):
Arrangement(l),
- columns(c),
- first_row(true),
- column(0)
+ columns(c)
{ }
void Grid::skip()
std::vector<Column> columns;
Edge row_top;
Edge row_bottom;
- bool first_row;
- unsigned column;
+ bool first_row = true;
+ unsigned column = 0;
public:
Grid(Layout &, unsigned);
namespace GLtk {
Image::Image(const GL::Texture2D *i):
- image(i),
- keep_aspect(true)
+ image(i)
{
}
};
private:
- const GL::Texture2D *image;
+ const GL::Texture2D *image = 0;
std::string icon_name;
- bool keep_aspect;
+ bool keep_aspect = true;
public:
Image(const GL::Texture2D * = 0);
InputMethod(Root &);
public:
- virtual ~InputMethod() { }
+ virtual ~InputMethod() = default;
};
} // namespace GLtk
Column();
};
- unsigned n_columns;
- unsigned n_rows;
+ unsigned n_columns = 1;
+ unsigned n_rows = 1;
std::vector<Column> columns;
- bool solved;
- bool infeasible;
+ bool solved = false;
+ bool infeasible = false;
public:
LinearProgram(unsigned);
} };
-Layout::Layout():
- container(0),
- n_active_slots(0),
- margin(8),
- row_spacing(5),
- col_spacing(4)
-{
- n_slack_vars[0] = 0;
- n_slack_vars[1] = 0;
-}
-
Layout::~Layout()
{
for(Slot *s: slots)
Layout::Constraint::Constraint(ConstraintType t, Slot &s):
type(t),
- target(s),
- spacing(-1)
-{ }
-
-
-Layout::Packing::Packing():
- gravity(-1),
- expand(false)
+ target(s)
{ }
Layout::Slot::Slot(Layout &l, Widget &w):
layout(l),
- index(0),
- widget(w),
- ghost(false),
- floating(false)
+ widget(w)
{
vert_pack.gravity = 1;
widget.signal_autosize_changed.connect(sigc::mem_fun(this, &Slot::autosize_changed));
Layout::LinearProgram::LinearProgram(unsigned s):
n_columns(s),
- n_rows(1),
- columns(n_columns),
- solved(false),
- infeasible(false)
+ columns(n_columns)
{ }
Layout::LinearProgram::Row Layout::LinearProgram::add_row()
{
ConstraintType type;
Slot ⌖
- int spacing;
+ int spacing = -1;
Constraint(ConstraintType, Slot &);
};
struct Packing
{
- int gravity;
- bool expand;
-
- Packing();
+ int gravity = -1;
+ bool expand = false;
};
struct Slot: public sigc::trackable
{
Layout &layout;
- int index;
+ int index = 0;
Widget &widget;
Geometry autosize_geom;
Geometry geom;
std::list<Constraint> constraints;
Packing horiz_pack;
Packing vert_pack;
- bool ghost;
- bool floating;
+ bool ghost = false;
+ bool floating = false;
Slot(Layout &, Widget &);
class LinearProgram;
struct Pointers;
- Container *container;
+ Container *container = 0;
std::list<Slot *> slots;
- unsigned n_active_slots;
- unsigned n_slack_vars[2];
- Sides margin;
- unsigned row_spacing;
- unsigned col_spacing;
+ 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;
static Pointers pointers[2];
public:
- Layout();
~Layout();
void set_container(Container &);
LinearArrangement::LinearArrangement(Layout &l, Side p):
Arrangement(l),
- primary(p),
- opposite(static_cast<Side>((primary+2)%4)),
- first(true),
- split_here(false),
- gravity(opposite),
- internal_aligned(false),
- uniform(false),
- uniform_ref(0),
- next_spacing(-1)
+ primary(p)
{ }
void LinearArrangement::set_uniform(bool u)
};
protected:
- Side primary;
- Side opposite;
+ Side primary = RIGHT;
+ Side opposite = static_cast<Side>(primary^2);
Edge next;
- bool first;
- bool split_here;
- Side gravity;
- bool internal_aligned;
- bool uniform;
- Widget *uniform_ref;
- int next_spacing;
+ bool first = true;
+ bool split_here = false;
+ Side gravity = opposite;
+ bool internal_aligned = false;
+ bool uniform = false;
+ Widget *uniform_ref = 0;
+ int next_spacing = -1;
LinearArrangement(Layout &, Side);
List::List():
- data(new BasicListData<string>),
- own_data(true)
+ List(*new BasicListData<string>)
{
- init();
+ own_data = true;
}
List::List(ListData &d):
data(&d),
- own_data(false)
-{
- init();
-}
-
-void List::init()
+ observer(new DataObserver(*this))
{
input_type = INPUT_NAVIGATION;
- item_factory = 0;
- view_mode = LIST;
- sel_index = -1;
- focus_index = -1;
- first_row = 0;
- max_scroll = 0;
- view_rows = 5;
- view_columns = 5;
- items_part = 0;
- ignore_slider_change = false;
- dragging = false;
- drag_start_x = 0;
- drag_start_y = 0;
-
- observer = new DataObserver(*this);
-
add(slider);
slider.set_step(1);
slider.signal_value_changed.connect(sigc::mem_fun(this, &List::slider_value_changed));
class SimpleItem: public Item
{
protected:
- SimpleItem() { }
+ SimpleItem() = default;
virtual void on_style_change();
};
class MultiColumnItem: public Item
{
protected:
- MultiColumnItem() { }
+ MultiColumnItem() = default;
virtual void check_widths(std::vector<unsigned> &) const;
virtual void set_widths(const std::vector<unsigned> &);
class ItemFactory
{
protected:
- ItemFactory() { }
+ ItemFactory() = default;
public:
- virtual ~ItemFactory() { }
+ virtual ~ItemFactory() = default;
virtual void set_data(const ListData &) = 0;
virtual Item *create_item(unsigned) const = 0;
sigc::signal<void> signal_selection_cleared;
private:
- ListData *data;
- bool own_data;
- DataObserver *observer;
- ItemFactory *item_factory;
- ViewMode view_mode;
- int sel_index;
- int focus_index;
- unsigned first_row;
- unsigned max_scroll;
- unsigned view_rows;
- unsigned view_columns;
- const Part *items_part;
- bool ignore_slider_change;
- bool dragging;
- int drag_start_x;
- int drag_start_y;
+ ListData *data = 0;
+ bool own_data = false;
+ DataObserver *observer = 0;
+ ItemFactory *item_factory = 0;
+ ViewMode view_mode = LIST;
+ int sel_index = -1;
+ int focus_index = -1;
+ unsigned first_row = 0;
+ unsigned max_scroll = 0;
+ unsigned view_rows = 5;
+ unsigned view_columns = 5;
+ const Part *items_part = 0;
+ bool ignore_slider_change = false;
+ bool dragging = false;
+ int drag_start_x = 0;
+ int drag_start_y = 0;
VSlider slider;
std::vector<Item *> items;
public:
List();
List(ListData &);
-private:
- void init();
-public:
virtual ~List();
virtual const char *get_class() const { return "list"; }
sigc::signal<void, unsigned> signal_refresh_item;
protected:
- ListData() { }
+ ListData() = default;
public:
- virtual ~ListData() { }
+ virtual ~ListData() = default;
virtual unsigned size() const = 0;
virtual std::string get_string(unsigned) const = 0;
protected:
std::vector<T> items;
- ListDataStore() { }
+ ListDataStore() = default;
public:
void append(const T &v) { insert(items.size(), v); }
typedef std::string Func(const T &);
private:
- Func *func;
+ Func *func = 0;
public:
FunctionListData(Func f): func(f) { }
TypeRegistry<Panel::Loader::AddChildType, Panel::Loader &> Panel::widget_registry;
bool Panel::widget_registry_init_done = false;
-Panel::Panel():
- layout(0)
+Panel::Panel()
{
input_type = INPUT_NAVIGATION;
}
protected:
std::vector<Widget *> nav_order;
- Layout *layout;
+ Layout *layout = 0;
static TypeRegistry<Loader::AddChildType, Loader &> widget_registry;
static bool widget_registry_init_done;
Part::Part(const string &n):
name(n)
-{
- fill(graphic, graphic+N_STATES_, static_cast<Graphic *>(0));
-}
+{ }
const Graphic *Part::get_graphic(State state) const
{
private:
std::string name;
- const Graphic *graphic[N_STATES_];
+ const Graphic *graphic[N_STATES_] = { };
Geometry geom;
Sides margin;
Alignment align;
namespace Msp {
namespace GLtk {
-CachedPart::CachedPart():
- part(0),
- texture(0),
- mesh(0)
-{ }
-
CachedPart::~CachedPart()
{
delete mesh;
}
-PartCache::PartCache():
- rebuilding(false)
-{ }
-
void PartCache::begin_rebuild()
{
if(rebuilding)
struct CachedPart
{
- const Part *part;
- const GL::Texture2D *texture;
- GL::Mesh *mesh;
+ const Part *part = 0;
+ const GL::Texture2D *texture = 0;
+ GL::Mesh *mesh = 0;
- CachedPart();
~CachedPart();
};
typedef std::list<CachedPart> PartList;
private:
- bool rebuilding;
+ bool rebuilding = false;
PartList parts;
PartList::iterator next;
PartList::iterator current;
public:
- PartCache();
-
void begin_rebuild();
void insert_special(const Part &);
GL::Mesh &create_mesh(const Part &, const GL::Texture2D &);
namespace Msp {
namespace GLtk {
-ProgressBar::ProgressBar():
- range(1),
- fraction(0)
-{ }
-
void ProgressBar::set_range(float r)
{
if(r<=0)
class MSPGLTK_API ProgressBar: public Widget
{
private:
- float range;
- float fraction;
+ float range = 1.0f;
+ float fraction = 0.0f;
public:
- ProgressBar();
-
virtual const char *get_class() const { return "progressbar"; }
void set_range(float);
Resources::Resources()
{
- init();
+ add_type<Graphic>().keyword("graphic");
+ add_type<GL::Module>().creator([this](const string &n){ return create_module(n); });
+ add_type<GL::Sampler>().creator([this](const string &n){ return create_sampler(n); });
+ add_type<GL::Program>().creator([this](const string &n){ return create_program(n); });
+ add_type<GL::Texture2D>().keyword("texture").creator([this](const string &n){ return create_texture(n); });
+ add_type<GL::Font>().keyword("font");
+ add_type<Style>().keyword("style");
}
-Resources::Resources(const FS::Path &fn)
+Resources::Resources(const FS::Path &fn):
+ Resources()
{
- init();
-
dir_src = new DataFile::DirectorySource;
dir_src->add_directory(FS::dirname(fn));
add_source(*dir_src);
DataFile::load(*this, fn.str());
}
-void Resources::init()
-{
- default_font = 0;
- dir_src = 0;
- add_type<Graphic>().keyword("graphic");
- add_type<GL::Module>().creator([this](const string &n){ return create_module(n); });
- add_type<GL::Sampler>().creator([this](const string &n){ return create_sampler(n); });
- add_type<GL::Program>().creator([this](const string &n){ return create_program(n); });
- add_type<GL::Texture2D>().keyword("texture").creator([this](const string &n){ return create_texture(n); });
- add_type<GL::Font>().keyword("font");
- add_type<Style>().keyword("style");
-}
-
Resources::~Resources()
{
delete dir_src;
private:
FS::Path path;
- GL::Font *default_font;
- DataFile::DirectorySource *dir_src;
+ GL::Font *default_font = 0;
+ DataFile::DirectorySource *dir_src = 0;
public:
Resources();
Resources(const FS::Path &);
-private:
- void init();
-public:
~Resources();
const GL::Font &get_default_font() const;
namespace GLtk {
Root::Root(Resources &r, Graphics::Window &window):
- resources(r),
- keyboard(new Input::Keyboard(window)),
- input_method(0),
- mouse(new Input::Mouse(window)),
- touchscreen(0),
- own_input(true)
+ Root(r, &window, new Input::Keyboard(window), new Input::Mouse(window), 0)
{
- init(&window);
+ own_input = true;
}
Root::Root(Resources &r, Graphics::Window *window, Input::Keyboard *k, Input::Mouse *m, Input::Touchscreen *t):
resources(r),
keyboard(k),
- input_method(0),
mouse(m),
- touchscreen(t),
- own_input(false)
-{
- init(window);
-}
-
-void Root::init(Graphics::Window *window)
+ touchscreen(t)
{
if(window)
set_geometry(Geometry(0, 0, window->get_width(), window->get_height()));
- lbl_tooltip = 0;
- tooltip_target = 0;
-
camera.set_orthographic(geom.w, geom.h);
update_camera();
private:
Resources &resources;
- Input::Keyboard *keyboard;
- InputMethod *input_method;
- Input::Mouse *mouse;
- Input::Touchscreen *touchscreen;
- bool own_input;
- Label *lbl_tooltip;
- int pointer_x;
- int pointer_y;
+ Input::Keyboard *keyboard = 0;
+ InputMethod *input_method = 0;
+ Input::Mouse *mouse = 0;
+ Input::Touchscreen *touchscreen = 0;
+ bool own_input = false;
+ Label *lbl_tooltip = 0;
+ int pointer_x = 0;
+ int pointer_y = 0;
Time::TimeStamp tooltip_timeout;
Time::TimeStamp last_tick;
- Widget *tooltip_target;
+ Widget *tooltip_target = 0;
Msp::GL::Camera camera;
- Msp::GL::Program *shprog;
+ Msp::GL::Program *shprog = 0;
Msp::GL::Blend blend;
public:
/** Creates a Root widget with custom input devices. If window is not null,
it is used to set the widget's initial geometry. */
Root(Resources &, Graphics::Window *, Input::Keyboard *, Input::Mouse *, Input::Touchscreen * = 0);
-private:
- void init(Graphics::Window *);
-public:
virtual ~Root();
virtual const char *get_class() const { return "root"; }
namespace GLtk {
Slider::Slider(Direction d):
- dir(d),
- min(0),
- max(1),
- value(0),
- step(0.1),
- page_size(0.25),
- dragging(false),
- drag_area_size(0),
- drag_area_offset(0),
- slider_min_size(1),
- slider_size(1),
- total_margin(0)
+ dir(d)
{ }
void Slider::set_value(double v)
protected:
Direction dir;
- double min, max;
- double value;
- double step;
- double page_size;
-
- bool dragging;
- double drag_start_pos;
- double drag_start_value;
- unsigned drag_area_size;
- unsigned drag_area_offset;
- unsigned slider_min_size;
- unsigned slider_size;
- unsigned total_margin;
+ double min = 0.0;
+ double max = 1.0;
+ double value = 0.0;
+ double step = 0.1;
+ double page_size = 0.25;
+
+ bool dragging = false;
+ double drag_start_pos = 0.0;
+ double drag_start_value = 0.0;
+ unsigned drag_area_size = 0;
+ unsigned drag_area_offset = 0;
+ unsigned slider_min_size = 1;
+ unsigned slider_size = 1;
+ unsigned total_margin = 0;
Slider(Direction);
namespace Msp {
namespace GLtk {
-Style::Style():
- font(0),
- font_size(0),
- sampler(0)
-{ }
-
const GL::Font &Style::get_font() const
{
if(!font)
typedef std::list<Part> PartSeq;
private:
- const GL::Font *font;
- unsigned font_size;
+ const GL::Font *font = 0;
+ unsigned font_size = 0;
GL::Color font_color[N_STATES_];
- const GL::Sampler *sampler;
+ const GL::Sampler *sampler = 0;
PartSeq parts;
public:
- Style();
const GL::Font &get_font() const;
unsigned get_font_size() const { return font_size; }
const GL::Color &get_font_color(State) const;
SystemKeyboardInput::SystemKeyboardInput(Root &r, Input::Keyboard &k):
InputMethod(r),
- keyboard(k),
- modifier_state(0)
+ keyboard(k)
{
keyboard.signal_button_press.connect(sigc::mem_fun(this, &SystemKeyboardInput::key_press));
keyboard.signal_button_release.connect(sigc::mem_fun(this, &SystemKeyboardInput::key_release));
{
private:
Input::Keyboard &keyboard;
- unsigned modifier_state;
+ unsigned modifier_state = 0;
public:
SystemKeyboardInput(Root &, Input::Keyboard &);
Text::Text():
- style(0)
-{
- Line line;
- line.start = 0;
- line.bytes = 0;
- line.length = 0;
- line.width = 0;
- lines.push_back(line);
-}
+ lines(1)
+{ }
Text::Text(const Style &s, const string &t):
style(&s)
private:
struct Line
{
- unsigned start;
- unsigned bytes;
- unsigned length;
- unsigned width;
+ unsigned start = 0;
+ unsigned bytes = 0;
+ unsigned length = 0;
+ unsigned width = 0;
};
struct RenderData;
struct CoordsToGeomData;
- const Style *style;
+ const Style *style = 0;
std::string text;
std::vector<Line> lines;
namespace Msp {
namespace GLtk {
-Toggle::Toggle(const string &t):
- text(),
- pressed(false),
- value(false),
- exclusive(false)
+Toggle::Toggle(const string &t)
{
input_type = INPUT_NAVIGATION;
set_text(t);
private:
Text text;
- bool pressed;
- bool value;
- bool exclusive;
+ bool pressed = false;
+ bool value = false;
+ bool exclusive = false;
public:
Toggle(const std::string & = std::string());
namespace Msp {
namespace GLtk {
-Widget::Widget():
- style(0),
- state(NORMAL),
- visible(true),
- input_type(INPUT_NONE),
- parent(0),
- rebuild_needed(false)
-{ }
-
Widget::~Widget()
{
if(parent)
protected:
Geometry geom;
std::string style_name;
- const Style *style;
- State state;
- bool visible;
- InputType input_type;
- Container *parent;
+ const Style *style = 0;
+ State state = NORMAL;
+ bool visible = true;
+ InputType input_type = INPUT_NONE;
+ Container *parent = 0;
std::string tooltip;
PartCache part_cache;
- bool rebuild_needed;
+ bool rebuild_needed = false;
Time::TimeDelta anim_interval;
- Widget();
+ Widget() = default;
private:
Widget(const Widget &);
Widget &operator=(const Widget &);