18#include <AUI/View/AViewContainer.h>
19#include "AUI/Performance/APerformanceFrame.h"
20#include "AUI/Performance/APerformanceSection.h"
21#include "AWindowManager.h"
22#include "AOverlappingSurface.h"
23#include "ADragNDrop.h"
24#include "AUI/Util/ATouchScroller.h"
25#include "ATouchscreenKeyboardPolicy.h"
57 bool highlightRedrawRequests =
false;
63 bool renderToTextureDecay =
false;
69 bool breakpointOnMarkMinContentSizeInvalid =
false;
87 virtual void blockUserInput(
bool blockUserInput =
true);
101 void preventClickOnPointerRelease();
108 return mPreventClickOnPointerRelease.valueOr(
false);
114 template<aui::invocable<const _<AView>&> Callback>
116 for (
auto view = mFocusedView.lock(); view;) {
119 auto container = _cast<AViewContainer>(view);
120 if (!container)
return;
121 view = container->focusChainTarget();
137 return *getWindowManagerImpl();
139 template<
typename WindowManager,
typename... Args>
140 static void setWindowManager(Args&&...
args) {
141 destroyWindowManager();
143 getWindowManagerImpl() = std::make_unique<WindowManager>(std::forward<Args>(
args)...);
145 static void destroyWindowManager() {
146 getWindowManagerImpl() =
nullptr;
149 const _unique<IRenderingContext>& getRenderingContext()
const {
150 return mRenderingContext;
154 BeforeFrameQueue& beforeFrameQueue() noexcept {
155 return mBeforeFrameQueue;
172 return mFocusedView.lock();
175 void setFocusedView(
const _<AView>& view);
176 void updateFocusChain();
181 void closeOverlappingSurfacesOnClick();
183 bool isFocused()
const {
188 const glm::ivec2& getMousePos()
const {
192 void onKeyDown(AInput::Key key)
override;
195 virtual void focusNextView();
196 virtual void flagRedraw();
199 currentWindowStorage() =
this;
230 const glm::ivec2& size,
231 bool closeOnClick =
true) {
234 case 0:
return position;
235 case 1:
return glm::clamp(position, {0, 0}, {
getSize() - size});
236 default:
return std::nullopt;
238 }, size, closeOnClick);
252 const glm::ivec2& size,
253 bool closeOnClick =
true) {
254 glm::ivec2 position = {0, 0};
255 auto maxPos =
getSize() - size;
256 for (
unsigned index = 0; ; ++index) {
257 auto optionalPosition = positionFactory(index);
258 if (optionalPosition) {
259 position = *optionalPosition;
261 if (position.x >= 0 && position.y >= 0 && glm::all(glm::lessThan(position, maxPos))) {
269 auto tmp = createOverlappingSurfaceImpl(position, size);
270 tmp->mParentWindow =
this;
271 tmp->mCloseOnClick = closeOnClick;
272 mOverlappingSurfaces << tmp;
277 closeOverlappingSurfaceImpl(surface);
281 void onFocusLost()
override;
283 void applyGeometryToChildren()
override;
299 virtual void onDragLeave();
305 void requestShowTouchscreenKeyboard();
310 void requestHideTouchscreenKeyboard();
316 bool shouldDisplayHoverAnimations()
const;
323 virtual void forceUpdateCursor();
325 bool onGesture(
const glm::ivec2& origin,
const AGestureEvent& event)
override;
330 static constexpr std::chrono::milliseconds DOUBLECLICK_MAX_DURATION = std::chrono::milliseconds(500);
337 return mLastCapturedFps;
340 void setTouchscreenKeyboardPolicy(ATouchscreenKeyboardPolicy policy)
noexcept {
341 mKeyboardPolicy = policy;
348 float scalingFactor = 1.f;
369 void markMinContentSizeInvalid()
override;
393 bool mIsFocused =
true;
403 bool mForceUpdateCursorGuard =
false;
405 bool mPerformDoubleClickOnPointerRelease =
false;
407 std::chrono::milliseconds mLastButtonPressedTime = std::chrono::milliseconds::zero();
409 glm::vec2 mLastPosition = {0, 0};
411 _unique<IRenderingContext> mRenderingContext;
421 virtual void createDevtoolsWindow();
423 static _unique<AWindowManager>& getWindowManagerImpl();
425 virtual float fetchDpiFromSystem()
const;
427 virtual void showTouchscreenKeyboardImpl();
428 virtual void hideTouchscreenKeyboardImpl();
433 void processTouchscreenKeyboardRequest();
437 float mDpiRatio = 1.f;
438 ScalingParams mScalingParams;
440 BeforeFrameQueue mBeforeFrameQueue;
442 ATouchscreenKeyboardPolicy mKeyboardPolicy = ATouchscreenKeyboardPolicy::SHOWN_IF_NEEDED;
444 enum class KeyboardRequest {
450 KeyboardRequest mKeyboardRequestedState = KeyboardRequest::NO_OP;
452 glm::ivec2 mMousePos = {0, 0};
465 std::chrono::time_point<std::chrono::high_resolution_clock> mLastTimeFpsCaptured = std::chrono::high_resolution_clock::now();
466 size_t mFpsCounter = 0;
467 size_t mLastCapturedFps = 0;
486#define AUI_ASSERT_UI_THREAD_ONLY() { AUI_ASSERTX((AWindow::current() ? AThread::current() == AWindow::current()->getThread() : AThread::current() == getThread()), "this method should be used in ui thread only."); }
494#define AUI_ASSERT_WORKER_THREAD_ONLY() { AUI_ASSERTX(AThread::current() != AWindow::current()->getThread(), "this method should be used in worker thread only."); }
A std::map with AUI extensions.
Definition: AMap.h:218
Utility wrapper implementing the stack-allocated (fast) optional idiom.
Definition: AOptional.h:32
Definition: AOverlappingSurface.h:19
Wrapper class that stores either mouse button index or finger index.
Definition: APointerIndex.h:21
A std::set with AUI extensions.
Definition: ASet.h:25
Vector-like container consisting of few elements on stack and switches to dynamic allocation vector i...
Definition: ASmallVector.h:34
A std::vector with AUI extensions.
Definition: AVector.h:38
void onPointerPressed(const APointerPressedEvent &event) override
Called on pointer (mouse) released event.
Definition: AViewContainerBase.cpp:287
bool onGesture(const glm::ivec2 &origin, const AGestureEvent &event) override
Definition: AViewContainerBase.cpp:547
void onPointerMove(glm::vec2 pos, const APointerMoveEvent &event) override
Handles pointer hover events.
Definition: AViewContainerBase.cpp:242
void markPixelDataInvalid(ARect< int > invalidArea) override
A view requests to redraw it and passes it's coords relative to this.
Definition: AViewContainerBase.cpp:641
void onPointerReleased(const APointerReleasedEvent &event) override
Called on pointer (mouse) released event.
Definition: AViewContainerBase.cpp:327
void onScroll(const AScrollEvent &event) override
Definition: AViewContainerBase.cpp:359
void render(ARenderContext context) override
Draws this AView. Noone should call this function except rendering routine.
Definition: AViewContainerBase.cpp:233
A trivial modifiable view that represents a set of views.
Definition: AViewContainer.h:33
glm::ivec2 getSize() const noexcept
Size, including content area, border and padding.
Definition: AView.h:370
Definition: AWindowBase.h:33
float getDpiRatio()
Returns current dpi ratio.
Definition: AWindowBase.h:165
bool isPreventingClickOnPointerRelease() const noexcept
Definition: AWindowBase.h:107
AOptional< bool > mPreventClickOnPointerRelease
Definition: AWindowBase.h:398
virtual _< AOverlappingSurface > createOverlappingSurfaceImpl(const glm::ivec2 &position, const glm::ivec2 &size)=0
void iterateOverFocusChain(Callback &&callback)
Iterates over focus chain, from parent to child.
Definition: AWindowBase.h:115
_< AOverlappingSurface > createOverlappingSurface(const glm::ivec2 &position, const glm::ivec2 &size, bool closeOnClick=true)
Definition: AWindowBase.h:229
virtual unsigned frameMillis() const noexcept=0
Returns previous frame's rendering duration in millis.
emits touchscreenKeyboardHidden
On touch screen keyboard hide.
Definition: AWindowBase.h:386
size_t getFps()
Definition: AWindowBase.h:336
_< AOverlappingSurface > createOverlappingSurface(const std::function< AOptional< glm::ivec2 >(unsigned)> &positionFactory, const glm::ivec2 &size, bool closeOnClick=true)
Definition: AWindowBase.h:251
emits touchscreenKeyboardShown
On touch screen keyboard show.
Definition: AWindowBase.h:380
Profiling & profiling()
Get profiling settings (mutable).
Definition: AWindowBase.h:365
Definition: AWindowManager.h:23
Definition: SoftwareRenderer.h:19
An std::weak_ptr with AUI extensions.
Definition: SharedPtrTypes.h:177
Definition: UITestCase.h:26
API_AUI_CORE const ACommandLineArgs & args() noexcept
Definition: OSAndroid.cpp:29
Definition: ADragNDrop.h:67
Definition: ADragNDrop.h:62
Pointing method move event.
Definition: APointerMoveEvent.h:21
Pointing method press event.
Definition: APointerPressedEvent.h:21
Pointing method press event.
Definition: APointerReleasedEvent.h:19
Axis aligned 2D rectangle.
Definition: ARect.h:24
Render context passed to AView::render.
Definition: ARenderContext.h:43
Profiling (debugging) settings for this window.
Definition: AWindowBase.h:48
_weak< AView > highlightView
View to highlight.
Definition: AWindowBase.h:52
Definition: AWindowBase.h:344
Definition: IRenderingContext.h:38
Definition: MouseMove.h:16
An std::weak_ptr with AUI extensions.
Definition: SharedPtrTypes.h:51
static _< T > fake(T *raw)
Definition: SharedPtrTypes.h:376