Refactoring in SizeNotifiable.
Class is a template now and accepts a registraton policy.
This commit is contained in:
parent
dbf29f13d1
commit
d0a052ddb2
7 changed files with 122 additions and 22 deletions
|
@ -1,10 +1,40 @@
|
|||
#include "sizenotifiable.hpp"
|
||||
#include "sizeratio.hpp"
|
||||
#include "sdlmain.hpp"
|
||||
#include <cassert>
|
||||
#include <ciso646>
|
||||
|
||||
namespace cloonel {
|
||||
namespace implem {
|
||||
} //namespace implem
|
||||
|
||||
namespace regbehaviuors {
|
||||
///----------------------------------------------------------------------
|
||||
///----------------------------------------------------------------------
|
||||
void AutoRegister::Register (SizeNotifiableBase* parNotifiable) {
|
||||
assert(m_sdlmain);
|
||||
#if !defined(NDEBUG)
|
||||
assert(not m_registered);
|
||||
m_registered = true;
|
||||
#endif
|
||||
m_id = m_sdlmain->RegisterForResChange(parNotifiable);
|
||||
}
|
||||
|
||||
///----------------------------------------------------------------------
|
||||
///----------------------------------------------------------------------
|
||||
void AutoRegister::Unregister() noexcept {
|
||||
#if !defined(NDEBUG)
|
||||
assert(m_registered);
|
||||
m_registered = false;
|
||||
#endif
|
||||
assert(m_sdlmain);
|
||||
m_sdlmain->UnregisterForResChange(m_id);
|
||||
}
|
||||
} //namespace regbehaviuors
|
||||
|
||||
///--------------------------------------------------------------------------
|
||||
///--------------------------------------------------------------------------
|
||||
void SizeNotifiable::NotifyResChanged (const SizeRatio& parSize) {
|
||||
void SizeNotifiableBase::NotifyResChanged (const SizeRatio& parSize) {
|
||||
m_scaleRatio = parSize.Ratio();
|
||||
}
|
||||
} //namespace cloonel
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue