MeshLib C++ Docs
Loading...
Searching...
No Matches
MRSplashWindow.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRViewerFwd.h"
4#include <string>
5#include <functional>
6#include <atomic>
7#include <thread>
8#include <memory>
9
10struct GLFWwindow;
11struct ImGuiContext;
12
13namespace MR
14{
17
18
21class MRVIEWER_CLASS SplashWindow
22{
23public:
24 MRVIEWER_API SplashWindow( std::string name );
25
27 MRVIEWER_API virtual ~SplashWindow();
28
31 MRVIEWER_API virtual void start();
32
34 MRVIEWER_API virtual void stop();
35
37 virtual float minimumTimeSec() const { return 2.f; }
38
39protected:
40 std::string name_;
41
42 GLFWwindow* window_{ nullptr };
43 ImGuiContext* guiContext_{ nullptr };
44
45 std::atomic<bool> terminate_{ false };
46private:
48 virtual void afterStart_() {}
50 virtual void beforeStop_() {}
51
53 virtual void setup_() const = 0;
55 virtual void postInit_() {}
57 virtual void positioning_( float hdpiScale ) = 0;
59 virtual void reloadFont_( float hdpiScale, float pixelRatio ) = 0;
61 virtual bool frame_( float scaling ) = 0;
63 virtual void preDestruct_() {}
65 virtual void postDestruct_() {}
66
67 std::thread thread_;
68};
69
70#ifndef __EMSCRIPTEN__
71class MRVIEWER_CLASS DefaultSplashWindow final : public SplashWindow
72{
73public:
74 MRVIEWER_API DefaultSplashWindow();
75private:
76 virtual void setup_() const override;
77 virtual void postInit_() override;
78 virtual void positioning_( float hdpiScale ) override;
79 virtual void reloadFont_( float hdpiScale, float pixelRatio ) override;
80 virtual bool frame_( float scaling ) override;
81 virtual void preDestruct_() override;
82
83 std::shared_ptr<ImGuiImage> splashImage_;
84 std::string versionStr_;
85};
86#endif
87
88#ifdef __APPLE__
91class MRVIEWER_CLASS StaticImageSplashWindow final : public SplashWindow
92{
93public:
94 MRVIEWER_API StaticImageSplashWindow();
95 MRVIEWER_API void start() override;
96 MRVIEWER_API void stop() override;
97private:
98 virtual void setup_() const override {}
99 virtual void positioning_( float ) override {}
100 virtual void reloadFont_( float, float ) override {}
101 virtual bool frame_( float ) override { return false; }
102
103 void* nsWindow_ = nullptr;
104};
105#endif
106}
Definition MRSplashWindow.h:22
virtual float minimumTimeSec() const
Returns minimum time in seconds, splash screen to be present.
Definition MRSplashWindow.h:37
virtual void start()
virtual ~SplashWindow()
Thread should be stopped before destructor.
std::atomic< bool > terminate_
Definition MRSplashWindow.h:45
GLFWwindow * window_
Definition MRSplashWindow.h:42
std::string name_
Definition MRSplashWindow.h:40
virtual void stop()
Closes splash window if it is still opened.
ImGuiContext * guiContext_
Definition MRSplashWindow.h:43
SplashWindow(std::string name)
Only strictly necessary for the bindings (to make MR::MeshIntersectionResult a complete type).
Definition MRCameraOrientationPlugin.h:8