Started adding borderless uiWindow support; implemented on Windows.
This commit is contained in:
parent
aafdb75a98
commit
377f46814a
|
@ -93,11 +93,19 @@ void setFullscreen(uiCheckbox *cb, void *data)
|
|||
updatesize(w);
|
||||
}
|
||||
|
||||
static void borderless(uiCheckbox *c, void *data)
|
||||
{
|
||||
uiWindow *w = uiWindow(data);
|
||||
|
||||
uiWindowSetBorderless(w, uiCheckboxChecked(c));
|
||||
}
|
||||
|
||||
uiBox *makePage15(uiWindow *w)
|
||||
{
|
||||
uiBox *page15;
|
||||
uiBox *hbox;
|
||||
uiButton *button;
|
||||
uiCheckbox *checkbox;
|
||||
|
||||
page15 = newVerticalBox();
|
||||
|
||||
|
@ -136,5 +144,9 @@ uiBox *makePage15(uiWindow *w)
|
|||
uiWindowOnContentSizeChanged(w, onSize, NULL);
|
||||
updatesize(w);
|
||||
|
||||
checkbox = uiNewCheckbox("Borderless");
|
||||
uiCheckboxOnToggled(checkbox, borderless, w);
|
||||
uiBoxAppend(page15, uiControl(checkbox), 0);
|
||||
|
||||
return page15;
|
||||
}
|
||||
|
|
2
ui.h
2
ui.h
|
@ -109,6 +109,8 @@ _UI_EXTERN int uiWindowFullscreen(uiWindow *w);
|
|||
_UI_EXTERN void uiWindowSetFullscreen(uiWindow *w, int fullscreen);
|
||||
_UI_EXTERN void uiWindowOnContentSizeChanged(uiWindow *w, void (*f)(uiWindow *, void *), void *data);
|
||||
_UI_EXTERN void uiWindowOnClosing(uiWindow *w, int (*f)(uiWindow *w, void *data), void *data);
|
||||
_UI_EXTERN int uiWindowBorderless(uiWindow *w);
|
||||
_UI_EXTERN void uiWindowSetBorderless(uiWindow *w, int borderless);
|
||||
_UI_EXTERN void uiWindowSetChild(uiWindow *w, uiControl *child);
|
||||
_UI_EXTERN int uiWindowMargined(uiWindow *w);
|
||||
_UI_EXTERN void uiWindowSetMargined(uiWindow *w, int margined);
|
||||
|
|
|
@ -22,6 +22,7 @@ struct uiWindow {
|
|||
BOOL changingSize;
|
||||
int fullscreen;
|
||||
WINDOWPLACEMENT fsPrevPlacement;
|
||||
int borderless;
|
||||
};
|
||||
|
||||
// from https://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
|
||||
|
@ -411,6 +412,7 @@ void uiWindowSetFullscreen(uiWindow *w, int fullscreen)
|
|||
SWP_FRAMECHANGED | SWP_NOOWNERZORDER) == 0)
|
||||
logLastError(L"error making window fullscreen");
|
||||
} else {
|
||||
if (!w->borderless) // keep borderless until that is turned off
|
||||
setStyle(w->hwnd, getStyle(w->hwnd) | WS_OVERLAPPEDWINDOW);
|
||||
if (SetWindowPlacement(w->hwnd, &(w->fsPrevPlacement)) == 0)
|
||||
logLastError(L"error leaving fullscreen");
|
||||
|
@ -434,6 +436,21 @@ void uiWindowOnClosing(uiWindow *w, int (*f)(uiWindow *, void *), void *data)
|
|||
w->onClosingData = data;
|
||||
}
|
||||
|
||||
int uiWindowBorderless(uiWindow *w)
|
||||
{
|
||||
return w->borderless;
|
||||
}
|
||||
|
||||
void uiWindowSetBorderless(uiWindow *w, int borderless)
|
||||
{
|
||||
w->borderless = borderless;
|
||||
if (w->borderless)
|
||||
setStyle(w->hwnd, getStyle(w->hwnd) & ~WS_OVERLAPPEDWINDOW);
|
||||
else
|
||||
if (!w->fullscreen) // keep borderless until leaving fullscreen
|
||||
setStyle(w->hwnd, getStyle(w->hwnd) | WS_OVERLAPPEDWINDOW);
|
||||
}
|
||||
|
||||
void uiWindowSetChild(uiWindow *w, uiControl *child)
|
||||
{
|
||||
if (w->child != NULL) {
|
||||
|
|
Loading…
Reference in New Issue