-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathPWView.m
More file actions
82 lines (67 loc) · 1.7 KB
/
PWView.m
File metadata and controls
82 lines (67 loc) · 1.7 KB
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
//
// ProWidgets
//
// 1.0.0
//
// Created by Alan Yip on 18 Jan 2014
// Copyright 2014 Alan Yip. All rights reserved.
//
#import "PWView.h"
#import "PWWindow.h"
#import "PWBackgroundView.h"
#import "PWTheme.h"
#import "PWController.h"
#import "PWWidgetController.h"
#import "PWWidget.h"
#import "PWMiniView.h"
#import "PWWidgetController.h"
@implementation PWView
- (instancetype)init {
if (self = [super init]) {
self.userInteractionEnabled = YES;
// create PWBackgroundView
if ([PWController shouldShowBackgroundView]) {
_backgroundView = [PWBackgroundView new];
_backgroundView.userInteractionEnabled = YES;
[self addSubview:_backgroundView];
}
}
return self;
}
- (void)layoutSubviews {
[super layoutSubviews];
_backgroundView.frame = CGRectInset(self.bounds, -PWSheetMotionEffectDistance, -PWSheetMotionEffectDistance);
}
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
UIView *result = [super hitTest:point withEvent:event];
// dragging
if ([PWWidgetController isDragging]) {
return self;
}
// resizing
if ([PWWidgetController isResizing]) {
return self;
}
// background view
if (result == _backgroundView) {
return result;
}
// mini view
if ([result isKindOfClass:[PWMiniView class]]) {
return result;
}
// container views
NSSet *widgetControllers = [PWWidgetController allControllers];
if ([widgetControllers count] > 0) {
for (PWWidgetController *widgetController in widgetControllers) {
if (widgetController.isPresented && !widgetController.isMinimized) {
PWContainerView *containerView = widgetController.containerView;
if ([result isDescendantOfView:containerView]) {
return result;
}
}
}
}
return nil;
}
@end