Fixed inheritance issue with Widget::wantsFocus() and child classes.

Changed some code in TIA class to eliminate function calls.

Minor code refactoring wrt d'tors.
This commit is contained in:
Stephen Anthony 2017-04-01 15:41:34 -02:30
parent f041de441f
commit 58f93c1930
15 changed files with 34 additions and 54 deletions

View File

@ -77,10 +77,9 @@ class PromptWidget : public Widget, public CommandSender
void handleCommand(CommandSender* sender, int cmd, int data, int id) override; void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
// Account for the extra width of embedded scrollbar // Account for the extra width of embedded scrollbar
virtual int getWidth() const override; int getWidth() const override;
virtual bool wantsFocus() { return true; }
bool wantsFocus() const override { return true; }
void loadConfig() override; void loadConfig() override;
private: private:

View File

@ -42,10 +42,10 @@ class TiaOutputWidget : public Widget, public CommandSender
// For example, clicking an area may cause an action // For example, clicking an area may cause an action
// (fill to this scanline, etc). // (fill to this scanline, etc).
/* /*
virtual void handleMouseUp(int x, int y, int button, int clickCount) override; void handleMouseUp(int x, int y, int button, int clickCount) override;
virtual void handleMouseWheel(int x, int y, int direction) override; void handleMouseWheel(int x, int y, int direction) override;
virtual bool handleKeyDown(StellaKey key, StellaMod mod) override; bool handleKeyDown(StellaKey key, StellaMod mod) override;
virtual bool handleKeyUp(StellaKey key, StellaMod mod) override; bool handleKeyUp(StellaKey key, StellaMod mod) override;
*/ */
private: private:
unique_ptr<ContextMenu> myMenu; unique_ptr<ContextMenu> myMenu;
@ -62,7 +62,7 @@ class TiaOutputWidget : public Widget, public CommandSender
void handleCommand(CommandSender* sender, int cmd, int data, int id) override; void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
void drawWidget(bool hilite) override; void drawWidget(bool hilite) override;
bool wantsFocus() { return false; } bool wantsFocus() const override { return false; }
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported
TiaOutputWidget() = delete; TiaOutputWidget() = delete;

View File

@ -48,7 +48,7 @@ class TiaZoomWidget : public Widget, public CommandSender
void handleCommand(CommandSender* sender, int cmd, int data, int id) override; void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
void drawWidget(bool hilite) override; void drawWidget(bool hilite) override;
bool wantsFocus() { return true; } bool wantsFocus() const override { return true; }
private: private:
unique_ptr<ContextMenu> myMenu; unique_ptr<ContextMenu> myMenu;

View File

@ -39,7 +39,7 @@ class ToggleWidget : public Widget, public CommandSender
const BoolArray& getState() { return _stateList; } const BoolArray& getState() { return _stateList; }
bool getSelectedState() const { return _stateList[_selectedItem]; } bool getSelectedState() const { return _stateList[_selectedItem]; }
virtual bool wantsFocus() { return true; } bool wantsFocus() const override { return true; }
int colWidth() const { return _colWidth; } int colWidth() const { return _colWidth; }
void setEditable(bool editable) { _editable = editable; } void setEditable(bool editable) { _editable = editable; }

View File

@ -198,11 +198,6 @@ class Controller : public Serializable
Controller::Type xtype, int xid, Controller::Type ytype, int yid) Controller::Type xtype, int xid, Controller::Type ytype, int yid)
{ return false; } { return false; }
/**
Returns the name of this controller.
*/
virtual string name() const override { return myName; }
/** /**
Returns more detailed information about this controller. Returns more detailed information about this controller.
*/ */
@ -237,6 +232,11 @@ class Controller : public Serializable
*/ */
bool load(Serializer& in) override; bool load(Serializer& in) override;
/**
Returns the name of this controller.
*/
string name() const override { return myName; }
public: public:
/// Constant which represents maximum resistance for analog pins /// Constant which represents maximum resistance for analog pins
static constexpr Int32 maximumResistance = 0x7FFFFFFF; static constexpr Int32 maximumResistance = 0x7FFFFFFF;

View File

@ -283,7 +283,7 @@ class AbstractFSNode
// AbstractFSNode(AbstractFSNode&&) = default; // AbstractFSNode(AbstractFSNode&&) = default;
AbstractFSNode& operator=(const AbstractFSNode&) = default; AbstractFSNode& operator=(const AbstractFSNode&) = default;
// AbstractFSNode& operator=(AbstractFSNode&&) = default; // AbstractFSNode& operator=(AbstractFSNode&&) = default;
virtual ~AbstractFSNode() { } virtual ~AbstractFSNode() = default;
/* /*
* Indicates whether the object referred by this path exists in the * Indicates whether the object referred by this path exists in the

View File

@ -202,7 +202,6 @@ void Missile::tick(uInt8 hclock)
myEffectiveWidth = myWidth; myEffectiveWidth = myWidth;
break; break;
} }
} }
if (++myRenderCounter >= (myIsMoving ? myEffectiveWidth : myWidth)) myIsRendering = false; if (++myRenderCounter >= (myIsMoving ? myEffectiveWidth : myWidth)) myIsRendering = false;

View File

@ -1042,10 +1042,21 @@ void TIA::tickHframe()
myPlayfield.tick(x); myPlayfield.tick(x);
if (lineNotCached) // Render sprites
renderSprites(); if (lineNotCached) {
myPlayer0.render();
myPlayer1.render();
myMissile0.render(myHctr);
myMissile1.render(myHctr);
myBall.render();
}
tickSprites(); // Tick sprites
myMissile0.tick(myHctr);
myMissile1.tick(myHctr);
myPlayer0.tick();
myPlayer1.tick();
myBall.tick();
if (myFrameManager.isRendering()) if (myFrameManager.isRendering())
renderPixel(x, y, lineNotCached); renderPixel(x, y, lineNotCached);
@ -1064,26 +1075,6 @@ void TIA::applyRsync()
myHctr = 225; myHctr = 225;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIA::renderSprites()
{
myPlayer0.render();
myPlayer1.render();
myMissile0.render(myHctr);
myMissile1.render(myHctr);
myBall.render();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIA::tickSprites()
{
myMissile0.tick(myHctr);
myMissile1.tick(myHctr);
myPlayer0.tick();
myPlayer1.tick();
myBall.tick();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIA::nextLine() void TIA::nextLine()
{ {

View File

@ -386,10 +386,6 @@ class TIA : public Device, public PlayfieldPositionProvider
void updateCollision(); void updateCollision();
void renderSprites();
void tickSprites();
void renderPixel(uInt32 x, uInt32 y, bool lineNotCached); void renderPixel(uInt32 x, uInt32 y, bool lineNotCached);
void clearHmoveComb(); void clearHmoveComb();

View File

@ -40,7 +40,7 @@ class ComboDialog : public Dialog
void saveConfig() override; void saveConfig() override;
void setDefaults() override; void setDefaults() override;
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id) override; void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
private: private:
Event::Type myComboEvent; Event::Type myComboEvent;

View File

@ -58,7 +58,7 @@ class EditableWidget : public Widget, public CommandSender
bool handleKeyDown(StellaKey key, StellaMod mod) override; bool handleKeyDown(StellaKey key, StellaMod mod) override;
// We only want to focus this widget when we can edit its contents // We only want to focus this widget when we can edit its contents
virtual bool wantsFocus() const { return _editable; } bool wantsFocus() const override { return _editable; }
// Set filter used to test whether a character can be inserted // Set filter used to test whether a character can be inserted
void setTextFilter(const TextFilter& filter) { _filter = filter; } void setTextFilter(const TextFilter& filter) { _filter = filter; }

View File

@ -189,11 +189,6 @@ LauncherDialog::LauncherDialog(OSystem& osystem, DialogContainer& parent,
setListFilters(); setListFilters();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
LauncherDialog::~LauncherDialog()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string& LauncherDialog::selectedRomMD5() const string& LauncherDialog::selectedRomMD5()
{ {

View File

@ -55,7 +55,7 @@ class LauncherDialog : public Dialog
public: public:
LauncherDialog(OSystem& osystem, DialogContainer& parent, LauncherDialog(OSystem& osystem, DialogContainer& parent,
int x, int y, int w, int h); int x, int y, int w, int h);
virtual ~LauncherDialog(); virtual ~LauncherDialog() = default;
/** /**
Get MD5sum for the currently selected file Get MD5sum for the currently selected file

View File

@ -58,7 +58,7 @@ class PopUpWidget : public Widget, public CommandSender
const string& getSelectedName() const { return myMenu->getSelectedName(); } const string& getSelectedName() const { return myMenu->getSelectedName(); }
const Variant& getSelectedTag() const { return myMenu->getSelectedTag(); } const Variant& getSelectedTag() const { return myMenu->getSelectedTag(); }
bool wantsFocus() { return true; } bool wantsFocus() const override { return true; }
protected: protected:
void handleMouseDown(int x, int y, int button, int clickCount) override; void handleMouseDown(int x, int y, int button, int clickCount) override;

View File

@ -96,7 +96,7 @@ class Widget : public GuiObject
bool isEnabled() const { return _flags & WIDGET_ENABLED; } bool isEnabled() const { return _flags & WIDGET_ENABLED; }
bool isVisible() const override { return !(_flags & WIDGET_INVISIBLE); } bool isVisible() const override { return !(_flags & WIDGET_INVISIBLE); }
bool wantsFocus() const { return _flags & WIDGET_RETAIN_FOCUS; } virtual bool wantsFocus() const { return _flags & WIDGET_RETAIN_FOCUS; }
bool wantsTab() const { return _flags & WIDGET_WANTS_TAB; } bool wantsTab() const { return _flags & WIDGET_WANTS_TAB; }
bool wantsRaw() const { return _flags & WIDGET_WANTS_RAWDATA; } bool wantsRaw() const { return _flags & WIDGET_WANTS_RAWDATA; }