Francisco Tolmasky
unread,Jul 27, 2009, 3:25:55 PM7/27/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Cappuccino & Objective-J
I've just pushed the beginnings of "platform windows" support to the
master branch. Platform windows are "real" windows, in other words,
"browser windows" as opposed to CPWindows. Prior to this change,
Cappuccino could only run in one window, and if you wanted another
window you would have to do so through the traditional window.open API
and load an entire new Cappuccino app in it. This had a number of
problems:
1. For starters, it is slow to load a whole new instance of the app in
the new window.
2. The new window had its own "context", meaning it had its own
separate copy of globals like CPApp, etc. Essentially, you really were
running TWO separate Cappuccino apps, not one with 2 windows.
3. If you closed this window, you could not open it again, and would
have to load the whole app again.
This (partially now and better soon) no longer be the case with the
introduction of CPPlatformWindow. Normally, you will never deal with
them directly, but CPWindows now exist within a CPPlatformWindow,
which is accessible as so:
[myWindow platformWindow]; // This will be [CPPlatformWindow
primaryPlatformWindow] normally
But you can now create new platform windows as well:
var anotherPlatformWindow = [[CPPlatformWindow alloc]
initWithContentRect:CGRectMake(100.0, 100.0, 500.0, 500.0)];
[anotherPlatformWindow orderFront:self];
[myWindow setPlatformWindow:anotherPlatformWindow];
[myWindow orderFront:self]; // This will be in the new window now.
The important thing about platform windows is that their "code" still
runs in the first window. That means you can make views and objects in
the first window and treat the CPWindow just like any other CPWindow
that exists inside the browser:
var myView = [[CPView alloc] initWithFrame:CGRectMake(0.0, 0.0, 100.0,
100.0)];
[myView setBackgroundColor:[CPColor redColor]];
[myWindow addSubview:myView]; // view created in first window put in
second window.
Similarly, you can close platform windows and open them again without
needing to create a new DOMWindow object like in traditional
javascript:
[anotherPlatformWindow orderOut:self];
[anotherPlatformWindow orderFront:self];
vs.
window.close();
window // stale object, cant open it again.
There is still a fair deal of work left here, but it is now at the
point where it works as well as it did before. One important thing to
note is that the introduction of CPPlatformWindows deprecate the old
CPDOMWindowBridge class which expected there to only ever be one
window. This is the only place you may find conflicts in your code (if
you use something like [[CPDOMWindowBridge sharedWindowBridge]
contentBounds] or somesuch), but these methods have parallel
implementations in CPPlatformWindow.
Thanks,
Francisco