};
Layout &layout;
- Arrangement *parent = 0;
+ Arrangement *parent = nullptr;
Edge edges[4];
Arrangement(Layout &);
private:
Text text;
- const GL::Texture2D *icon = 0;
+ const GL::Texture2D *icon = nullptr;
bool pressed = false;
public:
if(i==children.end())
throw hierarchy_error("widget not in container");
- wdg.set_parent(0);
+ wdg.set_parent(nullptr);
delete *i;
children.erase(i);
if(wdg.get_animation_interval())
if((*--i)->widget->is_visible() && (*i)->widget->get_geometry().is_inside(x, y))
return (*i)->widget;
- return 0;
+ return nullptr;
}
Widget *Container::get_descendant_at(int x, int y) const
{
if(child==click_focus && btn==click_button)
{
- click_focus = 0;
+ click_focus = nullptr;
if(!pointer_focus)
set_pointer_focus(get_child_at(x, y));
}
{
Widget *child = get_pointer_target(x, y, false);
if(!pointer_grabbed)
- set_pointer_focus((child && child->get_geometry().is_inside(x, y)) ? child : 0);
+ set_pointer_focus((child && child->get_geometry().is_inside(x, y)) ? child : nullptr);
if(child)
{
if(child && child->is_enabled())
return child;
else
- return 0;
+ return nullptr;
}
}
void Container::pointer_leave()
{
Widget::pointer_leave();
- set_pointer_focus(0);
+ set_pointer_focus(nullptr);
}
void Container::touch_press(int x, int y, unsigned finger)
{
// TODO track focus for each finger separately
if(child==touch_focus)
- touch_focus = 0;
+ touch_focus = nullptr;
const Geometry &cgeom = child->get_geometry();
child->touch_release(x-cgeom.x, y-cgeom.y, finger);
void Container::focus_out()
{
saved_input_focus = input_focus;
- set_input_focus(0);
+ set_input_focus(nullptr);
Widget::focus_out();
}
if(!v)
{
if(widget==container.click_focus)
- container.click_focus = 0;
+ container.click_focus = nullptr;
if(widget==container.pointer_focus)
- container.set_pointer_focus(0);
+ container.set_pointer_focus(nullptr);
if(widget==container.input_focus)
- container.set_input_focus(0);
+ container.set_input_focus(nullptr);
}
}
if(container.pointer_grabbed && container.pointer_focus==widget)
{
// XXX Should set to the widget under pointer
- container.set_pointer_focus(0);
+ container.set_pointer_focus(nullptr);
container.signal_ungrab_pointer.emit();
}
}
struct Child: public sigc::trackable
{
Container &container;
- Widget *widget = 0;
+ Widget *widget = nullptr;
Time::TimeDelta time_since_animate;
Child(Container &, Widget *);
};
std::list<Child *> children;
- Widget *click_focus = 0;
+ Widget *click_focus = nullptr;
unsigned click_button = 0;
- Widget *pointer_focus = 0;
+ Widget *pointer_focus = nullptr;
bool pointer_grabbed = false;
- Widget *input_focus = 0;
- Widget *saved_input_focus = 0;
- Widget *touch_focus = 0;
+ Widget *input_focus = nullptr;
+ Widget *saved_input_focus = nullptr;
+ Widget *touch_focus = nullptr;
bool children_rebuild_needed = false;
Container() = default;
if(!style)
{
- text_part = 0;
+ text_part = nullptr;
return;
}
if(!multiline || !text_part)
return;
- visible_rows = text.get_visible_lines(*text_part, geom, 0);
+ visible_rows = text.get_visible_lines(*text_part, geom, nullptr);
unsigned row, col;
text.offset_to_coords(edit_pos, row, col);
unsigned edit_pos = 0;
unsigned first_row = 0;
unsigned visible_rows = 1;
- const Part *text_part = 0;
- VSlider *slider = 0;
+ const Part *text_part = nullptr;
+ VSlider *slider = nullptr;
bool got_key_press = false;
bool cursor_blink = true;
bool selection_active = false;
private:
Sides border;
Sides shadow;
- const GL::Texture2D *texture = 0;
+ const GL::Texture2D *texture = nullptr;
Geometry slice;
bool repeat = false;
if(root)
{
if(icon_name.empty())
- image = 0;
+ image = nullptr;
else
image = &root->get_resources().get<GL::Texture2D>(icon_name);
signal_autosize_changed.emit();
}
}
- image = 0;
+ image = nullptr;
}
void Image::rebuild_special(const Part &part)
};
private:
- const GL::Texture2D *image = 0;
+ const GL::Texture2D *image = nullptr;
std::string icon_name;
bool keep_aspect = true;
public:
- Image(const GL::Texture2D * = 0);
+ Image(const GL::Texture2D * = nullptr);
virtual const char *get_class() const { return "image"; }
Arrangement *Layout::get_arrangement() const
{
if(arrangement_stack.empty())
- return 0;
+ return nullptr;
else
return arrangement_stack.back();
}
class LinearProgram;
struct Pointers;
- Container *container = 0;
+ Container *container = nullptr;
std::list<Slot *> slots;
unsigned n_active_slots = 0;
unsigned n_slack_vars[2] = { 0, 0 };
{
uniform = u;
if(!uniform)
- uniform_ref = 0;
+ uniform_ref = nullptr;
}
void LinearArrangement::split()
Side gravity = opposite;
bool internal_aligned = false;
bool uniform = false;
- Widget *uniform_ref = 0;
+ Widget *uniform_ref = nullptr;
int next_spacing = -1;
LinearArrangement(Layout &, Side);
List::Item *List::create_item(unsigned index)
{
- Item *item = 0;
+ Item *item = nullptr;
if(item_factory)
item = item_factory->create_item(index);
else
{
sel_index = -1;
focus_index = -1;
- set_input_focus(0);
+ set_input_focus(nullptr);
signal_selection_cleared.emit();
}
else
void List::on_style_change()
{
- items_part = (style ? style->get_part("items") : 0);
+ items_part = (style ? style->get_part("items") : nullptr);
}
void List::move_focus(Navigation nav, bool select)
{
delete list.items[i];
// Avoid stale pointer while create_item is executing
- list.items[i] = 0;
+ list.items[i] = nullptr;
list.items[i] = list.create_item(i);
list.items_changed();
}
sigc::signal<void> signal_selection_cleared;
private:
- ListData *data = 0;
+ ListData *data = nullptr;
bool own_data = false;
- DataObserver *observer = 0;
- ItemFactory *item_factory = 0;
+ DataObserver *observer = nullptr;
+ ItemFactory *item_factory = nullptr;
ViewMode view_mode = LIST;
int sel_index = -1;
int focus_index = -1;
unsigned max_scroll = 0;
unsigned view_rows = 5;
unsigned view_columns = 5;
- const Part *items_part = 0;
+ const Part *items_part = nullptr;
bool ignore_slider_change = false;
bool dragging = false;
int drag_start_x = 0;
Panel::~Panel()
{
delete layout;
- layout = 0;
+ layout = nullptr;
}
void Panel::set_layout(Layout *l)
Widget *Panel::find_next_child(int origin_x, int origin_y, int origin_dim, int nav_x, int nav_y) const
{
- Widget *sibling = 0;
+ Widget *sibling = nullptr;
int best_score = 0;
for(const Child *c: children)
{
Panel::Loader::Loader(Panel &p, map<string, Widget *> &m):
DataFile::DerivedObjectLoader<Panel, Widget::Loader>(p),
wdg_map(m),
- last_widget(0)
+ last_widget(nullptr)
{
if(!widget_registry_init_done)
{
protected:
std::vector<Widget *> nav_order;
- Layout *layout = 0;
+ Layout *layout = nullptr;
static TypeRegistry<Loader::AddChildType, Loader &> widget_registry;
static bool widget_registry_init_done;
void Part::Loader::graphic(State s, const string &n)
{
- Graphic *grph = (n.empty() ? 0 : &get_collection().get<Graphic>(n));
+ Graphic *grph = (n.empty() ? nullptr : &get_collection().get<Graphic>(n));
for(int i=0; i<N_STATES_; ++i)
if((i&s)==s)
obj.graphic[i] = grph;
struct CachedPart
{
- const Part *part = 0;
- const GL::Texture2D *texture = 0;
- GL::Mesh *mesh = 0;
+ const Part *part = nullptr;
+ const GL::Texture2D *texture = nullptr;
+ GL::Mesh *mesh = nullptr;
~CachedPart();
};
GL::Module *Resources::create_module(const string &name)
{
if(name!="ui.glsl")
- return 0;
+ return nullptr;
- GL::Module *mod = 0;
+ GL::Module *mod = nullptr;
if(GL::get_backend_api()==GL::VULKAN)
mod = new GL::SpirVModule;
else
GL::Program *Resources::create_program(const string &name)
{
if(name!="ui.shader")
- return 0;
+ return nullptr;
return new GL::Program(get<GL::Module>("ui.glsl"));
}
return sampler;
}
- return 0;
+ return nullptr;
}
GL::Texture2D *Resources::create_texture(const string &name)
return tex;
}
- return 0;
+ return nullptr;
}
private:
FS::Path path;
- GL::Font *default_font = 0;
- DataFile::DirectorySource *dir_src = 0;
+ GL::Font *default_font = nullptr;
+ DataFile::DirectorySource *dir_src = nullptr;
public:
Resources();
namespace GLtk {
Root::Root(Resources &r, Graphics::Window &window):
- Root(r, &window, new Input::Keyboard(window), new Input::Mouse(window), 0)
+ Root(r, &window, new Input::Keyboard(window), new Input::Mouse(window), nullptr)
{
own_input = true;
}
renderer.set_camera(camera);
renderer.set_shader_program(shprog);
renderer.set_blend(&blend);
- renderer.set_depth_test(0);
+ renderer.set_depth_test(nullptr);
Widget::render(renderer);
}
{
if(lbl_tooltip)
lbl_tooltip->set_visible(false);
- tooltip_target = 0;
+ tooltip_target = nullptr;
}
if(pointer_focus)
private:
Resources &resources;
- Input::Keyboard *keyboard = 0;
- InputMethod *input_method = 0;
- Input::Mouse *mouse = 0;
- Input::Touchscreen *touchscreen = 0;
+ Input::Keyboard *keyboard = nullptr;
+ InputMethod *input_method = nullptr;
+ Input::Mouse *mouse = nullptr;
+ Input::Touchscreen *touchscreen = nullptr;
bool own_input = false;
- Label *lbl_tooltip = 0;
+ Label *lbl_tooltip = nullptr;
int pointer_x = 0;
int pointer_y = 0;
Time::TimeStamp tooltip_timeout;
Time::TimeStamp last_tick;
- Widget *tooltip_target = 0;
+ Widget *tooltip_target = nullptr;
Msp::GL::Camera camera;
- Msp::GL::Program *shprog = 0;
+ Msp::GL::Program *shprog = nullptr;
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);
+ Root(Resources &, Graphics::Window *, Input::Keyboard *, Input::Mouse *, Input::Touchscreen * = nullptr);
virtual ~Root();
virtual const char *get_class() const { return "root"; }
const Part *Style::get_part(const string &name) const
{
auto i = find_if(parts, [&name](const Part &p){ return p.get_name()==name; });
- return (i!=parts.end() ? &*i : 0);
+ return (i!=parts.end() ? &*i : nullptr);
}
bool Style::compare_states(State s1, State s2) const
typedef std::list<Part> PartSeq;
private:
- const GL::Font *font = 0;
+ const GL::Font *font = nullptr;
unsigned font_size = 0;
GL::Color font_color[N_STATES_];
- const GL::Sampler *sampler = 0;
+ const GL::Sampler *sampler = nullptr;
PartSeq parts;
public:
struct RenderData;
struct CoordsToGeomData;
- const Style *style = 0;
+ const Style *style = nullptr;
std::string text;
std::vector<Line> lines;
if(parent)
{
Container *p = parent;
- parent = 0;
+ parent = nullptr;
p->remove(*this);
}
}
catch(...)
{
// The container has not yet added the widget as its child
- parent = 0;
+ parent = nullptr;
throw;
}
}
for(top=this; top->parent; top=top->parent) ;
Root *root = dynamic_cast<Root *>(top);
if(!root)
- style = 0;
+ style = nullptr;
else
{
string sname = get_class();
protected:
Geometry geom;
std::string style_name;
- const Style *style = 0;
+ const Style *style = nullptr;
State state = NORMAL;
bool visible = true;
InputType input_type = INPUT_NONE;
- Container *parent = 0;
+ Container *parent = nullptr;
std::string tooltip;
PartCache part_cache;
bool rebuild_needed = false;