Skip to content

Commit

Permalink
More tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
kunitoki committed Dec 11, 2024
1 parent d9a95da commit 3368e25
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
15 changes: 13 additions & 2 deletions modules/yup_gui/component/yup_ComponentNative.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,20 @@ class Component;
class JUCE_API ComponentNative
{
struct decoratedWindowTag;
struct resizableWindowTag;
struct renderContinuousTag;
struct allowHighDensityDisplayTag;

public:
//==============================================================================
using Flags = FlagSet<uint32, decoratedWindowTag, renderContinuousTag, allowHighDensityDisplayTag>;
using Flags = FlagSet<uint32, decoratedWindowTag, resizableWindowTag, renderContinuousTag, allowHighDensityDisplayTag>;

static inline constexpr Flags noFlags = Flags();
static inline constexpr Flags decoratedWindow = Flags::declareValue<decoratedWindowTag>();
static inline constexpr Flags resizableWindow = Flags::declareValue<resizableWindowTag>();
static inline constexpr Flags renderContinuous = Flags::declareValue<renderContinuousTag>();
static inline constexpr Flags allowHighDensityDisplay = Flags::declareValue<allowHighDensityDisplayTag>();
static inline constexpr Flags defaultFlags = decoratedWindow | allowHighDensityDisplay;
static inline constexpr Flags defaultFlags = decoratedWindow | resizableWindow | allowHighDensityDisplay;

//==============================================================================
/** Configuration options for creating a native component. */
Expand All @@ -54,6 +56,15 @@ class JUCE_API ComponentNative
return *this;
}

Options& withResizableWindow (bool shouldAllowResizing) noexcept
{
if (shouldAllowResizing)
flags |= resizableWindow;
else
flags &= ~resizableWindow;
return *this;
}

Options& withRenderContinuous (bool shouldRenderContinuous) noexcept
{
if (shouldRenderContinuous)
Expand Down
18 changes: 14 additions & 4 deletions modules/yup_gui/native/yup_Windowing_sdl2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ class SDL2ComponentNative final

void* parentWindow = nullptr;
String windowTitle;
uint32 windowFlags = 0;

GraphicsContext::Api currentGraphicsApi;

Expand Down Expand Up @@ -562,9 +563,11 @@ SDL2ComponentNative::SDL2ComponentNative (Component& component,
{
SDL_AddEventWatch (eventDispatcher, this);

// Setup window hints
auto windowFlags = setContextWindowHints (currentGraphicsApi);
windowFlags |= SDL_WINDOW_RESIZABLE;
// Setup window hints and get flags
windowFlags = setContextWindowHints (currentGraphicsApi);

if (options.flags.test (resizableWindow))
windowFlags |= SDL_WINDOW_RESIZABLE;

if (component.isVisible())
windowFlags |= SDL_WINDOW_SHOWN;
Expand All @@ -577,8 +580,15 @@ SDL2ComponentNative::SDL2ComponentNative (Component& component,
if (! options.flags.test (decoratedWindow))
windowFlags |= SDL_WINDOW_BORDERLESS;

SDL_SetHint (SDL_HINT_ORIENTATIONS, "Portrait PortraitUpsideDown LandscapeLeft LandscapeRight");

// Create the window, renderer and parent it
window = SDL_CreateWindow (component.getTitle().toRawUTF8(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 1, 1, windowFlags);
window = SDL_CreateWindow (component.getTitle().toRawUTF8(),
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
1,
1,
windowFlags);
if (window == nullptr)
return; // TODO - raise something ?

Expand Down

0 comments on commit 3368e25

Please sign in to comment.