Bug fixes
This commit is contained in:
parent
fb9876ad22
commit
6fb05f77ab
9 changed files with 54 additions and 49 deletions
|
|
@ -1 +1 @@
|
|||
2078
|
||||
2087
|
||||
|
|
|
|||
|
|
@ -173,6 +173,7 @@ namespace ogfx
|
|||
ostd::ConsoleOutputHandler m_out;
|
||||
GraphicsWindowOutputHandler m_wout;
|
||||
const ostd::Stylesheet* m_guiTheme { nullptr };
|
||||
bool m_refreshScreen { true };
|
||||
|
||||
private:
|
||||
Color m_clearColor { 10, 10, 10, 255 };
|
||||
|
|
@ -190,7 +191,6 @@ namespace ogfx
|
|||
bool m_visible { true };
|
||||
bool m_blockingEvents { false };
|
||||
bool m_resizeable { true };
|
||||
bool m_refreshScreen { true };
|
||||
bool m_invertHorizontalScroll { true };
|
||||
|
||||
f32 m_systemScale { 1.0f };
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ namespace ogfx
|
|||
if (m_window != nullptr) return;
|
||||
m_window = &window;
|
||||
m_renderer.init(window);
|
||||
m_renderer.loadDefaultMonoFont(18);
|
||||
}
|
||||
|
||||
void GraphicsWindowOutputHandler::setMonospaceFont(const String& filePath)
|
||||
|
|
|
|||
|
|
@ -166,7 +166,9 @@ namespace ogfx
|
|||
{
|
||||
if (!m_initialized || !m_fontOpen) return;
|
||||
if (m_font != nullptr)
|
||||
{
|
||||
TTF_CloseFont(m_font);
|
||||
}
|
||||
m_font = nullptr;
|
||||
m_fontOpen = false;
|
||||
m_fontSize = DefaultFontSize;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <limits>
|
||||
#include <ostd/utils/Defines.hpp>
|
||||
|
||||
typedef int8_t i8;
|
||||
|
|
|
|||
|
|
@ -46,11 +46,3 @@
|
|||
|
||||
#include <ostd/utils/Signals.hpp>
|
||||
#include <ostd/utils/Time.hpp>
|
||||
|
||||
namespace ostd
|
||||
{
|
||||
inline void initialize(void)
|
||||
{
|
||||
ostd::SignalHandler::init(true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,34 +4,24 @@
|
|||
|
||||
namespace ostd
|
||||
{
|
||||
void SignalHandler::init(bool allow_reinit)
|
||||
{
|
||||
if (m_initialized && !allow_reinit) return;
|
||||
m_recievers.clear();
|
||||
m_recievers.reserve(__SIGNAL_BUFFER_START_SIZE);
|
||||
m_DelegateRecievers.clear();
|
||||
m_DelegateRecievers.reserve(__DELEGATE_SIGNALS_BUFFER_START_SIZE);
|
||||
m_initialized = true;
|
||||
}
|
||||
|
||||
void SignalHandler::handleDelegateSignals(void)
|
||||
{
|
||||
for (auto& delegate : m_DelegateRecievers)
|
||||
for (auto& delegate : delegateReceivers())
|
||||
emitSignal(delegate.id, Signal::Priority::RealTime, delegate.ud);
|
||||
m_DelegateRecievers.clear();
|
||||
delegateReceivers().clear();
|
||||
}
|
||||
|
||||
void SignalHandler::emitSignal(u32 signal_id, u8 prio, BaseObject& userData)
|
||||
{
|
||||
if (prio == Signal::Priority::Normal)
|
||||
{
|
||||
SignalHandler::m_DelegateRecievers.push_back({ signal_id, userData });
|
||||
SignalHandler::delegateReceivers().push_back({ signal_id, userData });
|
||||
return;
|
||||
}
|
||||
Signal signal { signal_id, userData, prio };
|
||||
if (m_recievers.count(signal_id) < 1)
|
||||
if (receivers().count(signal_id) < 1)
|
||||
return;
|
||||
for (auto& obj : m_recievers[signal_id])
|
||||
for (auto& obj : receivers()[signal_id])
|
||||
{
|
||||
obj->__handle_signal(signal);
|
||||
if (signal.handled) return;
|
||||
|
|
@ -40,13 +30,13 @@ namespace ostd
|
|||
|
||||
void SignalHandler::connect(BaseObject& object, u32 signal_id)
|
||||
{
|
||||
m_recievers[signal_id].push_back(&object);
|
||||
receivers()[signal_id].push_back(&object);
|
||||
}
|
||||
|
||||
void SignalHandler::disconnect(BaseObject& object, u32 signal_id)
|
||||
{
|
||||
auto it = m_recievers.find(signal_id);
|
||||
if (it == m_recievers.end())
|
||||
auto it = receivers().find(signal_id);
|
||||
if (it == receivers().end())
|
||||
return;
|
||||
STDVEC_REMOVE(it->second, &object);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,16 +80,36 @@ namespace ostd
|
|||
inline DelegateSignal(u32 _id, BaseObject& _ud) : id(_id), ud(_ud) { }
|
||||
};
|
||||
public:
|
||||
static void init(bool allow_reinit = false);
|
||||
static void handleDelegateSignals(void);
|
||||
static void emitSignal(u32 signal_id, u8 prio = Signal::Priority::RealTime, BaseObject& userData = BaseObject::InvalidRef());
|
||||
static void connect(BaseObject& object, u32 signal_id);
|
||||
static void disconnect(BaseObject& object, u32 signal_id);
|
||||
inline static u32 newCustomSignal(u32 sub_id) { return BuiltinSignals::CustomSignalBase + sub_id; }
|
||||
|
||||
private:
|
||||
inline static stdumap<u32, stdvec<BaseObject*>>& receivers(void)
|
||||
{
|
||||
static stdumap<u32, stdvec<BaseObject*>> m = [] {
|
||||
stdumap<u32, stdvec<BaseObject*>> map;
|
||||
map.reserve(__SIGNAL_BUFFER_START_SIZE);
|
||||
return map;
|
||||
}();
|
||||
return m;
|
||||
}
|
||||
|
||||
inline static stdvec<DelegateSignal>& delegateReceivers(void)
|
||||
{
|
||||
static stdvec<DelegateSignal> v = [] {
|
||||
stdvec<DelegateSignal> vec;
|
||||
vec.reserve(__DELEGATE_SIGNALS_BUFFER_START_SIZE);
|
||||
return vec;
|
||||
}();
|
||||
return v;
|
||||
}
|
||||
|
||||
private:
|
||||
inline static stdumap<u32, stdvec<BaseObject*>> m_recievers;
|
||||
inline static stdvec<DelegateSignal> m_DelegateRecievers;
|
||||
inline static stdvec<DelegateSignal> m_delegateRecievers;
|
||||
inline static constexpr u16 __SIGNAL_BUFFER_START_SIZE { 2048 };
|
||||
inline static constexpr u16 __DELEGATE_SIGNALS_BUFFER_START_SIZE { 2048 };
|
||||
inline static bool m_initialized { false };
|
||||
|
|
|
|||
|
|
@ -516,7 +516,6 @@ class TestWindow : public Window
|
|||
i32 main(i32 argc, char** argv)
|
||||
{
|
||||
ostd::Random::autoSeed();
|
||||
ostd::initialize();
|
||||
TestWindow window;
|
||||
window.initialize(1200, 900, "OmniaFramework - Test Window");
|
||||
window.setClearColor({ 0, 0, 0 });
|
||||
|
|
|
|||
Loading…
Reference in a new issue