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;
// Account for the extra width of embedded scrollbar
virtual int getWidth() const override;
virtual bool wantsFocus() { return true; }
int getWidth() const override;
bool wantsFocus() const override { return true; }
void loadConfig() override;
private:

View File

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

View File

@ -39,7 +39,7 @@ class ToggleWidget : public Widget, public CommandSender
const BoolArray& getState() { return _stateList; }
bool getSelectedState() const { return _stateList[_selectedItem]; }
virtual bool wantsFocus() { return true; }
bool wantsFocus() const override { return true; }
int colWidth() const { return _colWidth; }
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)
{ return false; }
/**
Returns the name of this controller.
*/
virtual string name() const override { return myName; }
/**
Returns more detailed information about this controller.
*/
@ -237,6 +232,11 @@ class Controller : public Serializable
*/
bool load(Serializer& in) override;
/**
Returns the name of this controller.
*/
string name() const override { return myName; }
public:
/// Constant which represents maximum resistance for analog pins
static constexpr Int32 maximumResistance = 0x7FFFFFFF;

View File

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

View File

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

View File

@ -1042,10 +1042,21 @@ void TIA::tickHframe()
myPlayfield.tick(x);
if (lineNotCached)
renderSprites();
// Render sprites
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())
renderPixel(x, y, lineNotCached);
@ -1064,26 +1075,6 @@ void TIA::applyRsync()
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()
{

View File

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

View File

@ -40,7 +40,7 @@ class ComboDialog : public Dialog
void saveConfig() 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:
Event::Type myComboEvent;

View File

@ -58,7 +58,7 @@ class EditableWidget : public Widget, public CommandSender
bool handleKeyDown(StellaKey key, StellaMod mod) override;
// 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
void setTextFilter(const TextFilter& filter) { _filter = filter; }

View File

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

View File

@ -55,7 +55,7 @@ class LauncherDialog : public Dialog
public:
LauncherDialog(OSystem& osystem, DialogContainer& parent,
int x, int y, int w, int h);
virtual ~LauncherDialog();
virtual ~LauncherDialog() = default;
/**
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 Variant& getSelectedTag() const { return myMenu->getSelectedTag(); }
bool wantsFocus() { return true; }
bool wantsFocus() const override { return true; }
protected:
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 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 wantsRaw() const { return _flags & WIDGET_WANTS_RAWDATA; }