Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devel #3032

Merged
merged 3 commits into from
Feb 13, 2024
Merged

Devel #3032

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions Samples/Common/include/Sample.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace OgreBites
| Base class responsible for everything specific to one sample.
| Designed to be subclassed for each sample.
=============================================================================*/
class Sample : public InputListener, public TrayListener, public Ogre::GeneralAllocatedObject
class Sample : public InputListener, public TrayListener, public Ogre::FrameListener
{
public:
/*=============================================================================
Expand Down Expand Up @@ -189,6 +189,7 @@ namespace OgreBites
mContentSetup = true;

mDone = false;
mContext->addInputListener(this);
}

/*-----------------------------------------------------------------------------
Expand All @@ -198,6 +199,8 @@ namespace OgreBites
{
Ogre::ControllerManager::getSingleton().clearControllers();

mContext->removeInputListener(this);

if (mContentSetup)
cleanupContent();
if (mSceneMgr)
Expand All @@ -224,13 +227,19 @@ namespace OgreBites
| Actions to perform when the context stops sending frame listener events
| and input device events to this sample.
-----------------------------------------------------------------------------*/
virtual void paused() {}
virtual void paused()
{
mContext->removeInputListener(this);
}

/*-----------------------------------------------------------------------------
| Actions to perform when the context continues sending frame listener
| events and input device events to this sample.
-----------------------------------------------------------------------------*/
virtual void unpaused() {}
virtual void unpaused()
{
mContext->addInputListener(this);
}

/*-----------------------------------------------------------------------------
| Saves the sample state. Optional. Used during reconfiguration.
Expand All @@ -241,17 +250,6 @@ namespace OgreBites
| Restores the sample state. Optional. Used during reconfiguration.
-----------------------------------------------------------------------------*/
virtual void restoreState(Ogre::NameValuePairList& state) {}

// callback interface copied from various listeners to be used by SampleContext

virtual bool frameStarted(const Ogre::FrameEvent& evt) { return true; }
virtual bool frameRenderingQueued(const Ogre::FrameEvent& evt) { return true; }
virtual bool frameEnded(const Ogre::FrameEvent& evt) { return true; }
virtual void windowMoved(Ogre::RenderWindow* rw) {}
virtual void windowResized(Ogre::RenderWindow* rw) {}
virtual bool windowClosing(Ogre::RenderWindow* rw) { return true; }
virtual void windowClosed(Ogre::RenderWindow* rw) {}
virtual void windowFocusChange(Ogre::RenderWindow* rw) {}
protected:

/*-----------------------------------------------------------------------------
Expand Down
106 changes: 0 additions & 106 deletions Samples/Common/include/SampleContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,112 +212,6 @@ namespace OgreBites
return true;
}

/*-----------------------------------------------------------------------------
| Processes window size change event. Adjusts mouse's region to match that
| of the window. You could also override this method to prevent resizing.
-----------------------------------------------------------------------------*/
void windowResized(Ogre::RenderWindow* rw) override
{
// manually call sample callback to ensure correct order
if (!isCurrentSamplePaused()) mCurrentSample->windowResized(rw);
}

// window event callbacks which manually call their respective sample callbacks to ensure correct order

void windowMoved(Ogre::RenderWindow* rw) override
{
if (!isCurrentSamplePaused()) mCurrentSample->windowMoved(rw);
}

bool windowClosing(Ogre::RenderWindow* rw) override
{
if (!isCurrentSamplePaused()) return mCurrentSample->windowClosing(rw);
return true;
}

void windowClosed(Ogre::RenderWindow* rw) override
{
if (!isCurrentSamplePaused()) mCurrentSample->windowClosed(rw);
}

void windowFocusChange(Ogre::RenderWindow* rw) override
{
if (!isCurrentSamplePaused()) mCurrentSample->windowFocusChange(rw);
}

// keyboard and mouse callbacks which manually call their respective sample callbacks to ensure correct order

bool keyPressed(const KeyboardEvent& evt) override
{
// Ignore repeated signals from key being held down.
if (evt.repeat) return true;

if (!isCurrentSamplePaused()) return mCurrentSample->keyPressed(evt);
return true;
}

bool keyReleased(const KeyboardEvent& evt) override
{
if (!isCurrentSamplePaused()) return mCurrentSample->keyReleased(evt);
return true;
}

bool touchMoved(const TouchFingerEvent& evt) override
{
if (!isCurrentSamplePaused())
return mCurrentSample->touchMoved(evt);
return true;
}

bool mouseMoved(const MouseMotionEvent& evt) override
{
if (!isCurrentSamplePaused())
return mCurrentSample->mouseMoved(evt);
return true;
}

bool touchPressed(const TouchFingerEvent& evt) override
{
if (!isCurrentSamplePaused())
return mCurrentSample->touchPressed(evt);
return true;
}

bool mousePressed(const MouseButtonEvent& evt) override
{
if (!isCurrentSamplePaused())
return mCurrentSample->mousePressed(evt);
return true;
}

bool touchReleased(const TouchFingerEvent& evt) override
{
if (!isCurrentSamplePaused())
return mCurrentSample->touchReleased(evt);
return true;
}

bool mouseReleased(const MouseButtonEvent& evt) override
{
if (!isCurrentSamplePaused())
return mCurrentSample->mouseReleased(evt);
return true;
}

bool mouseWheelRolled(const MouseWheelEvent& evt) override
{
if (!isCurrentSamplePaused())
return mCurrentSample->mouseWheelRolled(evt);
return true;
}

bool textInput (const TextInputEvent& evt) override
{
if (!isCurrentSamplePaused ())
return mCurrentSample->textInput (evt);
return true;
}

bool isFirstRun() { return mFirstRun; }
void setFirstRun(bool flag) { mFirstRun = flag; }
bool isLastRun() { return mLastRun; }
Expand Down
1 change: 1 addition & 0 deletions Samples/Common/include/SdkSample.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ namespace OgreBites
-----------------------------------------------------------------------------*/
void unpaused() override
{
Sample::unpaused();
mTrayMgr->refreshCursor();
}

Expand Down
Loading