11#ifndef GAMP_WTWINDOW_HPP_
12#define GAMP_WTWINDOW_HPP_
36 typedef std::shared_ptr<Window>
WindowRef;
38 using namespace jau::fractions_i64_literals;
39 using namespace jau::math;
40 using namespace jau::enums;
41 using namespace gamp::wt::event;
113 std::string res =
"RenderListener[";
114 res.append(
"pending ").append(
to_string(m_pending_actions))
137 Recti m_window_bounds;
161 SelfWinListener(
Window* self) noexcept : m_self(self) {}
169 void windowMoved(WindowEvent&,
const Vec2i& winPos)
override { m_self->setWindowPos(winPos); }
170 void windowDestroyNotify(WindowEvent&)
override {}
171 void windowDestroyed(WindowEvent&)
override {}
172 void windowFocusChanged(WindowEvent&,
bool focused)
override { m_self->setFocused(
focused); }
173 void windowRepaint(WindowEvent&)
override {}
174 void windowVisibilityChanged(WindowEvent&,
bool visible)
override { m_self->setVisible(
visible); }
178 void disposeImpl(
handle_t handle)
noexcept;
185 m_window_handle(window_handle),
187 m_win_selflistener(
std::make_shared<SelfWinListener>(this))
201 return std::make_shared<Window>(
Private(), window_handle, window_bounds,
202 surface_handle, surface_size);
210 static WindowRef create(
const char* title,
int wwidth,
int wheight,
bool verbose=
false);
230 constexpr Vec2i windowPos() const noexcept {
return m_window_bounds.getPosition(); }
284 m_win_evt_mngr.dispatchResize(when,
shared(), winSize, surfSize);
289 if( m_window_bounds.getPosition() != winPos ) {
290 m_win_evt_mngr.dispatchMoved(when,
shared(), winPos);
305 m_key_evt_mngr.dispatchPressed(when,
shared(), keySym, keySymMods, keyChar);
308 m_key_evt_mngr.dispatchReleased(when,
shared(), keySym, keySymMods, keyChar);
322 m_ptr_evt_mngr.dispatch(
type, when,
shared(),
keyTracker().
modifier(), ptype,
id, pos, clickCount, button, rotation, rotationScale);
336 return m_render_listener.erase_matching(l,
true,
341 const size_t count = m_render_listener.size();
342 m_render_listener.clear(
true);
359 if( m_window_handle ) {
360 disposeImpl(m_window_handle);
369 std::string
toString() const noexcept;
constexpr RenderListener(Private) noexcept
Private ctor for shared_ptr<RenderListener> instance method w/o public ctor.
std::string toString() const noexcept
void setPendingActions(RenderActions v) noexcept
virtual bool init(const WindowRef &, const jau::fraction_timespec &)=0
Called by the drawable immediately after the render context is initialized.
virtual void reshape(const WindowRef &, const jau::math::Recti &, const jau::fraction_timespec &)=0
Called by the drawable during the first repaint after the component has been resized.
virtual void display(const WindowRef &, const jau::fraction_timespec &)=0
Called by the drawable to initiate rendering by the client.
RenderActions & pendingActions() noexcept
RenderActions pendingActions() const noexcept
virtual ~RenderListener() noexcept=default
virtual void dispose(const WindowRef &, const jau::fraction_timespec &)=0
Notifies the listener to perform the release of all renderer resources per context,...
virtual std::string toStringImpl() const noexcept
constexpr handle_t surfaceHandle() const noexcept
Returns the handle to the surface for this NativeSurface.
void setSurfaceSize(const Vec2i &sz) noexcept
Surface(Private, handle_t surface_handle, const Vec2i &surface_size)
Private ctor for single Surface::create() method w/o public ctor.
std::shared_ptr< ChildT > shared_from_base()
constexpr bool isBLOriented() const noexcept
Returns true if this surface is rendered in OpenGL's coordinate system, origin at bottom left.
virtual void dispose(const jau::fraction_timespec &) noexcept
virtual void disposedNotify(const jau::fraction_timespec &) noexcept
constexpr const Vec2i & surfaceSize() const noexcept
Returns the surface size of the client area excluding insets (window decorations) in pixel units.
constexpr Vec2i windowPos() const noexcept
Returns the window top-lect position of client-area in window units.
constexpr WindowState state() const noexcept
void display(const jau::fraction_timespec &when) noexcept
constexpr bool hasFocus() const noexcept
constexpr handle_t windowHandle() const noexcept
Returns the handle to the surface for this NativeSurface.
void addRenderListener(const RenderListenerRef &l)
void notifyKeyReleased(const jau::fraction_timespec &when, VKeyCode keySym, InputModifier keySymMods, uint16_t keyChar) noexcept
size_t renderListenerCount() const noexcept
constexpr bool isVisible() const noexcept
bool isValid() const noexcept override
void notifyWindowEvent(uint16_t type, const jau::fraction_timespec &when, bool value=true) noexcept
void addWindowListener(const WindowListenerRef &l)
constexpr Vec2i windowSize() const noexcept
Returns the window size of the client area excluding insets (window decorations) in window units.
void operator=(const Window &)=delete
size_t removeKeyListener(const KeyListenerRef &l)
void setFocused(bool v) noexcept
size_t windowListenerCount() const noexcept
void notifyWindowResize(const jau::fraction_timespec &when, const jau::math::Vec2i &winSize, const jau::math::Vec2i &surfSize) noexcept
~Window() noexcept override=default
Releases this instance.
Window(const Window &)=delete
void notifyWindowMoved(const jau::fraction_timespec &when, const jau::math::Vec2i &winPos) noexcept
size_t pointerListenerCount() const noexcept
size_t removeAllRenderListener()
void notifyKeyPressed(const jau::fraction_timespec &when, VKeyCode keySym, InputModifier keySymMods, uint16_t keyChar) noexcept
size_t removeRenderListener(const RenderListenerRef &l)
size_t removePointerListener(const PointerListenerRef &l)
size_t removeAllPointerListener()
void setVisible(bool v) noexcept
size_t removeAllWindowListener()
void notifyPointer(uint16_t type, const jau::fraction_timespec &when, PointerType ptype, uint16_t id, jau::math::Vec2i pos, uint16_t clickCount, InputButton button, jau::math::Vec3f rotation, float rotationScale) noexcept
size_t removeAllKeyListener()
static WindowRef create(const char *title, int wwidth, int wheight, bool verbose=false)
Create an new instance using a native windowing toolkit.
static WindowRef wrapNative(handle_t window_handle, const Recti &window_bounds, handle_t surface_handle, const Vec2i &surface_size)
Create an new instance, wrapping the native windowing toolkit's handle/resources.
void addPointerListener(const PointerListenerRef &l)
void disposedNotify(const jau::fraction_timespec &when) noexcept override
SurfaceRef nativeSurface()
Returns the associated Surface of this SurfaceHolder.
void setWindowPos(const Vec2i &sz) noexcept
const KeyboardTracker & keyTracker() const noexcept
constexpr const Recti & windowBounds() const noexcept
Returns the window client-area top-left position and size excluding insets (window decorations) in wi...
size_t removeWindowListener(const WindowListenerRef &l)
void dispose(const jau::fraction_timespec &when) noexcept override
bool surfaceSwap() noexcept override
Provide a mechanism to utilize custom (pre-) swap surface code.
void setWindowBounds(const Recti &r) noexcept
Window(Private, handle_t window_handle, const Recti &window_bounds, handle_t surface_handle, const Vec2i &surface_size)
Private ctor for single Window::create() method w/o public ctor.
void setWindowSize(const Vec2i &sz) noexcept
std::string toString() const noexcept
size_t keyListenerCount() const noexcept
constexpr bool isPointerBLOriented() const noexcept
Returns true if this window delivers PointerEvent in OpenGL's coordinate system, origin at bottom lef...
void disposeRenderListener(bool clearRenderListener, const jau::fraction_timespec &when) noexcept
void addKeyListener(const KeyListenerRef &l)
Listener for multiple WindowEvent.
Implementation of a Copy-On-Write (CoW) using jau::darray as the underlying storage,...
constexpr_atomic storage_ref_t snapshot() const noexcept
Returns the current snapshot of the underlying shared storage by reference.
constexpr bool is_zero() const noexcept
Return true if area is zero.
constexpr bool value(const Bool rhs) noexcept
#define JAU_MAKE_BITFIELD_ENUM_STRING(type,...)
constexpr bool is_set(const E mask, const E bits) noexcept
constexpr E & write(E &store, const E bits, bool set) noexcept
If set==true, sets the bits in store, i.e.
#define JAU_MAKE_ENUM_INFO(type,...)
std::shared_ptr< WindowListener > WindowListenerRef
std::shared_ptr< PointerListener > PointerListenerRef
std::shared_ptr< KeyListener > KeyListenerRef
VKeyCode
Virtual key code following UTF16 specification.
static constexpr uint16_t EVENT_WINDOW_DESTROY_NOTIFY
static constexpr uint16_t EVENT_WINDOW_DESTROYED
PointerType
Type of pointer devices.
std::shared_ptr< RenderListener > RenderListenerRef
std::shared_ptr< Window > WindowRef
std::shared_ptr< Surface > SurfaceRef
uintptr_t handle_t
A native handle type, big enough to store a pointer.
std::string to_string(const math_error_t v) noexcept
Returns std::string representation of math_error_t.
std::string to_hexstring(value_type const &v, const bool skipLeading0x=false) noexcept
Produce a lower-case hexadecimal string representation with leading 0x in MSB of the given pointer.
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
Timespec structure using int64_t for its components in analogy to struct timespec_t on 64-bit platfor...