Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
sdl_window_host.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <pulp/view/view.hpp>
4#include <string>
5#include <memory>
6#include <functional>
7#include <cstdint>
8
9namespace pulp::view {
10
11// SDL3-backed window host for cross-platform standalone UI preview
12// Uses SDL3 for window management and input, CoreGraphics/etc for rendering
14public:
15 struct Options {
16 std::string title = "Pulp";
17 uint32_t width = 400;
18 uint32_t height = 300;
19 bool resizable = true;
20
21 Options() = default;
22 };
23
24 // Create an SDL3 window hosting the given view tree
25 static std::unique_ptr<SdlWindowHost> create(View& root, Options options);
26
27 virtual ~SdlWindowHost() = default;
28
29 virtual void show() = 0;
30 virtual void hide() = 0;
31 virtual void repaint() = 0;
32
33 // Called once per event-loop iteration before a frame is painted. The
34 // standalone bridge uses this for editor polling and settings updates.
35 virtual void set_idle_callback(std::function<void()> cb) = 0;
36
37 virtual void request_content_size(float width, float height) = 0;
38 virtual void set_fixed_aspect_ratio(float ratio) = 0;
39 virtual void set_design_viewport(float width, float height) = 0;
40
41 // Run the event loop (blocks until window closed)
42 virtual void run_event_loop() = 0;
43
44 // Native content-view handle for outbound file drag (mirrors
45 // WindowHost::native_content_view_handle). X11 Window id on Linux, HWND on
46 // Windows; nullptr where unsupported so the drag degrades to false. The SDL
47 // backend overrides this; the default keeps non-drag SDL hosts buildable.
48 virtual void* native_content_view_handle() const { return nullptr; }
49
50 // Set close callback
51 virtual void set_close_callback(std::function<void()> cb) = 0;
52};
53
54} // namespace pulp::view
Definition sdl_window_host.hpp:13
virtual void show()=0
virtual void set_design_viewport(float width, float height)=0
virtual void * native_content_view_handle() const
Definition sdl_window_host.hpp:48
virtual void set_fixed_aspect_ratio(float ratio)=0
static std::unique_ptr< SdlWindowHost > create(View &root, Options options)
virtual void request_content_size(float width, float height)=0
virtual void set_idle_callback(std::function< void()> cb)=0
virtual void hide()=0
virtual ~SdlWindowHost()=default
virtual void set_close_callback(std::function< void()> cb)=0
virtual void run_event_loop()=0
virtual void repaint()=0
Definition view.hpp:73
Hover-cursor tracking for platform window hosts.
Definition fwd.hpp:27
@ height
Definition css_animation.hpp:128
@ width
Definition css_animation.hpp:127
Definition sdl_window_host.hpp:15
uint32_t width
Definition sdl_window_host.hpp:17
std::string title
Definition sdl_window_host.hpp:16
bool resizable
Definition sdl_window_host.hpp:19
uint32_t height
Definition sdl_window_host.hpp:18