]> git.tdb.fi Git - libs/gltk.git/commitdiff
Use nullptr instead of 0 for pointers
authorMikko Rasa <tdb@tdb.fi>
Sun, 20 Aug 2023 09:55:01 +0000 (12:55 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 20 Aug 2023 10:01:19 +0000 (13:01 +0300)
28 files changed:
source/arrangement.h
source/button.h
source/container.cpp
source/container.h
source/entry.cpp
source/entry.h
source/graphic.h
source/image.cpp
source/image.h
source/layout.cpp
source/layout.h
source/lineararrangement.cpp
source/lineararrangement.h
source/list.cpp
source/list.h
source/panel.cpp
source/panel.h
source/part.cpp
source/partcache.h
source/resources.cpp
source/resources.h
source/root.cpp
source/root.h
source/style.cpp
source/style.h
source/text.h
source/widget.cpp
source/widget.h

index 164a091c6a9032bdb3078d54e928e3ceee480483..2decb3eb4fc5ef71513fe9985b86462e5cf04425 100644 (file)
@@ -41,7 +41,7 @@ protected:
        };
 
        Layout &layout;
-       Arrangement *parent = 0;
+       Arrangement *parent = nullptr;
        Edge edges[4];
 
        Arrangement(Layout &);
index 09084f183a938defe07b07a45045cacb4ab1532a..962b2e11908e0608b2ced7133274a0d0e648ec59 100644 (file)
@@ -29,7 +29,7 @@ public:
 
 private:
        Text text;
-       const GL::Texture2D *icon = 0;
+       const GL::Texture2D *icon = nullptr;
        bool pressed = false;
 
 public:
index ef837a2d26180a20faa9808bec18fc7868cab0d3..4f4d2a370152fe6fda3b05c2e65de7d92d59ef35 100644 (file)
@@ -35,7 +35,7 @@ void Container::remove(Widget &wdg)
        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())
@@ -92,7 +92,7 @@ Widget *Container::get_child_at(int x, int y) const
                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
@@ -209,7 +209,7 @@ void Container::button_release(int x, int y, unsigned btn)
        {
                if(child==click_focus && btn==click_button)
                {
-                       click_focus = 0;
+                       click_focus = nullptr;
                        if(!pointer_focus)
                                set_pointer_focus(get_child_at(x, y));
                }
@@ -223,7 +223,7 @@ void Container::pointer_motion(int x, int 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)
        {
@@ -246,14 +246,14 @@ Widget *Container::get_pointer_target(int x, int y, bool touch) const
                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)
@@ -275,7 +275,7 @@ void Container::touch_release(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);
@@ -325,7 +325,7 @@ void Container::focus_in()
 void Container::focus_out()
 {
        saved_input_focus = input_focus;
-       set_input_focus(0);
+       set_input_focus(nullptr);
        Widget::focus_out();
 }
 
@@ -394,11 +394,11 @@ void Container::Child::visibility_changed(bool v)
        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);
        }
 }
 
@@ -424,7 +424,7 @@ void Container::Child::ungrab_pointer()
        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();
        }
 }
index 61502e44177c2d963f617da91fc1e4e5d86a570d..adaee6f4bb02c17b021e6386e6eb988809c15051 100644 (file)
@@ -24,7 +24,7 @@ protected:
        struct Child: public sigc::trackable
        {
                Container &container;
-               Widget *widget = 0;
+               Widget *widget = nullptr;
                Time::TimeDelta time_since_animate;
 
                Child(Container &, Widget *);
@@ -39,13 +39,13 @@ protected:
        };
 
        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;
index 19bbaf9dc693f685a875ef962dcb03ac3a42340c..5aadbc262d355805e3b4fe338714a2a0bb8d4311 100644 (file)
@@ -343,7 +343,7 @@ void Entry::on_style_change()
 
        if(!style)
        {
-               text_part = 0;
+               text_part = nullptr;
                return;
        }
 
@@ -468,7 +468,7 @@ void Entry::check_view_range()
        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);
index 871024da89af32b33c4f8ae1864370a817f488e7..66b3327d70c29b3d7200d91ca0d9c898b3ebec6e 100644 (file)
@@ -45,8 +45,8 @@ private:
        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;
index b114d7e1c96eba41fd555453d71cb6d1b5dd4cc4..32a06864f9dcebf260c9f52e154b141e95660ba1 100644 (file)
@@ -33,7 +33,7 @@ public:
 private:
        Sides border;
        Sides shadow;
-       const GL::Texture2D *texture = 0;
+       const GL::Texture2D *texture = nullptr;
        Geometry slice;
        bool repeat = false;
 
index 8dbf6cf74fe881e6e871be3894e0ae51aa3147b6..655ecc252d2b81aa3187195e6d662611835e283a 100644 (file)
@@ -61,7 +61,7 @@ void Image::update_icon()
                if(root)
                {
                        if(icon_name.empty())
-                               image = 0;
+                               image = nullptr;
                        else
                                image = &root->get_resources().get<GL::Texture2D>(icon_name);
                        signal_autosize_changed.emit();
@@ -70,7 +70,7 @@ void Image::update_icon()
                }
        }
 
-       image = 0;
+       image = nullptr;
 }
 
 void Image::rebuild_special(const Part &part)
index 026aaca82aebbcc4b326b706d4df052f98ea3d8d..12e77f2a7f6df28f935bcf2c66dac9290913f33f 100644 (file)
@@ -21,12 +21,12 @@ public:
        };
 
 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"; }
 
index b6248e6ad8511bb8dbaa9bc0d1ba5b1eaeaa18ba..7fcbf103b085808fe34fa0d45f67b54fd5442251 100644 (file)
@@ -136,7 +136,7 @@ void Layout::push_arrangement(Arrangement &arr)
 Arrangement *Layout::get_arrangement() const
 {
        if(arrangement_stack.empty())
-               return 0;
+               return nullptr;
        else
                return arrangement_stack.back();
 }
index 8b1c527640e4e29e69bd61c3f9fab4a4188044be..aa11e965bf19cbc042b968c65d38506686625f27 100644 (file)
@@ -172,7 +172,7 @@ private:
        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 };
index 3ac686e85d9fded12a71fdfaabf7b6a75f71f4e0..269b68e34f71fe9933b668695d51b0eaa5806662 100644 (file)
@@ -12,7 +12,7 @@ void LinearArrangement::set_uniform(bool u)
 {
        uniform = u;
        if(!uniform)
-               uniform_ref = 0;
+               uniform_ref = nullptr;
 }
 
 void LinearArrangement::split()
index 917b595cb8caa8dae8259fa579cb619ef94bffe7..f0ec2453d02121d445b3caf9b3307948709c0110 100644 (file)
@@ -31,7 +31,7 @@ protected:
        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);
index 897ea39ebadb972decb3e7fe8dd8a876ac58089d..e0d2bd81c150d62918bedd77b7eebe3b1537baac 100644 (file)
@@ -118,7 +118,7 @@ void List::items_changed()
 
 List::Item *List::create_item(unsigned index)
 {
-       Item *item = 0;
+       Item *item = nullptr;
        if(item_factory)
                item = item_factory->create_item(index);
        else
@@ -162,7 +162,7 @@ void List::set_selected_index(int i)
        {
                sel_index = -1;
                focus_index = -1;
-               set_input_focus(0);
+               set_input_focus(nullptr);
                signal_selection_cleared.emit();
        }
        else
@@ -330,7 +330,7 @@ bool List::navigate(Navigation nav)
 
 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)
@@ -567,7 +567,7 @@ void List::DataObserver::refresh_item(unsigned i)
 {
        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();
 }
index 9bc30c685d146a88d9d3b0fc8b886037f7ffa724..d6cb2b554d859dc04d32307c4bdd9ec6d90dcfdb 100644 (file)
@@ -157,10 +157,10 @@ public:
        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;
@@ -168,7 +168,7 @@ private:
        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;
index 871d7a2d9ebffb211d1bdc3f389a4fd6374e31e6..155682616f44245bbe9ff5dbeb9f46f56a55552d 100644 (file)
@@ -35,7 +35,7 @@ Panel::Panel()
 Panel::~Panel()
 {
        delete layout;
-       layout = 0;
+       layout = nullptr;
 }
 
 void Panel::set_layout(Layout *l)
@@ -134,7 +134,7 @@ bool Panel::navigate(Navigation nav)
 
 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)
        {
@@ -210,7 +210,7 @@ void Panel::on_child_removed(Widget &wdg)
 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)
        {
index 4b013a8b469eb363ac0a79a35c60b757aecee267..b5755d0cbb1d4f39d7c0975d45cb19656eac8cf0 100644 (file)
@@ -67,7 +67,7 @@ private:
 
 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;
index 21dacc64da547123209388128b0f246b4d6f8014..dbccc060e828c8b4b5f1f07a5f650dfc94d638fa 100644 (file)
@@ -63,7 +63,7 @@ void Part::Loader::graphic_normal(const string &n)
 
 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;
index af697339efcfa0ed5e46cb998235e0c156ac13c0..137bce4c37539a8c032f27b36cff0c35afc89f58 100644 (file)
@@ -12,9 +12,9 @@ class Part;
 
 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();
 };
index 3cfd8306275cb5e0ae47268e4dd013749531d310..078b58b71696559b16b12267f0e39c8759852373 100644 (file)
@@ -45,9 +45,9 @@ const GL::Font &Resources::get_default_font() const
 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
@@ -64,7 +64,7 @@ GL::Module *Resources::create_module(const string &name)
 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"));
 }
@@ -80,7 +80,7 @@ GL::Sampler *Resources::create_sampler(const string &name)
                return sampler;
        }
 
-       return 0;
+       return nullptr;
 }
 
 GL::Texture2D *Resources::create_texture(const string &name)
@@ -98,7 +98,7 @@ GL::Texture2D *Resources::create_texture(const string &name)
                        return tex;
                }
 
-       return 0;
+       return nullptr;
 }
 
 
index 1fd030d03438674510ac66e7cb6c49e13cfca5df..6a1c603c050766487a27995270c65d136f55ba91 100644 (file)
@@ -37,8 +37,8 @@ public:
 
 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();
index 5ea447fecdf46d48f0013aa3f832e5aef9fe8348..376b9d53c819beec1b2f4548d771571535073b8e 100644 (file)
@@ -11,7 +11,7 @@ namespace Msp {
 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;
 }
@@ -133,7 +133,7 @@ void Root::render(GL::Renderer &renderer, GL::Tag tag) const
        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);
 }
 
@@ -189,7 +189,7 @@ bool Root::axis_motion_event(unsigned, float, float)
                {
                        if(lbl_tooltip)
                                lbl_tooltip->set_visible(false);
-                       tooltip_target = 0;
+                       tooltip_target = nullptr;
                }
 
                if(pointer_focus)
index 9ebe7cf57d823fdf59cf63d25829251f51b0b806..0fe624f4c4e3f5d03e7fab70ee4bc00d594cd20e 100644 (file)
@@ -32,19 +32,19 @@ public:
 
 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:
@@ -54,7 +54,7 @@ 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"; }
index d1dea041dca0e010dcfa294c9252259c5fea2d60..a339c0cb2bd913f2e336228cd0fb3fd2c63afb36 100644 (file)
@@ -32,7 +32,7 @@ const GL::Sampler &Style::get_sampler() const
 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
index ee25b251dcb50ba932efe40d368f465ab78719c9..56870da615b8e1a9efb7062d0fea9869c7512a4c 100644 (file)
@@ -36,10 +36,10 @@ public:
        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:
index cdde08c2b081aa42804ec16bf6d0656c343c8d3c..6de3573fc6dfda35495b40d303065d412413a599 100644 (file)
@@ -31,7 +31,7 @@ private:
        struct RenderData;
        struct CoordsToGeomData;
 
-       const Style *style = 0;
+       const Style *style = nullptr;
        std::string text;
        std::vector<Line> lines;
 
index 0181e451e95163f40d67c06fda793dceb554e55b..4d990009d81002ece8cc5a8caeb2ac73606e0b3c 100644 (file)
@@ -15,7 +15,7 @@ Widget::~Widget()
        if(parent)
        {
                Container *p = parent;
-               parent = 0;
+               parent = nullptr;
                p->remove(*this);
        }
 }
@@ -110,7 +110,7 @@ void Widget::set_parent(Container *p)
        catch(...)
        {
                // The container has not yet added the widget as its child
-               parent = 0;
+               parent = nullptr;
                throw;
        }
 }
@@ -127,7 +127,7 @@ void Widget::update_style()
        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();
index 9b86691e48343344b723af0ad2d90726d82ff6b6..14d15fc7a5678a33fed2062b81d530719e62cabc 100644 (file)
@@ -47,11 +47,11 @@ public:
 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;