Started reintegrating uiWindow on macOS. I didn't think the implData variable naming through... Also made uiWindow a mere typedef to uiControl; I'll need to copy the handle logic from Windows to make this robust, or something to that effect...
This commit is contained in:
parent
a65bbfa057
commit
ba6f2865df
|
@ -3,9 +3,10 @@
|
||||||
|
|
||||||
#define defaultStyleMask (NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask)
|
#define defaultStyleMask (NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask)
|
||||||
|
|
||||||
struct uiWindow {
|
struct windowImplData {
|
||||||
uiDarwinControl c;
|
|
||||||
NSWindow *window;
|
NSWindow *window;
|
||||||
|
char *title;
|
||||||
|
#if 0
|
||||||
uiControl *child;
|
uiControl *child;
|
||||||
int margined;
|
int margined;
|
||||||
int (*onClosing)(uiWindow *, void *);
|
int (*onClosing)(uiWindow *, void *);
|
||||||
|
@ -16,8 +17,11 @@ struct uiWindow {
|
||||||
BOOL suppressSizeChanged;
|
BOOL suppressSizeChanged;
|
||||||
int fullscreen;
|
int fullscreen;
|
||||||
int borderless;
|
int borderless;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
|
||||||
@implementation uiprivNSWindow
|
@implementation uiprivNSWindow
|
||||||
|
|
||||||
- (void)uiprivDoMove:(NSEvent *)initialEvent
|
- (void)uiprivDoMove:(NSEvent *)initialEvent
|
||||||
|
@ -367,24 +371,25 @@ static void defaultOnPositionContentSizeChanged(uiWindow *w, void *data)
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
|
#endif
|
||||||
|
|
||||||
|
static bool windowInit(uiControl *c, void *implData, void *initData)
|
||||||
{
|
{
|
||||||
uiWindow *w;
|
windowImplData *w = (windowImplData *) implData;
|
||||||
|
|
||||||
uiprivFinalizeMenus();
|
w->window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, TODO, TODO)
|
||||||
|
|
||||||
uiDarwinNewControl(uiWindow, w);
|
|
||||||
|
|
||||||
w->window = [[uiprivNSWindow alloc] initWithContentRect:NSMakeRect(0, 0, (CGFloat) width, (CGFloat) height)
|
|
||||||
styleMask:defaultStyleMask
|
styleMask:defaultStyleMask
|
||||||
backing:NSBackingStoreBuffered
|
backing:NSBackingStoreBuffered
|
||||||
defer:YES];
|
defer:YES];
|
||||||
[w->window setTitle:uiprivToNSString(title)];
|
|
||||||
|
w->title = NULL;
|
||||||
|
[w->window setTitle:@""];
|
||||||
|
|
||||||
// do NOT release when closed
|
// do NOT release when closed
|
||||||
// we manually do this in uiWindowDestroy() above
|
// we manually do this in uiWindowDestroy() above
|
||||||
[w->window setReleasedWhenClosed:NO];
|
[w->window setReleasedWhenClosed:NO];
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (windowDelegate == nil) {
|
if (windowDelegate == nil) {
|
||||||
windowDelegate = [[windowDelegateClass new] autorelease];
|
windowDelegate = [[windowDelegateClass new] autorelease];
|
||||||
[uiprivDelegates addObject:windowDelegate];
|
[uiprivDelegates addObject:windowDelegate];
|
||||||
|
@ -392,10 +397,63 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
|
||||||
[windowDelegate registerWindow:w];
|
[windowDelegate registerWindow:w];
|
||||||
uiWindowOnClosing(w, defaultOnClosing, NULL);
|
uiWindowOnClosing(w, defaultOnClosing, NULL);
|
||||||
uiWindowOnContentSizeChanged(w, defaultOnPositionContentSizeChanged, NULL);
|
uiWindowOnContentSizeChanged(w, defaultOnPositionContentSizeChanged, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
return w;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void windowFree(uiControl *c, void *implData)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void windowParentChanging(uiControl *c, void *implData, uiControl *oldParent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void windowParentChanged(uiControl *c, void *implData, uiControl *newParent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static const uiControlVtable windowVtable = {
|
||||||
|
.Size = sizeof (uiControlVtable),
|
||||||
|
.Init = windowInit,
|
||||||
|
.Free = windowFree,
|
||||||
|
.ParentChanging = windowParentChanging,
|
||||||
|
.ParentChanged = windowParentChanged,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const uiControlOSVtable windowOSVtable = {
|
||||||
|
.Size = sizeof (uiControlOSVtable),
|
||||||
|
};
|
||||||
|
|
||||||
|
static uint32_t windowType = 0;
|
||||||
|
|
||||||
|
uint32_t uiWindowType(void)
|
||||||
|
{
|
||||||
|
if (windowType == 0)
|
||||||
|
windowType = uiRegisterControlType("uiWindow", &windowVtable, &windowOSVtable, sizeof (windowImplData));
|
||||||
|
return windowType;
|
||||||
|
}
|
||||||
|
|
||||||
|
uiWindow *uiNewWindow(void)
|
||||||
|
{
|
||||||
|
return (uiWindow *) uiNewControl(uiWindowType(), NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *uiWindowTitle(uiWindow *w)
|
||||||
|
{
|
||||||
|
if (w->title == NULL)
|
||||||
|
return "";
|
||||||
|
return w->title;
|
||||||
|
}
|
||||||
|
|
||||||
|
void uiWindowSetTitle(uiWindow *w, const char *title)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
|
||||||
// utility function for menus
|
// utility function for menus
|
||||||
uiWindow *uiprivWindowFromNSWindow(NSWindow *w)
|
uiWindow *uiprivWindowFromNSWindow(NSWindow *w)
|
||||||
{
|
{
|
||||||
|
@ -405,3 +463,5 @@ uiWindow *uiprivWindowFromNSWindow(NSWindow *w)
|
||||||
return NULL;
|
return NULL;
|
||||||
return [windowDelegate lookupWindow:w];
|
return [windowDelegate lookupWindow:w];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -11,12 +11,12 @@ TODO
|
||||||
### `uiWindow`
|
### `uiWindow`
|
||||||
|
|
||||||
```c
|
```c
|
||||||
typedef struct uiWindow uiWindow;
|
typedef uiControl uiWindow;
|
||||||
uiprivExtern uint32_t uiWindowType(void);
|
uiprivExtern uint32_t uiWindowType(void);
|
||||||
#define uiWindow(obj) ((uiWindow *) uiCheckControlType((obj), uiWindowType()))
|
#define uiWindow(obj) ((uiWindow *) uiCheckControlType((obj), uiWindowType()))
|
||||||
```
|
```
|
||||||
|
|
||||||
`uiWindow` is an opaque `uiControl` type that represents a window.
|
`uiWindow` is a `uiControl` that represents a window.
|
||||||
|
|
||||||
Windows are the highest level of a control hierarchy that is visibile on screen. All controls that are current visible are contained within a `uiWindow`, and it is the size and position of the window that ultimately decides their size and position (though a control's minimum size may contribute to this). Windows also have titles, which are used to identify the window to the user.
|
Windows are the highest level of a control hierarchy that is visibile on screen. All controls that are current visible are contained within a `uiWindow`, and it is the size and position of the window that ultimately decides their size and position (though a control's minimum size may contribute to this). Windows also have titles, which are used to identify the window to the user.
|
||||||
|
|
||||||
|
|
2
ui.h
2
ui.h
|
@ -66,7 +66,7 @@ uiprivExtern void uiControlFree(uiControl *c);
|
||||||
uiprivExtern void uiControlSetParent(uiControl *c, uiControl *parent);
|
uiprivExtern void uiControlSetParent(uiControl *c, uiControl *parent);
|
||||||
uiprivExtern void *uiControlImplData(uiControl *c);
|
uiprivExtern void *uiControlImplData(uiControl *c);
|
||||||
|
|
||||||
typedef struct uiWindow uiWindow;
|
typedef uiControl uiWindow;
|
||||||
uiprivExtern uint32_t uiWindowType(void);
|
uiprivExtern uint32_t uiWindowType(void);
|
||||||
#define uiWindow(obj) ((uiWindow *) uiCheckControlType((obj), uiWindowType()))
|
#define uiWindow(obj) ((uiWindow *) uiCheckControlType((obj), uiWindowType()))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue