Skip to content

Commit

Permalink
Merge branch 'master' into working
Browse files Browse the repository at this point in the history
  • Loading branch information
Ross Boucher committed Sep 18, 2008
2 parents 8bae704 + 0ee572c commit d38eac1
Show file tree
Hide file tree
Showing 28 changed files with 1,179 additions and 258 deletions.
4 changes: 2 additions & 2 deletions AppKit/AppKit.steam
Expand Up @@ -34,12 +34,12 @@
<dict>
<key>Name</key>
<string>Debug</string>
<key>Flags</key>
<string>-DDEBUG</string>
<key>Settings</key>
<dict>
<key>PREPROCESS</key>
<true/>
<key>FLAGS</key>
<string>-DDEBUG</string>
</dict>
</dict>
<dict>
Expand Down
4 changes: 2 additions & 2 deletions AppKit/CPControl.j
Expand Up @@ -253,8 +253,8 @@ var CPControlBlackColor = [CPColor blackColor];

- (void)mouseUp:(CPEvent)anEvent
{
if (_sendActionOn & CPLeftMouseUpMask && CPRectContainsPoint([self bounds], [self convertPoint:[anEvent locationInWindow] fromView:nil]))
[self sendAction:_action to:_target];
if (_sendActionOn & CPLeftMouseUpMask && CPRectContainsPoint([self bounds], [self convertPoint:[anEvent locationInWindow] fromView:nil])){alert([_target description] + " : " + _action);
[self sendAction:_action to:_target];}

[super mouseUp:anEvent];
}
Expand Down
173 changes: 95 additions & 78 deletions AppKit/CPSplitView.j
Expand Up @@ -35,17 +35,19 @@ var CPSplitViewHorizontalImage = nil,

@implementation CPSplitView : CPView
{
id _delegate;
BOOL _isVertical;
BOOL _isPaneSplitter;
id _delegate;
BOOL _isVertical;
BOOL _isPaneSplitter;

int _currentDivider;
float _initialOffset;
int _currentDivider;
float _initialOffset;

CPString _originComponent;
CPString _sizeComponent;
CPString _originComponent;
CPString _sizeComponent;

CPArray _DOMDividerElements;
CPArray _DOMDividerElements;
CPString _dividerImagePath;
int _drawingDivider;
}

/*
Expand Down Expand Up @@ -92,6 +94,7 @@ var CPSplitViewHorizontalImage = nil,

_originComponent = [self isVertical] ? "x" : "y";
_sizeComponent = [self isVertical] ? "width" : "height";
_dividerImagePath = [self isVertical] ? [CPSplitViewVerticalImage filename] : [CPSplitViewHorizontalImage filename];

[self adjustSubviews];
}
Expand Down Expand Up @@ -162,33 +165,30 @@ var CPSplitViewHorizontalImage = nil,

- (void)drawRect:(CGRect)rect
{
#if PLATFORM(DOM)
var dividerPath = [self isVertical] ? [CPSplitViewVerticalImage filename] : [CPSplitViewHorizontalImage filename];

var count = [_subviews count];
for (var i = 0; i < count; i++)
for (var _drawingDivider = 0; _drawingDivider < count-1; _drawingDivider++)
{
if (!_DOMDividerElements[i])
{
_DOMDividerElements[i] = document.createElement("div");
_DOMDividerElements[i].style.cursor = "move";
_DOMDividerElements[i].style.position = "absolute";
_DOMDividerElements[i].style.backgroundRepeat = "repeat";
CPDOMDisplayServerAppendChild(_DOMElement, _DOMDividerElements[i]);
}

var frame = [self rectOfDividerAtIndex:i];
CPDOMDisplayServerSetStyleLeftTop(_DOMDividerElements[i], NULL, _CGRectGetMinX(frame), _CGRectGetMinY(frame));
CPDOMDisplayServerSetStyleSize(_DOMDividerElements[i], _CGRectGetWidth(frame), _CGRectGetHeight(frame));

_DOMDividerElements[i].style.backgroundImage = "url('"+dividerPath+"')";
[self drawDividerInRect:[self rectOfDividerAtIndex:_drawingDivider]];
}
#endif
}

- (void)drawDividerInRect:(CGRect)aRect
{
// TODO: figure out a way to "draw" dividers using DOM element
#if PLATFORM(DOM)
if (!_DOMDividerElements[_drawingDivider])
{
_DOMDividerElements[_drawingDivider] = document.createElement("div");
_DOMDividerElements[_drawingDivider].style.cursor = "move";
_DOMDividerElements[_drawingDivider].style.position = "absolute";
_DOMDividerElements[_drawingDivider].style.backgroundRepeat = "repeat";
CPDOMDisplayServerAppendChild(_DOMElement, _DOMDividerElements[_drawingDivider]);
}

CPDOMDisplayServerSetStyleLeftTop(_DOMDividerElements[_drawingDivider], NULL, _CGRectGetMinX(aRect), _CGRectGetMinY(aRect));
CPDOMDisplayServerSetStyleSize(_DOMDividerElements[_drawingDivider], _CGRectGetWidth(aRect), _CGRectGetHeight(aRect));

_DOMDividerElements[_drawingDivider].style.backgroundImage = "url('"+_dividerImagePath+"')";
#endif
}

- (BOOL)cursorAtPoint:(CPPoint)aPoint hitDividerAtIndex:(int)anIndex
Expand All @@ -207,72 +207,89 @@ var CPSplitViewHorizontalImage = nil,
return CGRectContainsPoint(effectiveRect, aPoint) || (additionalRect && CGRectContainsPoint(additionalRect, aPoint));
}

- (void)mouseDown:(CPEvent)theEvent

/*
Tracks the divider.
@param anEvent the input event
*/
- (void)trackDivider:(CPEvent)anEvent
{
var location = [theEvent locationInWindow],
point = [self convertPoint:location fromView:nil];
var type = [anEvent type];

for (var i = 0; i < [_subviews count] - 1; i++)
if (type == CPLeftMouseUp)
{
var frame = [_subviews[i] frame],
startPosition = frame.origin[_originComponent] + frame.size[_sizeComponent];
if (_currentDivider != CPNotFound)
{
_currentDivider = CPNotFound;
[self _postNotificationDidResize];
}

if ([self cursorAtPoint:point hitDividerAtIndex:i])
return;
}

if (type == CPLeftMouseDown)
{
var location = [anEvent locationInWindow],
point = [self convertPoint:location fromView:nil];

_currentDivider = CPNotFound;
for (var i = 0; i < [_subviews count] - 1; i++)
{
if ([theEvent clickCount] == 2 &&
[_delegate respondsToSelector:@selector(splitView:canCollapseSubview:)] &&
[_delegate respondsToSelector:@selector(splitView:shouldCollapseSubview:forDoubleClickOnDividerAtIndex:)])
{
var minPosition = [self minPossiblePositionOfDividerAtIndex:i],
maxPosition = [self maxPossiblePositionOfDividerAtIndex:i];

if ([_delegate splitView:self canCollapseSubview:_subviews[i]] && [_delegate splitView:self shouldCollapseSubview:_subviews[i] forDoubleClickOnDividerAtIndex:i])
{
if ([self isSubviewCollapsed:_subviews[i]])
[self setPosition:(minPosition + (maxPosition - minPosition) / 2) ofDividerAtIndex:i];
else
[self setPosition:minPosition ofDividerAtIndex:i];
var frame = [_subviews[i] frame],
startPosition = frame.origin[_originComponent] + frame.size[_sizeComponent];

if ([self cursorAtPoint:point hitDividerAtIndex:i])
{
if ([anEvent clickCount] == 2 &&
[_delegate respondsToSelector:@selector(splitView:canCollapseSubview:)] &&
[_delegate respondsToSelector:@selector(splitView:shouldCollapseSubview:forDoubleClickOnDividerAtIndex:)])
{
var minPosition = [self minPossiblePositionOfDividerAtIndex:i],
maxPosition = [self maxPossiblePositionOfDividerAtIndex:i];

if ([_delegate splitView:self canCollapseSubview:_subviews[i]] && [_delegate splitView:self shouldCollapseSubview:_subviews[i] forDoubleClickOnDividerAtIndex:i])
{
if ([self isSubviewCollapsed:_subviews[i]])
[self setPosition:(minPosition + (maxPosition - minPosition) / 2) ofDividerAtIndex:i];
else
[self setPosition:minPosition ofDividerAtIndex:i];
}
else if ([_delegate splitView:self canCollapseSubview:_subviews[i+1]] && [_delegate splitView:self shouldCollapseSubview:_subviews[i+1] forDoubleClickOnDividerAtIndex:i])
{
if ([self isSubviewCollapsed:_subviews[i+1]])
[self setPosition:(minPosition + (maxPosition - minPosition) / 2) ofDividerAtIndex:i];
else
[self setPosition:maxPosition ofDividerAtIndex:i];
}
}
else if ([_delegate splitView:self canCollapseSubview:_subviews[i+1]] && [_delegate splitView:self shouldCollapseSubview:_subviews[i+1] forDoubleClickOnDividerAtIndex:i])
else
{
if ([self isSubviewCollapsed:_subviews[i+1]])
[self setPosition:(minPosition + (maxPosition - minPosition) / 2) ofDividerAtIndex:i];
else
[self setPosition:maxPosition ofDividerAtIndex:i];
}
}
else
{
_currentDivider = i;
_initialOffset = startPosition - point[_originComponent];
_currentDivider = i;
_initialOffset = startPosition - point[_originComponent];

[self _postNotificationWillResize];
[self _postNotificationWillResize];
}
}

return;
}
}
_currentDivider = CPNotFound;
}

- (void)mouseDragged:(CPEvent)theEvent
{
if (_currentDivider != CPNotFound)

else if (type == CPLeftMouseDragged)
{
var location = [theEvent locationInWindow],
point = [self convertPoint:location fromView:nil];

[self setPosition:(point[_originComponent] + _initialOffset) ofDividerAtIndex:_currentDivider];
if (_currentDivider != CPNotFound)
{
var location = [anEvent locationInWindow],
point = [self convertPoint:location fromView:nil];

[self setPosition:(point[_originComponent] + _initialOffset) ofDividerAtIndex:_currentDivider];
}
}

[CPApp setTarget:self selector:@selector(trackDivider:) forNextEventMatchingMask:CPLeftMouseDraggedMask | CPLeftMouseUpMask untilDate:nil inMode:nil dequeue:YES];
}

- (void)mouseUp:(CPEvent)theEvent
- (void)mouseDown:(CPEvent)anEvent
{
if (_currentDivider != CPNotFound)
{
_currentDivider = CPNotFound;
[self _postNotificationDidResize];
}
[self trackDivider:anEvent];
}

- (float)maxPossiblePositionOfDividerAtIndex:(int)dividerIndex
Expand Down
8 changes: 5 additions & 3 deletions AppKit/CPView.j
Expand Up @@ -1684,13 +1684,14 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
_DOMElement = DOMElementPrototype.cloneNode(false);
#endif

// Also decode these "early".
_frame = [aCoder decodeRectForKey:CPViewFrameKey];
_bounds = [aCoder decodeRectForKey:CPViewBoundsKey];

self = [super initWithCoder:aCoder];

if (self)
{
_frame = [aCoder decodeRectForKey:CPViewFrameKey];
_bounds = [aCoder decodeRectForKey:CPViewBoundsKey];

_window = [aCoder decodeObjectForKey:CPViewWindowKey];
_subviews = [aCoder decodeObjectForKey:CPViewSubviewsKey];
_superview = [aCoder decodeObjectForKey:CPViewSuperviewKey];
Expand All @@ -1716,6 +1717,7 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
for (; index < count; ++index)
{
CPDOMDisplayServerAppendChild(_DOMElement, _subviews[index]._DOMElement);
//_subviews[index]._superview = self;
}
#endif
_displayHash = [self hash];
Expand Down
13 changes: 10 additions & 3 deletions AppKit/CPWindow.j
Expand Up @@ -269,7 +269,9 @@ var CPWindowSaveImage = nil,
CPURL _representedURL;

// Bridge Support
#if PLATFORM(DOM)
DOMElement _DOMElement;
#endif
CPDOMWindowBridge _bridge;
unsigned _autoresizingMask;

Expand Down Expand Up @@ -364,7 +366,8 @@ CPTexturedBackgroundWindowMask
[self setContentView:[[CPView alloc] initWithFrame:CGRectMakeZero()]];

_firstResponder = self;


#if PLATFORM(DOM)
_DOMElement = document.createElement("div");

_DOMElement.style.position = "absolute";
Expand All @@ -375,7 +378,8 @@ CPTexturedBackgroundWindowMask
CPDOMDisplayServerSetStyleSize(_DOMElement, 1, 1);

CPDOMDisplayServerAppendChild(_DOMElement, _windowView._DOMElement);

#endif

[self setBridge:aBridge];

[self setNextResponder:CPApp];
Expand Down Expand Up @@ -854,12 +858,15 @@ CPTexturedBackgroundWindowMask
[_shadowView setBackgroundColor:_CPWindowShadowColor];
[_shadowView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];

#if PLATFORM(DOM)
CPDOMDisplayServerInsertBefore(_DOMElement, _shadowView._DOMElement, _windowView._DOMElement);
#endif
}
else
{
#if PLATFORM(DOM)
CPDOMDisplayServerRemoveChild(_DOMElement, _shadowView._DOMElement);

#endif
_shadowView = nil;
}
}
Expand Down
17 changes: 4 additions & 13 deletions AppKit/Cib/CPCib.j
Expand Up @@ -25,8 +25,9 @@ import <Foundation/CPURLConnection.j>
import <Foundation/CPURLRequest.j>

import "CPCustomView.j"
import "_CPCibCustomObject.j"
import "_CPCibObjectData.j"

import "_CPCibWindowTemplate.j"

CPCibOwner = @"CPCibOwner",
CPCibTopLevelObjects = @"CPCibTopLevelObjects";
Expand Down Expand Up @@ -56,20 +57,10 @@ var CPCibObjectDataKey = @"CPCibObjectDataKey";
if (!objectData || ![objectData isKindOfClass:[_CPCibObjectData class]])
return NO;

[objectData establishConnectionsWithExternalNameTable:anExternalNameTable];

var owner = [anExternalNameTable objectForKey:CPCibOwner],
topLevelObjects = [anExternalNameTable objectForKey:CPCibTopLevelObjects];

var objects = unarchiver._objects,
count = [objects count];

// The order in which objects receive the awakeFromCib message is not guaranteed.
while (count--)
{
var object = objects[count];

if ([object isMemberOfClass:[CPView class]])
return object;
}
/*
// [objectData establishConnectionsWithOwner:owner topLevelObjects:topLevelObjects];
// [objectData cibInstantiateWithOwner:owner topLevelObjects:topLevelObjects];
Expand Down

0 comments on commit d38eac1

Please sign in to comment.