Ultralight  1.0.0
A fast, lightweight, HTML UI engine for native apps.
Window.h
Go to the documentation of this file.
1 #pragma once
15 #include "Defines.h"
16 #include <Ultralight/RefPtr.h>
17 #include <Ultralight/Listener.h>
18 
19 namespace ultralight {
20 
21 class Monitor;
22 class OverlayManager;
23 
28 public:
29  virtual ~WindowListener() {}
30 
34  virtual void OnClose() = 0;
35 
43  virtual void OnResize(int width, int height) = 0;
44 };
45 
49 enum WindowFlags : uint8_t {
50  kWindowFlags_Borderless = 1 << 0,
51  kWindowFlags_Titled = 1 << 1,
52  kWindowFlags_Resizable = 1 << 2,
53  kWindowFlags_Maximizable = 1 << 3,
54 };
55 
59 class AExport Window : public RefCounted {
60 public:
74  static Ref<Window> Create(Monitor* monitor, uint32_t width, uint32_t height,
75  bool fullscreen, unsigned int window_flags);
76 
82  virtual void set_listener(WindowListener* listener) = 0;
83 
87  virtual WindowListener* listener() = 0;
88 
92  virtual int width() const = 0;
93 
97  virtual int height() const = 0;
98 
102  virtual bool is_fullscreen() const = 0;
103 
107  virtual double scale() const = 0;
108 
112  virtual void SetTitle(const char* title) = 0;
113 
117  virtual void SetCursor(ultralight::Cursor cursor) = 0;
118 
122  virtual void Close() = 0;
123 
127  virtual int DeviceToPixels(int val) const = 0;
128 
132  virtual int PixelsToDevice(int val) const = 0;
133 
134 protected:
135  virtual ~Window();
136  virtual OverlayManager* overlay_manager() const = 0;
137 
138  friend class OverlayImpl;
139 };
140 
141 } // namespace ultralight
virtual void OnResize(int width, int height)=0
Called when the Window is resized.
virtual void OnClose()=0
Called when the Window is closed.
A non-nullable smart pointer.
Definition: RefPtr.h:64
The header for View listener interfaces.
Interface for all Window-related events.
Definition: Window.h:27
This is a set of common JavaScriptCore Helper functions to simplify sample code.
Definition: App.h:19
The header for all ref-counting utilities.
Interface for all ref-counted objects that will be managed using the Ref<> and RefPtr<> smart pointer...
Definition: RefPtr.h:53
Cursor
Cursor types,.
Definition: Listener.h:53
WindowFlags
Window creation flags.
Definition: Window.h:49
Window class, represents a platform window.
Definition: Window.h:59
Monitor class, represents a platform monitor.
Definition: Monitor.h:22