1 /**
2  * Definition of IGraphics, which controls the UI from the host point of view.
3  *
4  * Copyright: Copyright Auburn Sounds 2015 and later.
5  * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
6  * Authors:   Guillaume Piolat
7  */
8 module dplug.client.graphics;
9 
10 import dplug.client.client;
11 import dplug.client.daw;
12 
13 enum GraphicsBackend
14 {
15     autodetect,
16     win32,
17     carbon,
18     cocoa,
19     x11
20 }
21 
22 /// Plugin GUI
23 interface IGraphics
24 {
25 nothrow:
26 @nogc:
27     /// Create an UI, return a system-specific handle for the window/view
28     abstract void* openUI(void* parentInfo, 
29                           void* controlInfo, 
30                           IClient client,
31                           GraphicsBackend backend);
32 
33     /// Close that UI.
34     abstract void closeUI();
35 
36     /// Get the current plugin UI size in logical pixels.
37     abstract void getGUISize(int* widthLogicalPixels, int* heightLogicalPixels);
38 
39     /// Used by VST3.
40     /// Returns: `true` if this is resizeable in terms of logical pixels.
41     /// This should succeed even if the UI is closed.
42     abstract bool isResizeable();
43 
44     /// Used by VST3.
45     /// Returns: Maximum valid size that still fits into a `inoutWidth x inoutHeight` rectangle.
46     ///          When one of the criterion is impossible to satisfy, returning a valid size is preferred.
47     /// This should work even if the UI is closed.
48     abstract void getMaxSmallerValidSize(int* inoutWidth, int* inoutHeight);
49 
50     /// Used by VST3.
51     /// Returns: Nearest, valid size in logical pixels, given an input size in logical pixels.
52     /// This should work even if the UI is closed.
53     /// Hack: Used by FLP format to find minimum and maximum size of window in logical pixels.
54     abstract void getNearestValidSize(int* inoutWidth, int* inoutHeight);
55 
56     /// Used by VST3.
57     /// Tells the native window to resize itself.
58     /// Called by the host when it's one resizing the parent window, and wants our window to follow suit.
59     /// This is to be forwarded to IWindow.
60     /// Returns: `true` if properly resized.
61     abstract bool nativeWindowResize(int newWidthLogicalPixels, int newHeightLogicalPixels);
62 }
63