My favorites | Sign in
Project Home Downloads Issues
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions

Issue 43 attachment: feature_largeborder_patch.diff (7.8 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
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
Index: pymt/ui/widgets/innerwindow.py
===================================================================
--- pymt/ui/widgets/innerwindow.py (revision 650)
+++ pymt/ui/widgets/innerwindow.py (working copy)
@@ -4,7 +4,7 @@
import os
import pymt
from pyglet.gl import *
-from ...graphx import gx_matrix, drawRectangle, set_color
+from ...graphx import gx_matrix, drawRectangle, set_color, gx_blending
from ...graphx import drawRoundedRectangle, drawTexturedRectangle
from ...vector import matrix_inv_mult
from rectangle import MTRectangularWidget
@@ -19,8 +19,12 @@
def __init__(self, **kargs):
super(MTInnerWindow, self).__init__(**kargs)

- self.color=(1,1,1,0.5)
- self.border = 20
+ self.color=(1,1,1,0.2)
+ self.border = 40
+
+ self.innerbordercolor=(1,1,1,0.5)
+ self.innerborder = 10
+
self.__w = self.__h = 0

self.container = MTRectangularWidget(pos=(0,0),size=self.size)
@@ -40,8 +44,9 @@
button_close.push_handlers(on_release=self.close)
self.controls.add_widget(button_close)

- self.controls.pos = self.width/2, -button_fullscreen.height*1.7
+ self.controls.pos = self.width/2 - self.controls.children[0].width*len(self.controls.children)/2, -self.controls.children[0].height-3

+
def fullscreen(self,touchID=None, x=0, y=0):
root_win = self.parent.get_parent_window()
root_win.children = []
@@ -65,10 +70,10 @@
self.__w, self.__h = w, h
for button in self.controls.children:
button.scale = 0.5/self.get_scale_factor()
- self.controls.pos = self.width/2 - self.controls.children[0].width*3/2, -self.controls.children[0].height*1.7
- for child in self.container.children:
- child.on_resize(w,h)
+ self.controls.pos = self.width/2 - self.controls.children[0].width*len(self.controls.children)/2, -self.controls.children[0].height-3

+ self.container.size = (w, h)
+
def on_touch_down(self, touches, touchID, x,y):
lx,ly = super(MTInnerWindow, self).to_local(x,y)
if self.controls.dispatch_event('on_touch_down', touches, touchID, lx, ly):
@@ -94,8 +99,8 @@
def collide_point(self, x,y):
scaled_border = int(self.border * (1.0/self.get_scale_factor()))
local_coords = super(MTInnerWindow,self).to_local(x,y)
- left, right = -scaled_border, self.width+scaled_border*2
- bottom,top = -scaled_border,self.height+scaled_border*2
+ left, right = -scaled_border, self.width+scaled_border
+ bottom,top = -scaled_border,self.height+scaled_border
if local_coords[0] > left and local_coords[0] < right \
and local_coords[1] > bottom and local_coords[1] < top:
return True
@@ -103,11 +108,23 @@
return False

def draw(self):
- set_color(*self.color)
- scaled_border = int(self.border * (1.0/self.get_scale_factor()))
- drawRoundedRectangle((-scaled_border, -scaled_border), (self.width+scaled_border*2, self.height+scaled_border*2))
- drawRectangle(((self.width/2)-(scaled_border*2.5), -scaled_border), (scaled_border*5, -scaled_border*1.2))
+ with gx_blending:
+ # draw the border
+ set_color(*self.color)
+ bscaled_border = int(self.border * (1.0/self.get_scale_factor()))
+ drawRoundedRectangle((-bscaled_border, -bscaled_border), (self.width+bscaled_border*2, self.height+bscaled_border*2))

+ # draw the inner border
+ set_color(*self.innerbordercolor)
+ scaled_border = int(self.innerborder * (1.0/self.get_scale_factor()))
+ drawRoundedRectangle((-scaled_border, -scaled_border), (self.width+scaled_border*2, self.height+scaled_border*2))
+
+ scaled_border = int(self.innerborder * (1.0/self.get_scale_factor()))
+ buttons_width=(self.controls.children[0].width+10)*len(self.controls.children)
+ buttons_height=(self.controls.children[0].height)
+
+ drawRectangle(((self.width/2)-buttons_width/2, -scaled_border), (buttons_width, -buttons_height-(1.0/self.get_scale_factor())))
+
def on_draw(self):
with gx_matrix:
glMultMatrixf(self.transform_mat)
Index: pymt/ui/widgets/scatter.py
===================================================================
--- pymt/ui/widgets/scatter.py (revision 650)
+++ pymt/ui/widgets/scatter.py (working copy)
@@ -186,6 +186,7 @@
glMultMatrixf(self.transform_mat)
glGetFloatv(GL_MODELVIEW_MATRIX, self.transform_mat)

+
def rotate_zoom_move(self, touchID, x, y):
# some default values, in case we dont calculate them,
# they still need to be defined for applying the openGL transformations
@@ -219,10 +220,15 @@
new_line = p1_now - p2_now
rotation = -1.0 * old_line.angle(new_line)

+ # use this to give feedback the status of the window
+ self.innerbordercolor=(0.7, 0.0,0.0, 0.5)
else:
# just comnpute a translation component if we only have one point
trans = p1_now - p1_start

+ # use this to give feedback the status of the window
+ self.innerbordercolor=(0.0, 0.7,0.0, 0.5)
+
# apply to our transformation matrix
self.apply_angle_scale_trans(rotation, scale, trans, intersect)

@@ -231,6 +237,7 @@

def _get_center(self):
return self.to_parent(self.width / 2, self.height / 2)
+
def _set_center(self, center):
center = self.to_local(*center)
if self._x == center[0] and self._y == center[1]:
@@ -244,6 +251,7 @@
def _get_x(self):
return self.center[0]
x = property(_get_x)
+
def _get_y(self):
return self.center[1]
y = property(_get_y)
@@ -255,7 +263,7 @@
return dist_trans

def on_touch_down(self, touches, touchID, x,y):
- # if the touch isnt on teh widget we do nothing
+ # if the touch isnt on the widget we do nothing
if not self.collide_point(x,y):
return False

@@ -264,14 +272,20 @@
if super(MTScatterWidget, self).on_touch_down(touches, touchID, lx, ly):
return True

- # if teh children didnt handle it, we bring to front & keep track of touches for rotate/scale/zoom action
+ # if the children didnt handle it, we bring to front & keep track of touches for rotate/scale/zoom action
self.bring_to_front()
self.touches[touchID] = Vector(x,y)
+
+ if len(self.touches) == 1:
+ self.innerbordercolor=(0.0,07.0,0.0,0.5)
+ else:
+ self.innerbordercolor=(0.7,0.0,0.0,0.5)
+
return True

def on_touch_move(self, touches, touchID, x, y):

- # if the touch isnt on teh widget we do nothing
+ # if the touch isnt on the widget we do nothing
if not (self.collide_point(x, y) or touchID in self.touches):
return False

@@ -280,6 +294,7 @@
if MTWidget.on_touch_move(self, touches, touchID, lx, ly):
return True

+
#rotate/scale/translate
if touchID in self.touches:
self.rotate_zoom_move(touchID, x, y)
@@ -287,6 +302,7 @@
self.dispatch_event('on_move', self.x, self.y)
return True

+
#stop porpagation if its within our bounds
if self.collide_point(x,y):
return True
@@ -300,6 +316,14 @@
if self.touches.has_key(touchID):
del self.touches[touchID]

+ if len(self.touches) == 0:
+ self.innerbordercolor=(1.0,1.0,1.0,0.5)
+ elif len(self.touches) == 1:
+ self.innerbordercolor=(0.0,0.7,0.0,0.5)
+ else:
+ self.innerbordercolor=(0.7,0.0,0.0,0.5)
+
+
#stop porpagating if its within our bounds
if self.collide_point(x,y):
return True
Powered by Google Project Hosting