@@ -241,12 +241,6 @@ public: | |||||
inline double getScaling() const noexcept { return getScaling(); } | inline double getScaling() const noexcept { return getScaling(); } | ||||
protected: | protected: | ||||
/** | |||||
A function called when the window is resized. | |||||
If there is a top-level widget associated with this window, its size will be set right after this function. | |||||
*/ | |||||
virtual void onReshape(uint width, uint height); | |||||
/** | /** | ||||
A function called when the window is attempted to be closed. | A function called when the window is attempted to be closed. | ||||
Returning true closes the window, which is the default behaviour. | Returning true closes the window, which is the default behaviour. | ||||
@@ -254,6 +248,18 @@ protected: | |||||
*/ | */ | ||||
virtual bool onClose(); | virtual bool onClose(); | ||||
/** | |||||
A function called when the window gains or loses the keyboard focus. | |||||
The default implementation does nothing. | |||||
*/ | |||||
virtual void onFocus(bool focus); | |||||
/** | |||||
A function called when the window is resized. | |||||
If there is a top-level widget associated with this window, its size will be set right after this function. | |||||
*/ | |||||
virtual void onReshape(uint width, uint height); | |||||
private: | private: | ||||
struct PrivateData; | struct PrivateData; | ||||
PrivateData* const pData; | PrivateData* const pData; | ||||
@@ -227,14 +227,18 @@ void Window::setGeometryConstraints(const uint minimumWidth, | |||||
} | } | ||||
} | } | ||||
void Window::onReshape(uint, uint) | |||||
bool Window::onClose() | |||||
{ | { | ||||
puglFallbackOnResize(pData->view); | |||||
return true; | |||||
} | } | ||||
bool Window::onClose() | |||||
void Window::onFocus(bool) | |||||
{ | { | ||||
return true; | |||||
} | |||||
void Window::onReshape(uint, uint) | |||||
{ | |||||
puglFallbackOnResize(pData->view); | |||||
} | } | ||||
#if 0 | #if 0 | ||||
@@ -384,6 +384,18 @@ void Window::PrivateData::onPuglClose() | |||||
close(); | close(); | ||||
} | } | ||||
void Window::PrivateData::onPuglFocus(const bool focus) | |||||
{ | |||||
DGL_DBGp("onPuglFocus : %i %u %u\n", focus); | |||||
// if (fModal.childFocus != nullptr) | |||||
// return fModal.childFocus->focus(); | |||||
#ifndef DPF_TEST_WINDOW_CPP | |||||
self->onFocus(focus); | |||||
#endif | |||||
} | |||||
void Window::PrivateData::onPuglKey(const Events::KeyboardEvent& ev) | void Window::PrivateData::onPuglKey(const Events::KeyboardEvent& ev) | ||||
{ | { | ||||
DGL_DBGp("onPuglKey : %i %u %u\n", ev.press, ev.key, ev.keycode); | DGL_DBGp("onPuglKey : %i %u %u\n", ev.press, ev.key, ev.keycode); | ||||
@@ -518,10 +530,9 @@ PuglStatus Window::PrivateData::puglEventCallback(PuglView* const view, const Pu | |||||
///< Keyboard focus entered view, a #PuglEventFocus | ///< Keyboard focus entered view, a #PuglEventFocus | ||||
case PUGL_FOCUS_IN: | case PUGL_FOCUS_IN: | ||||
break; | |||||
///< Keyboard focus left view, a #PuglEventFocus | ///< Keyboard focus left view, a #PuglEventFocus | ||||
case PUGL_FOCUS_OUT: | case PUGL_FOCUS_OUT: | ||||
pData->onPuglFocus(event->type == PUGL_FOCUS_IN); | |||||
break; | break; | ||||
///< Key pressed, a #PuglEventKey | ///< Key pressed, a #PuglEventKey | ||||
@@ -109,6 +109,7 @@ struct Window::PrivateData : IdleCallback { | |||||
void onPuglConfigure(int width, int height); | void onPuglConfigure(int width, int height); | ||||
void onPuglExpose(); | void onPuglExpose(); | ||||
void onPuglClose(); | void onPuglClose(); | ||||
void onPuglFocus(bool focus); | |||||
void onPuglKey(const Events::KeyboardEvent& ev); | void onPuglKey(const Events::KeyboardEvent& ev); | ||||
void onPuglSpecial(const Events::SpecialEvent& ev); | void onPuglSpecial(const Events::SpecialEvent& ev); | ||||
void onPuglText(const Events::CharacterInputEvent& ev); | void onPuglText(const Events::CharacterInputEvent& ev); | ||||