DPF

DISTRHO Plugin Framework
Log | Files | Refs | Submodules | README | LICENSE

pugl.hpp (4212B)


      1 /*
      2  * DISTRHO Plugin Framework (DPF)
      3  * Copyright (C) 2012-2023 Filipe Coelho <falktx@falktx.com>
      4  *
      5  * Permission to use, copy, modify, and/or distribute this software for any purpose with
      6  * or without fee is hereby granted, provided that the above copyright notice and this
      7  * permission notice appear in all copies.
      8  *
      9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
     10  * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
     11  * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
     12  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
     13  * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
     14  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     15  */
     16 
     17 #ifndef DGL_PUGL_HPP_INCLUDED
     18 #define DGL_PUGL_HPP_INCLUDED
     19 
     20 #include "../Base.hpp"
     21 
     22 // we will include all header files used in pugl.h in their C++ friendly form, then pugl stuff in custom namespace
     23 #include <cstddef>
     24 #ifdef DISTRHO_PROPER_CPP11_SUPPORT
     25 # include <cstdbool>
     26 # include <cstdint>
     27 #else
     28 # include <stdbool.h>
     29 # include <stdint.h>
     30 #endif
     31 
     32 // custom attributes
     33 #define PUGL_ATTRIBUTES_H
     34 #define PUGL_BEGIN_DECLS
     35 #define PUGL_END_DECLS
     36 #define PUGL_API
     37 #define PUGL_DISABLE_DEPRECATED
     38 
     39 // GCC function attributes
     40 #if defined(__GNUC__) && !defined(__clang__)
     41  #define PUGL_CONST_FUNC __attribute__((const))
     42  #define PUGL_MALLOC_FUNC __attribute__((malloc))
     43 #else
     44  #define PUGL_CONST_FUNC
     45  #define PUGL_MALLOC_FUNC
     46 #endif
     47 
     48 #define PUGL_CONST_API PUGL_CONST_FUNC
     49 #define PUGL_MALLOC_API PUGL_MALLOC_FUNC
     50 
     51 // we do our own OpenGL inclusion
     52 #define PUGL_NO_INCLUDE_GL_H
     53 #define PUGL_NO_INCLUDE_GLU_H
     54 
     55 #ifndef DISTRHO_OS_MAC
     56 START_NAMESPACE_DGL
     57 #endif
     58 
     59 #include "pugl/pugl.h"
     60 
     61 // --------------------------------------------------------------------------------------------------------------------
     62 
     63 // DGL specific, expose backend enter
     64 bool puglBackendEnter(PuglView* view);
     65 
     66 // DGL specific, expose backend leave
     67 bool puglBackendLeave(PuglView* view);
     68 
     69 // DGL specific, assigns backend that matches current DGL build
     70 void puglSetMatchingBackendForCurrentBuild(PuglView* view);
     71 
     72 // bring view window into the foreground, aka "raise" window
     73 void puglRaiseWindow(PuglView* view);
     74 
     75 // combined puglSetSizeHint using PUGL_MIN_SIZE, PUGL_MIN_ASPECT and PUGL_MAX_ASPECT
     76 PuglStatus puglSetGeometryConstraints(PuglView* view, uint width, uint height, bool aspect);
     77 
     78 // set view as resizable (or not) during runtime
     79 void puglSetResizable(PuglView* view, bool resizable);
     80 
     81 // set window size while also changing default
     82 PuglStatus puglSetSizeAndDefault(PuglView* view, uint width, uint height);
     83 
     84 // DGL specific, build-specific drawing prepare
     85 void puglOnDisplayPrepare(PuglView* view);
     86 
     87 // DGL specific, build-specific fallback resize
     88 void puglFallbackOnResize(PuglView* view, uint width, uint height);
     89 
     90 #if defined(DISTRHO_OS_HAIKU)
     91 
     92 // nothing here yet
     93 
     94 #elif defined(DISTRHO_OS_MAC)
     95 
     96 // macOS specific, add another view's window as child
     97 PuglStatus puglMacOSAddChildWindow(PuglView* view, PuglView* child);
     98 
     99 // macOS specific, remove another view's window as child
    100 PuglStatus puglMacOSRemoveChildWindow(PuglView* view, PuglView* child);
    101 
    102 // macOS specific, center view based on parent coordinates (if there is one)
    103 void puglMacOSShowCentered(PuglView* view);
    104 
    105 #elif defined(DISTRHO_OS_WASM)
    106 
    107 // nothing here yet
    108 
    109 #elif defined(DISTRHO_OS_WINDOWS)
    110 
    111 // win32 specific, call ShowWindow with SW_RESTORE
    112 void puglWin32RestoreWindow(PuglView* view);
    113 
    114 // win32 specific, center view based on parent coordinates (if there is one)
    115 void puglWin32ShowCentered(PuglView* view);
    116 
    117 #elif defined(HAVE_X11)
    118 
    119 #define DGL_USING_X11
    120 
    121 // X11 specific, update world without triggering exposure events
    122 PuglStatus puglX11UpdateWithoutExposures(PuglWorld* world);
    123 
    124 // X11 specific, set dialog window type and pid hints
    125 void puglX11SetWindowTypeAndPID(const PuglView* view, bool isStandalone);
    126 
    127 #endif
    128 
    129 // --------------------------------------------------------------------------------------------------------------------
    130 
    131 #ifndef DISTRHO_OS_MAC
    132 END_NAMESPACE_DGL
    133 #endif
    134 
    135 #endif // DGL_PUGL_HPP_INCLUDED