-
Notifications
You must be signed in to change notification settings - Fork 0
/
HASplitView.mm
655 lines (560 loc) · 22.2 KB
/
HASplitView.mm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
//
// HASplitView.m
// Photographer
//
// Created by Ben Uri on 7/6/12.
// Copyright (c) 2012 Ben Uri. All rights reserved.
//
#import "HASplitView.h"
#include <vector>
@interface HASplitView ()
{
NSMutableArray* _constraints;
NSView* _uncollapsedView; // The view that is currently uncollapsing (there must only one at a time)
BOOL _isRestoringUI;
NSMapTable* _subviewsLengths;
}
@property NSArray *viewStackConstraints;
@property NSArray *heightConstraints;
@end
/*
See this useful threads:
http://www.cocoabuilder.com/archive/cocoa/318091-nssplitview-question-how-to-implement-my-own-adjustviews-style-method.html
*/
@implementation HASplitView
- (NSMapTable*)subviewLengths
{
if (_subviewsLengths == nil)
{
@synchronized(self)
{
if (_subviewsLengths == nil)
{
_subviewsLengths = [NSMapTable mapTableWithKeyOptions:NSMapTableObjectPointerPersonality
valueOptions:NSMapTableObjectPointerPersonality];
}
}
}
return _subviewsLengths;
}
- (void)toggleSubviewShown:(NSView*)subview
{
[subview setHidden: !subview.isHidden];
}
- (void)collapseSubview:(NSView*)subview
{
if (subview.isHidden == YES) return;
[subview setHidden: YES];
}
- (void)uncollapseSubview:(NSView*)subview
{
if (subview.isHidden == NO) return;
[subview setHidden: NO];
}
@synthesize viewStackConstraints=_viewStackConstraints, heightConstraints=_heightConstraints;
+ (BOOL)requiresConstraintBasedLayout
{
return YES;
}
- (CGFloat)dividerThickness
{
return 1;
}
- (BOOL)isFlipped
{
return YES;
}
#pragma mark View Stack
// set up constraints to lay out subviews in a vertical stack with space between each consecutive pair. This doesn't specify the heights of views, just that they're stacked up head to tail.
- (void)updateViewStackConstraints {
if (!self.viewStackConstraints) {
NSMutableArray *stackConstraints = [NSMutableArray array];
NSDictionary *metrics = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithDouble:[self dividerThickness]], @"dividerThickness", nil];
NSMutableDictionary *viewsDict = [NSMutableDictionary dictionary];
// iterate over our subviews from top to bottom
char orientation_char = self.isVertical ? 'H' : 'V';
char ortho_orientation_char = self.isVertical ? 'V' : 'H';
NSView *previousView = nil;
for (NSView *currentView in [self subviews]) {
if (currentView.isHidden)
continue;
[viewsDict setObject:currentView forKey:@"currentView"];
if (!previousView) {
// tie topmost view to the top of the container
[stackConstraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:
[NSString stringWithFormat:@"%c:|[currentView]",orientation_char]
options:0
metrics:metrics
views:viewsDict]];
} else {
// tie current view to the next one higher up
[viewsDict setObject:previousView forKey:@"previousView"];
[stackConstraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:
[NSString stringWithFormat:@"%c:[previousView]-dividerThickness-[currentView]",orientation_char]
options:0
metrics:metrics
views:viewsDict]];
}
// each view should fill the splitview horizontally
[stackConstraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:
[NSString stringWithFormat:@"%c:|[currentView]|",ortho_orientation_char]
options:0
metrics:metrics
views:viewsDict]];
previousView = currentView;
}
// tie the bottom view to the bottom of the splitview
if ([[self subviews] count] > 0) [stackConstraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:
[NSString stringWithFormat:@"%c:[currentView]|",orientation_char]
options:0
metrics:metrics
views:viewsDict]];
[self setViewStackConstraints:stackConstraints];
}
}
- (NSArray *)viewStackConstraints
{
return _viewStackConstraints;
}
// passing nil marks us as needing to update the stack constraints
- (void)setViewStackConstraints:(NSArray *)stackConstraints {
if (_viewStackConstraints != stackConstraints) {
if (_viewStackConstraints)
[self removeConstraints:_viewStackConstraints];
_viewStackConstraints = stackConstraints;
if (_viewStackConstraints)
{
[self addConstraints:_viewStackConstraints];
}
else
{
[self setNeedsUpdateConstraints:YES];
}
}
}
// need to recompute the view stack when we gain or lose a subview
- (void)didAddSubview:(NSView *)subview {
[subview setTranslatesAutoresizingMaskIntoConstraints:NO];
[subview addObserver:self forKeyPath:@"hidden" options:0 context:nil];
[self setViewStackConstraints:nil];
[super didAddSubview:subview];
}
- (void)willRemoveSubview:(NSView *)subview {
[subview removeObserver:self forKeyPath:@"hidden"];
[self setViewStackConstraints:nil];
[self.subviewLengths removeObjectForKey:subview];
[super willRemoveSubview:subview];
}
#pragma mark View Heights
- (NSArray*)heightConstraints
{
return _heightConstraints;
}
- (void)setHeightConstraints:(NSArray *)heightConstraints
{
if (_heightConstraints != heightConstraints)
{
if (_heightConstraints)
[self removeConstraints:_heightConstraints];
_heightConstraints = heightConstraints;
if (_heightConstraints)
{
[self addConstraints:_heightConstraints];
}
else
{
[self setNeedsUpdateConstraints:YES];
}
}
}
int DistanceOfViewWithIndexFromDividerWithIndex(int viewIndex, int dividerIndex) {
return ABS(viewIndex - (dividerIndex + 0.5)) - 0.5;
}
/* make constraints specifying that each view wants its height to be the current percentage of the total space available
The priorities are not all equal, though. The views closest to the dividerIndex maintain height with the lowest priority, and priority increases as we move away from the divider.
Thus, the views closest to the divider are affected by divider dragging first.
-1 for dividerIndex means that no divider is being dragged and all the height constraints should have the same priority.
*/
- (NSArray *)constraintsForHeightsWithPrioritiesLowestAroundDivider:(int)dividerIndex
{
NSMutableArray *constraints = [NSMutableArray array];
NSLayoutAttribute lengthAttribute = self.isVertical ? NSLayoutAttributeWidth : NSLayoutAttributeHeight;
if (dividerIndex != -2)
{
// Fix the current length while dragging a divider
CGFloat currentLength = self.isVertical ? NSWidth(self.frame) : NSHeight(self.frame);
NSLayoutConstraint* totalLengthConstraint = [NSLayoutConstraint constraintWithItem:self attribute:lengthAttribute relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1 constant:currentLength];
[constraints addObject: totalLengthConstraint];
}
CGFloat uncollapsedViewLength = 0;
if (_uncollapsedView)
{
uncollapsedViewLength = [[self.subviewLengths objectForKey:_uncollapsedView] doubleValue];
}
CGFloat totalVisibleViewsLength = 0;
NSMutableArray* visibleSubviews = [NSMutableArray array];
NSInteger numberOfVisibleViews = 0;
{
// Count visible views
for (NSView* v in [self subviews])
{
if (v.isHidden) continue;
numberOfVisibleViews++;
[visibleSubviews addObject:v];
}
}
CGFloat spaceForAllDividers = [self dividerThickness] * (numberOfVisibleViews - 1);
// CGFloat boundsLength = self.isVertical ? NSWidth([self bounds]) : NSHeight([self bounds]);
// CGFloat spaceForAllViews = boundsLength - spaceForAllDividers;
CGFloat priorityIncrement = 1.0 / numberOfVisibleViews;
for (NSView* v in visibleSubviews)
{
CGFloat length = [[self.subviewLengths objectForKey:v] doubleValue];
if (length < 1)
{
NSSize fittingSize = [v fittingSize];
length = self.isVertical ? fittingSize.width : fittingSize.height;
[self.subviewLengths setObject:[NSNumber numberWithDouble:length] forKey:v];
}
// length = length >= 1 ? length : spaceForAllViews / numberOfVisibleViews;
if (v == _uncollapsedView)
uncollapsedViewLength = length;
else
totalVisibleViewsLength += length;
}
// uncollapsedViewLength = MIN(uncollapsedViewLength, spaceForAllViews / numberOfVisibleViews);
std::vector<CGFloat> percentsOfTotalLength([visibleSubviews count]);
CGFloat totalPercents = 0;
for (NSUInteger i = 0; i < [visibleSubviews count]; i++)
{
NSView *v = [visibleSubviews objectAtIndex:i];
CGFloat length = [[self.subviewLengths objectForKey:v] doubleValue];
if (v != _uncollapsedView && _uncollapsedView)
{
CGFloat spaceForUncollapsedViewLengthAndItsDivider = uncollapsedViewLength + (uncollapsedViewLength > 0 ? [self dividerThickness] : 0);
length -= spaceForUncollapsedViewLengthAndItsDivider / (numberOfVisibleViews-1);
}
CGFloat percentOfTotalLength = length / totalVisibleViewsLength;
// NSLog(@"percentOfTotalLength=%f", percentOfTotalLength);
totalPercents += percentOfTotalLength;
percentsOfTotalLength[i] = percentOfTotalLength;
}
// NSLog(@"totalPercents=%f", totalPercents);
if (totalPercents > 0)
{
for (NSUInteger i = 0; i < percentsOfTotalLength.size(); i++)
{
NSView *v = [visibleSubviews objectAtIndex:i];
CGFloat percentOfTotalLength = percentsOfTotalLength[i] / totalPercents;
// Constrain: v.height == (self.height - spaceForAllDividers) * percentOfTotalHeight
NSLayoutConstraint *lengthConstraint = [NSLayoutConstraint constraintWithItem:v
attribute:lengthAttribute
relatedBy:NSLayoutRelationEqual
toItem:self
attribute:lengthAttribute
multiplier:percentOfTotalLength
constant:-spaceForAllDividers * percentOfTotalLength];
if (dividerIndex == -2) {
[lengthConstraint setPriority:NSLayoutPriorityDefaultLow];
} else {
[lengthConstraint setPriority:NSLayoutPriorityDefaultLow + priorityIncrement*DistanceOfViewWithIndexFromDividerWithIndex(i, dividerIndex)];
}
[constraints addObject:lengthConstraint];
}
}
_uncollapsedView = nil;
return constraints;
}
- (void)updateHeightConstraints {
if (!self.heightConstraints) self.heightConstraints = [self constraintsForHeightsWithPrioritiesLowestAroundDivider:-2];
}
#pragma mark Update Layout Constraints Override
- (void)updateConstraints {
[super updateConstraints];
[self updateViewStackConstraints];
[self updateHeightConstraints];
}
#pragma mark Divider Dragging
- (void)layout
{
[super layout];
[self.window invalidateCursorRectsForView:self];
// Save visible subview lengths. We need this because hidden subviews may have
// a zero frame after layout.
// NSView* previousView = nil;
// NSLog(@"splitview.frame=%@", NSStringFromRect(self.frame));
if (MAX(NSHeight(self.frame), NSWidth(self.frame)) > 5000)
{
NSAssert(false, @"Internal Error in Auto Layout");
}
for (NSView* v in self.subviews)
{
if (!v.isHidden)
{
NSRect frame = v.frame;
CGFloat length = self.isVertical ? frame.size.width : frame.size.height;
[self.subviewLengths setObject:[NSNumber numberWithDouble:length] forKey:v];
// NSLog(@"\tv.frame=%@", NSStringFromRect(v.frame));
}
}
}
- (int)dividerIndexForPoint:(NSPoint)point
{
__block int dividerIndex = -1;
if (self.subviews.count == 0)
return dividerIndex;
CGFloat cursorRectThickness = MIN([self dividerThickness], 5);
CGFloat cursorRectOffset = MAX(0, (cursorRectThickness - [self dividerThickness])/2);
NSRect dividerRect = NSMakeRect(0, 0,
self.isVertical ? cursorRectThickness : NSWidth(self.bounds),
self.isVertical ? NSHeight(self.bounds) : cursorRectThickness);
NSView* previousView = nil;
int i = 0;
for (NSView* v in self.subviews)
{
if (v.isHidden)
continue;
// NSLog(@"v.frame=%@", NSStringFromRect(v.frame));
if (previousView != nil)
{
if (self.isVertical)
dividerRect.origin.x = NSMaxX(previousView.frame) - cursorRectOffset;
else
{
dividerRect.origin.y = self.isFlipped ? NSMaxY(previousView.frame) : NSMaxY(v.frame);
dividerRect.origin.y -= cursorRectOffset;
}
// NSLog(@"dividerRect=%@", NSStringFromRect(dividerRect));
if (NSPointInRect(point, dividerRect))
{
dividerIndex = i - 1;
break;
}
}
i++;
previousView = v;
}
return dividerIndex;
}
-(void)resetCursorRects
{
// NSLog(@"%s", __func__);
NSCursor * cursor = self.isVertical ? [NSCursor resizeLeftRightCursor] : [NSCursor resizeUpDownCursor];
if (!_draggingConstraint)
{
CGFloat cursorRectThickness = MIN([self dividerThickness], 5);
CGFloat cursorRectOffset = MAX(0, (cursorRectThickness - [self dividerThickness])/2);
NSRect dividerRect = NSMakeRect(0, 0,
self.isVertical ? cursorRectThickness : NSWidth(self.bounds),
self.isVertical ? NSHeight(self.bounds) : cursorRectThickness);
NSView* previousView = nil;
for (NSView* v in self.subviews)
{
if (v.isHidden)
continue;
// NSLog(@"v.frame=%@", NSStringFromRect(v.frame));
if (previousView != nil)
{
if (self.isVertical)
dividerRect.origin.x = NSMaxX(previousView.frame) - cursorRectOffset;
else
{
dividerRect.origin.y = self.isFlipped ? NSMaxY(previousView.frame) : NSMaxY(v.frame);
dividerRect.origin.y -= cursorRectOffset;
}
[self addCursorRect:dividerRect
cursor:cursor];
}
previousView = v;
}
}
}
- (BOOL)mouseDownCanMoveWindow
{
return NO;
}
-(void)mouseDown:(NSEvent *)theEvent
{
NSPoint locationInSelf = [self convertPoint:[theEvent locationInWindow] fromView:nil];
int dividerIndex = [self dividerIndexForPoint:locationInSelf];
// NSLog(@"locationInSelf = %@", NSStringFromPoint(locationInSelf));
if (dividerIndex != -1)
{
// First we lock the heights in place for the given dividerIndex
self.heightConstraints = [self constraintsForHeightsWithPrioritiesLowestAroundDivider:dividerIndex];
// Now we add a constraint that forces the bottom edge of the view above the divider to align with the mouse location
NSView *viewAboveDivider = [[self subviews] objectAtIndex:dividerIndex];
char orientation_char = self.isVertical ? 'H' : 'V';
_draggingConstraint = [[NSLayoutConstraint constraintsWithVisualFormat:[NSString stringWithFormat:
@"%c:[viewAboveDivider]-100-|", orientation_char]
options:0
metrics:nil
views:NSDictionaryOfVariableBindings(viewAboveDivider)] lastObject];
[_draggingConstraint setPriority:NSLayoutPriorityDragThatCannotResizeWindow];
_draggingConstraint.constant = self.isVertical ? (NSWidth([self bounds]) - NSMaxX(viewAboveDivider.frame)) : (self.isFlipped ? (NSHeight([self bounds]) - NSMaxY(viewAboveDivider.frame)) : NSMinY(viewAboveDivider.frame));
_draggingConstraintConstantAtMouseDown = _draggingConstraint.constant;
[self addConstraint:_draggingConstraint];
// NSLog(@"_draggingConstraint=%@", _draggingConstraint);
_mouseDownLocation = locationInSelf;
[[self window] disableCursorRects];
NSCursor * cursor = self.isVertical ? [NSCursor resizeLeftRightCursor] : [NSCursor resizeUpDownCursor];
[cursor push];
for (NSView* v in self.subviews)
{
[v viewWillStartLiveResize];
}
}
else
{
[super mouseDown:theEvent];
}
}
- (void)mouseDragged:(NSEvent *)theEvent
{
if (_draggingConstraint)
{
// update the dragging constraint for the new location
NSPoint locationInSelf = [self convertPoint:[theEvent locationInWindow] fromView:nil];
NSPoint delta = NSMakePoint(_mouseDownLocation.x - locationInSelf.x, _mouseDownLocation.y - locationInSelf.y);
[_draggingConstraint setConstant:self.isVertical ? _draggingConstraintConstantAtMouseDown + delta.x :
(_draggingConstraintConstantAtMouseDown + delta.y)];
// NSLog(@"_draggingConstraint=%@", _draggingConstraint);
[self setNeedsDisplay: YES];
}
else
{
[super mouseDragged:theEvent];
}
}
- (void)mouseUp:(NSEvent *)theEvent
{
if (_draggingConstraint) {
[self removeConstraint:_draggingConstraint];
_draggingConstraint = nil;
// We lock the current heights in place
self.heightConstraints = [self constraintsForHeightsWithPrioritiesLowestAroundDivider:-2];
[self setNeedsDisplay: YES];
[[NSCursor currentCursor] pop];
for (NSView* v in self.subviews)
{
[v viewDidEndLiveResize];
}
[[self window] enableCursorRects];
[[self window] resetCursorRects];
[self invalidateRestorableState];
}
else
{
[super mouseUp:theEvent];
}
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if ([keyPath isEqualToString:@"hidden"])
{
if ([self.subviews containsObject:object])
{
NSView* v = (NSView*)object;
if (!v.isHidden && !_isRestoringUI)
{
#if DEBUG
if (_uncollapsedView != nil)
NSLog(@"Internal error here %s.", __func__);
#endif
_uncollapsedView = v;
}
[self setHeightConstraints:nil];
[self setViewStackConstraints:nil];
[self setNeedsDisplay: YES];
[self invalidateRestorableState];
return;
}
else
{
[object removeObserver:self];
}
}
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
#pragma mark Drawing
- (void)disableUpdatedUntilFlush
{
[self.window disableScreenUpdatesUntilFlush];
}
- (void)drawRect:(NSRect)dirtyRect
{
[[NSColor redColor] set];
NSRectFill(dirtyRect);
}
- (void)adjustSubviews
{
[self disableUpdatedUntilFlush];
[self setNeedsUpdateConstraints:YES];
}
- (void)adjustSubviewsWithConstraints
{
[self adjustSubviews];
}
#pragma mark -
#pragma mark State Restoration
- (void)encodeRestorableStateWithCoder:(NSCoder *)coder
{
[super encodeRestorableStateWithCoder:coder];
NSMutableArray* lengths = [NSMutableArray arrayWithCapacity:self.subviews.count];
NSMutableArray* hiddens = [NSMutableArray arrayWithCapacity:self.subviews.count];
NSMutableArray* subviewsStates = [NSMutableArray arrayWithCapacity:self.subviews.count];
NSUInteger idx = 0;
for (NSView* v in self.subviews)
{
CGFloat length = [[self.subviewLengths objectForKey:v] doubleValue];
[lengths setObject: [NSNumber numberWithDouble:length] atIndexedSubscript:idx];
[hiddens setObject: [NSNumber numberWithBool:v.isHidden] atIndexedSubscript:idx];
// Recursively encode subviews' states:
{
NSMutableData* subviewState = [NSMutableData data];
NSKeyedArchiver* archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:subviewState];
[v encodeRestorableStateWithCoder:archiver];
[archiver finishEncoding];
[subviewsStates setObject:subviewState atIndexedSubscript:idx];
}
idx++;
}
[coder encodeObject:lengths forKey:@"lengths"];
[coder encodeObject:hiddens forKey:@"hiddens"];
[coder encodeObject:subviewsStates forKey:@"subviewsStates"];
}
- (void)restoreStateWithCoder:(NSCoder *)coder
{
NSLog(@"%s", __func__);
[super restoreStateWithCoder:coder];
NSArray* lengths = [coder decodeObjectForKey:@"lengths"];
NSArray* hiddens = [coder decodeObjectForKey:@"hiddens"];
NSArray* subviewsStates = [coder decodeObjectForKey:@"subviewsStates"];
if ([lengths count] != [hiddens count] ||
[lengths count] != [subviewsStates count] ||
[lengths count] != [self.subviews count])
{
return;
}
_isRestoringUI = YES;
NSUInteger idx = 0;
for (NSView* v in self.subviews)
{
CGFloat length = [[lengths objectAtIndex:idx] doubleValue];
CGFloat h = [[hiddens objectAtIndex:idx] doubleValue];
[self.subviewLengths setObject:[NSNumber numberWithDouble:length] forKey:v];
[v setHidden:h];
// Recursively decode subviews' states:
{
NSData* subviewState = [subviewsStates objectAtIndex:idx];
NSKeyedUnarchiver* unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:subviewState];
[v restoreStateWithCoder:unarchiver];
}
idx++;
}
[self setHeightConstraints:nil];
[self setViewStackConstraints:nil];
[self setNeedsDisplay: YES];
_isRestoringUI = NO;
}
@end