https://github.com/libsdl-org/Maelstrom/commit/810398a6029b6276a1a56fad18c88eb0b8299ba2
From 810398a6029b6276a1a56fad18c88eb0b8299ba2 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sat, 29 Oct 2011 21:19:02 -0400
Subject: [PATCH] Introduced the "override" keyword to reduce confusion about
which UI methods are newly exposed and which are being extended. Hopefully
this won't introduce new confusion about what "override" means. :)
---
MacDialog.h | 6 +++---
MacDialogButton.h | 6 +++---
MacDialogCheckbox.h | 4 ++--
MacDialogRadioButton.h | 4 ++--
UIElementIcon.h | 2 +-
UIElementKeyButton.h | 2 +-
UIElementSprite.h | 2 +-
UIElementTitle.h | 2 +-
screenlib/UIBaseElement.h | 7 +++++++
screenlib/UIDialog.h | 8 ++++----
screenlib/UIDialogButton.h | 4 ++--
screenlib/UIElement.h | 2 +-
screenlib/UIElementButton.h | 4 ++--
screenlib/UIElementCheckbox.h | 4 ++--
screenlib/UIElementLabel.h | 4 ++--
screenlib/UIElementLine.h | 4 ++--
screenlib/UIElementRadio.h | 4 ++--
screenlib/UIElementRect.h | 4 ++--
screenlib/UIElementTexture.h | 2 +-
screenlib/UIPanel.h | 12 ++++++------
20 files changed, 47 insertions(+), 40 deletions(-)
diff --git a/MacDialog.h b/MacDialog.h
index 4ce3f600..0e613f1d 100644
--- a/MacDialog.h
+++ b/MacDialog.h
@@ -10,10 +10,10 @@ DECLARE_TYPESAFE_CLASS(UIDialog)
public:
MacDialog(UIManager *ui, const char *name);
- virtual bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
+ override bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
- virtual void Show();
- virtual void Draw();
+ override void Show();
+ override void Draw();
protected:
enum {
diff --git a/MacDialogButton.h b/MacDialogButton.h
index b28464d3..c2bc0cba 100644
--- a/MacDialogButton.h
+++ b/MacDialogButton.h
@@ -10,10 +10,10 @@ DECLARE_TYPESAFE_CLASS(UIDialogButton)
public:
MacDialogButton(UIBaseElement *parent, const char *name = "");
- virtual void Draw();
+ override void Draw();
- virtual void OnMouseDown();
- virtual void OnMouseUp();
+ override void OnMouseDown();
+ override void OnMouseUp();
protected:
Uint32 m_colors[2];
diff --git a/MacDialogCheckbox.h b/MacDialogCheckbox.h
index b2e96a27..a6f03d5c 100644
--- a/MacDialogCheckbox.h
+++ b/MacDialogCheckbox.h
@@ -10,9 +10,9 @@ DECLARE_TYPESAFE_CLASS(UIElementCheckbox)
public:
MacDialogCheckbox(UIBaseElement *parent, const char *name = "");
- virtual bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
+ override bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
- virtual void Draw();
+ override void Draw();
protected:
Uint32 m_color;
diff --git a/MacDialogRadioButton.h b/MacDialogRadioButton.h
index 1dd13b5d..b673efd4 100644
--- a/MacDialogRadioButton.h
+++ b/MacDialogRadioButton.h
@@ -10,9 +10,9 @@ DECLARE_TYPESAFE_CLASS(UIElementRadioButton)
public:
MacDialogRadioButton(UIBaseElement *parent, const char *name = "");
- virtual bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
+ override bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
- virtual void Draw();
+ override void Draw();
protected:
Uint32 m_color;
diff --git a/UIElementIcon.h b/UIElementIcon.h
index bbdee3ca..c8c760e9 100644
--- a/UIElementIcon.h
+++ b/UIElementIcon.h
@@ -10,7 +10,7 @@ DECLARE_TYPESAFE_CLASS(UIElementTexture)
public:
UIElementIcon(UIBaseElement *parent, const char *name = "");
- virtual bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
+ override bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
};
#endif // _UIElementIcon_h
diff --git a/UIElementKeyButton.h b/UIElementKeyButton.h
index bafb8970..10de7ef5 100644
--- a/UIElementKeyButton.h
+++ b/UIElementKeyButton.h
@@ -10,7 +10,7 @@ DECLARE_TYPESAFE_CLASS(UIElementButton)
public:
UIElementKeyButton(UIBaseElement *parent, const char *name = "");
- virtual bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
+ override bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
};
#endif // _UIElementKeyButton_h
diff --git a/UIElementSprite.h b/UIElementSprite.h
index 55649043..75e828d5 100644
--- a/UIElementSprite.h
+++ b/UIElementSprite.h
@@ -10,7 +10,7 @@ DECLARE_TYPESAFE_CLASS(UIElementTexture)
public:
UIElementSprite(UIBaseElement *parent, const char *name = "");
- virtual bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
+ override bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
};
#endif // _UIElementSprite_h
diff --git a/UIElementTitle.h b/UIElementTitle.h
index cb611238..129457a0 100644
--- a/UIElementTitle.h
+++ b/UIElementTitle.h
@@ -10,7 +10,7 @@ DECLARE_TYPESAFE_CLASS(UIElementTexture)
public:
UIElementTitle(UIBaseElement *parent, const char *name = "");
- virtual bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
+ override bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
};
#endif // _UIElementTitle_h
diff --git a/screenlib/UIBaseElement.h b/screenlib/UIBaseElement.h
index c4c3cefd..2abfe918 100644
--- a/screenlib/UIBaseElement.h
+++ b/screenlib/UIBaseElement.h
@@ -126,4 +126,11 @@ public: \
}
/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
+// So we can be explicit about what methods are being newly exposed and
+// which methods are overriding a base class method, I'm going to introduce
+// the "override" keyword in this inheritance hierarchy.
+#define override virtual
+/////////////////////////////////////////////////////////////////////////
+
#endif // _UIBaseElement_h
diff --git a/screenlib/UIDialog.h b/screenlib/UIDialog.h
index f61b9f0c..74bdb189 100644
--- a/screenlib/UIDialog.h
+++ b/screenlib/UIDialog.h
@@ -56,9 +56,9 @@ DECLARE_TYPESAFE_CLASS(UIPanel)
return m_status;
}
- virtual void Show();
- virtual void Hide();
- virtual bool HandleEvent(const SDL_Event &event);
+ override void Show();
+ override void Hide();
+ override bool HandleEvent(const SDL_Event &event);
protected:
int m_status;
@@ -74,7 +74,7 @@ class UIDialogLauncher : public UIButtonDelegate
public:
UIDialogLauncher(UIManager *ui, const char *name, UIDialogInitHandler = NULL, UIDialogDoneHandler handleDone = NULL);
- virtual void OnClick();
+ override void OnClick();
protected:
UIManager *m_ui;
diff --git a/screenlib/UIDialogButton.h b/screenlib/UIDialogButton.h
index 75f12a48..7b715e6c 100644
--- a/screenlib/UIDialogButton.h
+++ b/screenlib/UIDialogButton.h
@@ -32,9 +32,9 @@ DECLARE_TYPESAFE_CLASS(UIElementButton)
public:
UIDialogButton(UIBaseElement *parent, const char *name = "");
- virtual bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
+ override bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
- virtual void OnClick();
+ override void OnClick();
protected:
int m_statusID;
diff --git a/screenlib/UIElement.h b/screenlib/UIElement.h
index b699b082..ff6002c0 100644
--- a/screenlib/UIElement.h
+++ b/screenlib/UIElement.h
@@ -32,7 +32,7 @@ DECLARE_TYPESAFE_CLASS(UIBaseElement)
public:
UIElement(UIBaseElement *parent, const char *name = "");
- virtual bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
+ override bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
};
#endif // _UIElement_h
diff --git a/screenlib/UIElementButton.h b/screenlib/UIElementButton.h
index ed28dbb6..1f33d54c 100644
--- a/screenlib/UIElementButton.h
+++ b/screenlib/UIElementButton.h
@@ -38,9 +38,9 @@ DECLARE_TYPESAFE_CLASS(UIElement)
UIElementButton(UIBaseElement *parent, const char *name = "");
virtual ~UIElementButton();
- virtual bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
+ override bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
- virtual bool HandleEvent(const SDL_Event &event);
+ override bool HandleEvent(const SDL_Event &event);
// These can be overridden by inherited classes
virtual void OnMouseEnter() { }
diff --git a/screenlib/UIElementCheckbox.h b/screenlib/UIElementCheckbox.h
index 88da9e21..0f833ae2 100644
--- a/screenlib/UIElementCheckbox.h
+++ b/screenlib/UIElementCheckbox.h
@@ -10,7 +10,7 @@ DECLARE_TYPESAFE_CLASS(UIElementButton)
public:
UIElementCheckbox(UIBaseElement *parent, const char *name = "");
- virtual bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
+ override bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
void SetChecked(bool checked) {
if (checked != m_checked) {
@@ -23,7 +23,7 @@ DECLARE_TYPESAFE_CLASS(UIElementButton)
}
virtual void OnChecked(bool checked) { }
- virtual void OnClick();
+ override void OnClick();
protected:
bool m_checked;
diff --git a/screenlib/UIElementLabel.h b/screenlib/UIElementLabel.h
index af150499..72e59f62 100644
--- a/screenlib/UIElementLabel.h
+++ b/screenlib/UIElementLabel.h
@@ -34,13 +34,13 @@ DECLARE_TYPESAFE_CLASS(UIElement)
UIElementLabel(UIBaseElement *parent, const char *name = "");
virtual ~UIElementLabel();
- virtual bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
+ override bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
void SetText(const char *text);
void SetTextColor(Uint8 R, Uint8 G, Uint8 B);
void SetTextColor(Uint32 color);
- virtual void Draw();
+ override void Draw();
protected:
char *m_fontName;
diff --git a/screenlib/UIElementLine.h b/screenlib/UIElementLine.h
index 00547058..6a389394 100644
--- a/screenlib/UIElementLine.h
+++ b/screenlib/UIElementLine.h
@@ -32,13 +32,13 @@ DECLARE_TYPESAFE_CLASS(UIElement)
public:
UIElementLine(UIBaseElement *parent, const char *name = "");
- virtual bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
+ override bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
void SetColor(Uint32 color) {
m_color = color;
}
- virtual void Draw();
+ override void Draw();
private:
Uint32 m_color;
diff --git a/screenlib/UIElementRadio.h b/screenlib/UIElementRadio.h
index 38f0448d..63cb7fc8 100644
--- a/screenlib/UIElementRadio.h
+++ b/screenlib/UIElementRadio.h
@@ -64,9 +64,9 @@ DECLARE_TYPESAFE_CLASS(UIElementCheckbox)
return m_id;
}
- virtual bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
+ override bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
- virtual void OnChecked(bool checked);
+ override void OnChecked(bool checked);
protected:
int m_id;
diff --git a/screenlib/UIElementRect.h b/screenlib/UIElementRect.h
index a024431b..145e8cd5 100644
--- a/screenlib/UIElementRect.h
+++ b/screenlib/UIElementRect.h
@@ -32,13 +32,13 @@ DECLARE_TYPESAFE_CLASS(UIElement)
public:
UIElementRect(UIBaseElement *parent, const char *name = "");
- virtual bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
+ override bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
void SetColor(Uint32 color) {
m_color = color;
}
- virtual void Draw();
+ override void Draw();
protected:
bool m_fill;
diff --git a/screenlib/UIElementTexture.h b/screenlib/UIElementTexture.h
index f1c0a9bb..69058f82 100644
--- a/screenlib/UIElementTexture.h
+++ b/screenlib/UIElementTexture.h
@@ -35,7 +35,7 @@ DECLARE_TYPESAFE_CLASS(UIElement)
void SetTexture(SDL_Texture *texture);
- virtual void Draw();
+ override void Draw();
private:
SDL_Texture *m_texture;
diff --git a/screenlib/UIPanel.h b/screenlib/UIPanel.h
index b1c7dfcd..f8824cc2 100644
--- a/screenlib/UIPanel.h
+++ b/screenlib/UIPanel.h
@@ -64,18 +64,18 @@ DECLARE_TYPESAFE_CLASS(UIBaseElement)
return m_cursorVisible;
}
- virtual bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
- virtual bool FinishLoading();
+ override bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
+ override bool FinishLoading();
void SetPanelDelegate(UIPanelDelegate *delegate, bool autodelete = true);
- virtual void Show();
- virtual void Hide();
+ override void Show();
+ override void Hide();
void HideAll();
- virtual void Draw();
- virtual bool HandleEvent(const SDL_Event &event);
+ override void Draw();
+ override bool HandleEvent(const SDL_Event &event);
protected:
bool m_fullscreen;