From: Mikko Rasa Date: Sun, 20 Aug 2023 10:00:21 +0000 (+0300) Subject: Use the override specifier when overriding a virtual function X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=d10d1de6d17c285c63d7b3cea549017aaa1ddb01;p=libs%2Fgltk.git Use the override specifier when overriding a virtual function --- diff --git a/source/button.h b/source/button.h index 962b2e1..165ca4f 100644 --- a/source/button.h +++ b/source/button.h @@ -35,25 +35,25 @@ private: public: Button(const std::string & = std::string()); - virtual const char *get_class() const { return "button"; } + const char *get_class() const override { return "button"; } private: - virtual void autosize_special(const Part &, Geometry &) const; + void autosize_special(const Part &, Geometry &) const override; public: void set_text(const std::string &); void set_icon(const GL::Texture2D *); private: - virtual void rebuild_special(const Part &); + void rebuild_special(const Part &) override; public: - virtual void button_press(int, int, unsigned); - virtual void button_release(int, int, unsigned); - virtual void pointer_motion(int, int); - virtual bool navigate(Navigation); + void button_press(int, int, unsigned) override; + void button_release(int, int, unsigned) override; + void pointer_motion(int, int) override; + bool navigate(Navigation) override; private: - virtual void on_style_change(); + void on_style_change() override; }; } // namespace GLtk diff --git a/source/column.h b/source/column.h index 6d6acd6..d82c8ca 100644 --- a/source/column.h +++ b/source/column.h @@ -13,7 +13,7 @@ public: Column(Layout &); private: - virtual void finish_widget(Widget &); + void finish_widget(Widget &) override; }; } // namespace GLtk diff --git a/source/container.h b/source/container.h index a0cba3b..26100b7 100644 --- a/source/container.h +++ b/source/container.h @@ -75,28 +75,28 @@ private: void check_animation_interval(); protected: - virtual void rebuild_hierarchy(); + void rebuild_hierarchy() override; public: - virtual void button_press(int, int, unsigned); - virtual void button_release(int, int, unsigned); - virtual void pointer_motion(int, int); + void button_press(int, int, unsigned) override; + void button_release(int, int, unsigned) override; + void pointer_motion(int, int) override; private: Widget *get_pointer_target(int, int, bool) const; public: - virtual void pointer_leave(); - virtual void touch_press(int, int, unsigned); - virtual void touch_release(int, int, unsigned); - virtual void touch_motion(int, int, unsigned); - virtual bool key_press(unsigned, unsigned); - virtual bool key_release(unsigned, unsigned); - virtual bool character(wchar_t); - virtual void focus_in(); - virtual void focus_out(); - virtual bool navigate(Navigation); - virtual void animate(const Time::TimeDelta &); + void pointer_leave() override; + void touch_press(int, int, unsigned) override; + void touch_release(int, int, unsigned) override; + void touch_motion(int, int, unsigned) override; + bool key_press(unsigned, unsigned) override; + bool key_release(unsigned, unsigned) override; + bool character(wchar_t) override; + void focus_in() override; + void focus_out() override; + bool navigate(Navigation) override; + void animate(const Time::TimeDelta &) override; protected: - virtual void on_reparent(); + void on_reparent() override; virtual void on_child_added(Widget &) { } virtual void on_child_removed(Widget &) { } virtual void on_input_focus_changed(Widget *); diff --git a/source/dialog.h b/source/dialog.h index e712227..285478e 100644 --- a/source/dialog.h +++ b/source/dialog.h @@ -30,7 +30,7 @@ private: bool stale = false; public: - virtual const char *get_class() const { return "dialog"; } + const char *get_class() const override { return "dialog"; } /** Adds an action button to the dialog. Pressing the button will invoke response handlers and delete the dialog. */ @@ -40,9 +40,9 @@ public: away from the dialog. */ void set_modal(bool); - virtual void button_release(int, int, unsigned); - virtual bool key_release(unsigned, unsigned); - virtual bool navigate(Navigation); + void button_release(int, int, unsigned) override; + bool key_release(unsigned, unsigned) override; + bool navigate(Navigation) override; protected: void response(int); void check_stale(); diff --git a/source/draghandle.h b/source/draghandle.h index d3cd6f2..68381fe 100644 --- a/source/draghandle.h +++ b/source/draghandle.h @@ -19,13 +19,13 @@ private: int drag_y = 0; public: - virtual const char *get_class() const { return "draghandle"; } + const char *get_class() const override { return "draghandle"; } - virtual void button_press(int, int, unsigned); - virtual void button_release(int, int, unsigned); - virtual void pointer_motion(int, int); + void button_press(int, int, unsigned) override; + void button_release(int, int, unsigned) override; + void pointer_motion(int, int) override; private: - virtual void on_reparent(); + void on_reparent() override; }; } // namespace GLtk diff --git a/source/dropdown.h b/source/dropdown.h index 70a9faa..c5b535d 100644 --- a/source/dropdown.h +++ b/source/dropdown.h @@ -37,10 +37,10 @@ private: void init(); public: - virtual const char *get_class() const { return "dropdown"; } + const char *get_class() const override { return "dropdown"; } private: - virtual void autosize_special(const Part &, Geometry &) const; + void autosize_special(const Part &, Geometry &) const override; public: void set_data(ListData &d) { list.set_data(d); } @@ -54,15 +54,15 @@ public: int get_selected_index() const { return list.get_selected_index(); } private: - virtual void rebuild_special(const Part &); - virtual void render_special(const Part &, GL::Renderer &) const; + void rebuild_special(const Part &) override; + void render_special(const Part &, GL::Renderer &) const override; public: - virtual void button_press(int, int, unsigned); - virtual bool navigate(Navigation); + void button_press(int, int, unsigned) override; + bool navigate(Navigation) override; private: - virtual void on_size_change(); - virtual void on_style_change(); + void on_size_change() override; + void on_style_change() override; void open_list(); void close_list(); diff --git a/source/entry.h b/source/entry.h index 66b3327..0573671 100644 --- a/source/entry.h +++ b/source/entry.h @@ -55,10 +55,10 @@ private: public: Entry(const std::string & = std::string()); - virtual const char *get_class() const { return "entry"; } + const char *get_class() const override { return "entry"; } private: - virtual void autosize_special(const Part &, Geometry &) const; + void autosize_special(const Part &, Geometry &) const override; public: void set_text(const std::string &); @@ -82,20 +82,20 @@ public: bool is_multiline() const { return multiline; } private: - virtual void rebuild_special(const Part &); - virtual void render_special(const Part &, GL::Renderer &) const; + void rebuild_special(const Part &) override; + void render_special(const Part &, GL::Renderer &) const override; public: - virtual void touch_press(int, int, unsigned); - virtual bool key_press(unsigned, unsigned); - virtual bool character(wchar_t); - virtual void focus_in(); - virtual void focus_out(); - virtual bool navigate(Navigation); - virtual void animate(const Time::TimeDelta &); + void touch_press(int, int, unsigned) override; + bool key_press(unsigned, unsigned) override; + bool character(wchar_t) override; + void focus_in() override; + void focus_out() override; + bool navigate(Navigation) override; + void animate(const Time::TimeDelta &) override; private: - virtual void on_size_change(); - virtual void on_style_change(); + void on_size_change() override; + void on_style_change() override; void move_edit_position(Navigation, bool); void adjust_edit_position_for_change(unsigned, int); diff --git a/source/floatingarrangement.h b/source/floatingarrangement.h index 8539b59..1ac4fa9 100644 --- a/source/floatingarrangement.h +++ b/source/floatingarrangement.h @@ -13,9 +13,9 @@ public: FloatingArrangement(Layout &); private: - virtual void process_widget(Widget &, Side, bool) { } - virtual void finish_widget(Widget &); - virtual void finish_slot() { } + void process_widget(Widget &, Side, bool) override { } + void finish_widget(Widget &) override; + void finish_slot() override { } }; } // namespace GLtk diff --git a/source/grid.h b/source/grid.h index 9324f95..4ed43d5 100644 --- a/source/grid.h +++ b/source/grid.h @@ -40,9 +40,9 @@ public: void next_row(); private: - virtual void process_widget(Widget &, Side, bool); - virtual void finish_widget(Widget &); - virtual void finish_slot(); + void process_widget(Widget &, Side, bool) override; + void finish_widget(Widget &) override; + void finish_slot() override; void finish_row(); }; diff --git a/source/image.h b/source/image.h index 12e77f2..99e0874 100644 --- a/source/image.h +++ b/source/image.h @@ -28,10 +28,10 @@ private: public: Image(const GL::Texture2D * = nullptr); - virtual const char *get_class() const { return "image"; } + const char *get_class() const override { return "image"; } private: - virtual void autosize_special(const Part &, Geometry &) const; + void autosize_special(const Part &, Geometry &) const override; public: void set_image(const GL::Texture2D *); @@ -40,9 +40,9 @@ public: private: void update_icon(); - virtual void rebuild_special(const Part &); - virtual void on_style_change(); - virtual void on_reparent(); + void rebuild_special(const Part &) override; + void on_style_change() override; + void on_reparent() override; }; } // namespace GLtk diff --git a/source/indicator.h b/source/indicator.h index 2b5b2a3..9ec9f33 100644 --- a/source/indicator.h +++ b/source/indicator.h @@ -13,7 +13,7 @@ An Indicator visualizes a boolean state. It can be either active or inactive. class MSPGLTK_API Indicator: public Widget { public: - virtual const char *get_class() const { return "indicator"; } + const char *get_class() const override { return "indicator"; } void set_active(bool); }; diff --git a/source/label.h b/source/label.h index 3275bca..6b350ed 100644 --- a/source/label.h +++ b/source/label.h @@ -28,15 +28,15 @@ private: public: Label(const std::string & = std::string()); - virtual const char *get_class() const { return "label"; } + const char *get_class() const override { return "label"; } void set_text(const std::string &); private: - virtual void autosize_special(const Part &, Geometry &) const; - virtual void rebuild_special(const Part &); + void autosize_special(const Part &, Geometry &) const override; + void rebuild_special(const Part &) override; - virtual void on_style_change(); + void on_style_change() override; }; } // namespace GLtk diff --git a/source/lineararrangement.h b/source/lineararrangement.h index f0ec245..7535bc7 100644 --- a/source/lineararrangement.h +++ b/source/lineararrangement.h @@ -43,9 +43,9 @@ public: void spacing(unsigned); protected: - virtual void process_widget(Widget &, Side, bool); - virtual void finish_widget(Widget &); - virtual void finish_slot(); + void process_widget(Widget &, Side, bool) override; + void finish_widget(Widget &) override; + void finish_slot() override; }; } // namespace GLtk diff --git a/source/list.h b/source/list.h index 37d4d7a..060fb81 100644 --- a/source/list.h +++ b/source/list.h @@ -67,14 +67,14 @@ public: Item(); public: - virtual const char *get_class() const { return "listitem"; } + const char *get_class() const override { return "listitem"; } protected: - virtual void autosize_special(const Part &, Geometry &) const; + void autosize_special(const Part &, Geometry &) const override; public: void set_active(bool); - virtual void render_special(const Part &, GL::Renderer &) const; + void render_special(const Part &, GL::Renderer &) const override; }; class SimpleItem: public Item @@ -82,7 +82,7 @@ public: protected: SimpleItem() = default; - virtual void on_style_change(); + void on_style_change() override; }; class MultiColumnItem: public Item @@ -93,7 +93,7 @@ public: virtual void check_widths(std::vector &) const; virtual void set_widths(const std::vector &); - virtual void on_style_change(); + void on_style_change() override; }; private: @@ -129,7 +129,7 @@ private: TypedItemFactory(const ListData &d) { set_data(d); } - virtual void set_data(const ListData &d) + void set_data(const ListData &d) override { if(const ListDataStore *ds = dynamic_cast *>(&d)) data = ds; @@ -137,7 +137,7 @@ private: throw incompatible_data(typeid(ValueType)); } - virtual Item *create_item(unsigned i) const + Item *create_item(unsigned i) const override { return new I(data->get(i)); } @@ -182,10 +182,10 @@ public: List(ListData &); virtual ~List(); - virtual const char *get_class() const { return "list"; } + const char *get_class() const override { return "list"; } private: - virtual void autosize_special(const Part &, Geometry &) const; + void autosize_special(const Part &, Geometry &) const override; public: void set_data(ListData &); @@ -216,19 +216,19 @@ public: private: void set_selected_item(Widget *); - virtual void rebuild_special(const Part &); - virtual void render_special(const Part &, GL::Renderer &) const; + void rebuild_special(const Part &) override; + void render_special(const Part &, GL::Renderer &) const override; public: - virtual bool key_press(unsigned, unsigned); - virtual void button_press(int, int, unsigned); - virtual void touch_press(int, int, unsigned); - virtual void touch_release(int, int, unsigned); - virtual void touch_motion(int, int, unsigned); - virtual void focus_in(); - virtual bool navigate(Navigation); + bool key_press(unsigned, unsigned) override; + void button_press(int, int, unsigned) override; + void touch_press(int, int, unsigned) override; + void touch_release(int, int, unsigned) override; + void touch_motion(int, int, unsigned) override; + void focus_in() override; + bool navigate(Navigation) override; private: - virtual void on_style_change(); + void on_style_change() override; void move_focus(Navigation, bool); void set_focus_index(int); diff --git a/source/listdata.h b/source/listdata.h index 00d2b9b..77be5ee 100644 --- a/source/listdata.h +++ b/source/listdata.h @@ -93,7 +93,7 @@ public: signal_cleared.emit(); } - virtual unsigned size() const { return items.size(); } + unsigned size() const override { return items.size(); } }; template @@ -116,7 +116,7 @@ private: public: FunctionListData(Func f): func(f) { } - virtual std::string get_string(unsigned i) const + std::string get_string(unsigned i) const override { return func(this->get(i)); } }; diff --git a/source/panel.h b/source/panel.h index b5755d0..ce4b2a7 100644 --- a/source/panel.h +++ b/source/panel.h @@ -81,24 +81,24 @@ public: template static void register_child_type(const std::string &); - virtual const char *get_class() const { return "panel"; } + const char *get_class() const override { return "panel"; } void set_layout(Layout *); Layout *get_layout() { return layout; } protected: - virtual void autosize_special(const Part &, Geometry &) const; - virtual void render_special(const Part &, GL::Renderer &) const; + void autosize_special(const Part &, Geometry &) const override; + void render_special(const Part &, GL::Renderer &) const override; public: - virtual bool navigate(Navigation); + bool navigate(Navigation) override; protected: Widget *find_next_child(int, int, int, int, int) const; static int compute_delta(int, int, int, int, int); - virtual void on_size_change(); - virtual void on_child_added(Widget &); - virtual void on_child_removed(Widget &); + void on_size_change() override; + void on_child_added(Widget &) override; + void on_child_removed(Widget &) override; }; diff --git a/source/progressbar.h b/source/progressbar.h index 6e44e73..7562192 100644 --- a/source/progressbar.h +++ b/source/progressbar.h @@ -14,14 +14,14 @@ private: float fraction = 0.0f; public: - virtual const char *get_class() const { return "progressbar"; } + const char *get_class() const override { return "progressbar"; } void set_range(float); void set_value(float); private: - virtual void autosize_special(const Part &, Geometry &) const; - virtual void rebuild_special(const Part &); + void autosize_special(const Part &, Geometry &) const override; + void rebuild_special(const Part &) override; }; } // namespace GLtk diff --git a/source/root.h b/source/root.h index 0fe624f..c71d50d 100644 --- a/source/root.h +++ b/source/root.h @@ -57,15 +57,15 @@ public: Root(Resources &, Graphics::Window *, Input::Keyboard *, Input::Mouse *, Input::Touchscreen * = nullptr); virtual ~Root(); - virtual const char *get_class() const { return "root"; } + const char *get_class() const override { return "root"; } Resources &get_resources() const { return resources; } virtual unsigned get_width() const { return geom.w; } virtual unsigned get_height() const { return geom.h; } void tick(); - virtual void setup_frame(GL::Renderer &); - virtual void render(GL::Renderer &, GL::Tag = GL::Tag()) const; + void setup_frame(GL::Renderer &) override; + void render(GL::Renderer &, GL::Tag = GL::Tag()) const override; private: bool button_press_event(unsigned); @@ -79,8 +79,8 @@ private: void get_touch(unsigned, int &, int &); void update_camera(); - virtual void on_size_change(); - virtual void on_child_added(Widget &); + void on_size_change() override; + void on_child_added(Widget &) override; }; } // namespace GLtk diff --git a/source/row.h b/source/row.h index 849ba62..678a385 100644 --- a/source/row.h +++ b/source/row.h @@ -13,7 +13,7 @@ public: Row(Layout &); private: - virtual void finish_widget(Widget &); + void finish_widget(Widget &) override; }; } // namespace GLtk diff --git a/source/slider.h b/source/slider.h index 70c5fc5..057b194 100644 --- a/source/slider.h +++ b/source/slider.h @@ -59,17 +59,17 @@ public: double get_value() const { return value; } protected: - virtual void autosize_special(const Part &, Geometry &) const; - virtual void rebuild_special(const Part &); + void autosize_special(const Part &, Geometry &) const override; + void rebuild_special(const Part &) override; public: - virtual void button_press(int, int, unsigned); - virtual void button_release(int, int, unsigned); - virtual void pointer_motion(int, int); + void button_press(int, int, unsigned) override; + void button_release(int, int, unsigned) override; + void pointer_motion(int, int) override; protected: - virtual void on_size_change(); - virtual void on_style_change(); + void on_size_change() override; + void on_style_change() override; }; @@ -78,7 +78,7 @@ class MSPGLTK_API VSlider: public Slider public: VSlider(): Slider(VERTICAL) { } - virtual const char *get_class() const { return "vslider"; } + const char *get_class() const override { return "vslider"; } }; class MSPGLTK_API HSlider: public Slider @@ -86,7 +86,7 @@ class MSPGLTK_API HSlider: public Slider public: HSlider(): Slider(HORIZONTAL) { } - virtual const char *get_class() const { return "hslider"; } + const char *get_class() const override { return "hslider"; } }; } // namespace GLtk diff --git a/source/stack.h b/source/stack.h index 53943fd..193a806 100644 --- a/source/stack.h +++ b/source/stack.h @@ -24,9 +24,9 @@ public: Stack(Layout &); private: - virtual void process_widget(Widget &, Side, bool); - virtual void finish_widget(Widget &); - virtual void finish_slot() { } + void process_widget(Widget &, Side, bool) override; + void finish_widget(Widget &) override; + void finish_slot() override { } }; } // namespace GLtk diff --git a/source/toggle.h b/source/toggle.h index 7c572c5..2b38ffc 100644 --- a/source/toggle.h +++ b/source/toggle.h @@ -20,7 +20,7 @@ public: public: Loader(Toggle &); private: - virtual void finish(); + void finish() override; void text(const std::string &); }; @@ -35,10 +35,10 @@ private: public: Toggle(const std::string & = std::string()); - virtual const char *get_class() const { return "toggle"; } + const char *get_class() const override { return "toggle"; } private: - virtual void autosize_special(const Part &, Geometry &) const; + void autosize_special(const Part &, Geometry &) const override; public: void set_text(const std::string &); @@ -51,14 +51,14 @@ public: bool get_value() const { return value; } private: - virtual void rebuild_special(const Part &); + void rebuild_special(const Part &) override; public: - virtual void button_press(int, int, unsigned); - virtual void button_release(int, int, unsigned); - virtual bool navigate(Navigation); + void button_press(int, int, unsigned) override; + void button_release(int, int, unsigned) override; + bool navigate(Navigation) override; private: - virtual void on_style_change(); + void on_style_change() override; }; } // namespace GLtk