Commit 37cdd323 authored by Duane Johnson's avatar Duane Johnson

Added 4 orders of magnitude to Z Buttons; Refactored some of XY Buttons

parent a6f3ec75
images/arrow_keys.png

1.14 KB | W: | H:

images/arrow_keys.png

1.03 KB | W: | H:

images/arrow_keys.png
images/arrow_keys.png
images/arrow_keys.png
images/arrow_keys.png
  • 2-up
  • Swipe
  • Onion skin
images/control_xy.png

56.5 KB | W: | H:

images/control_xy.png

58.5 KB | W: | H:

images/control_xy.png
images/control_xy.png
images/control_xy.png
images/control_xy.png
  • 2-up
  • Swipe
  • Onion skin
images/control_z.png

10.6 KB | W: | H:

images/control_z.png

10.7 KB | W: | H:

images/control_z.png
images/control_z.png
images/control_z.png
images/control_z.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -11,36 +11,13 @@ def sign(n): ...@@ -11,36 +11,13 @@ def sign(n):
class XYButtons(BufferedCanvas): class XYButtons(BufferedCanvas):
keypad_positions = { keypad_positions = {
0: (102, 109), 0: (126, 126),
1: (78, 86), 1: (100, 100),
2: (49, 58) 2: (78, 78),
3: (60, 60)
} }
concentric_circle_radii = [15, 55, 86, 117, 142] concentric_circle_radii = [15, 55, 86, 117, 142]
center = (166, 164) center = (166, 164)
distance = [
# Order of Magnitude 0 (i.e. 0.1, 1, 10)
[
# Quadrant 0 (Right)
[(0.1, 0), (1, 0), (10, 0)],
# Quadrant 1 (Up)
[(0, 0.1), (0, 1), (0, 10)],
# Quadrant 2 (Left)
[(-0.1, 0), (-1, 0), (-10, 0)],
# Quadrant 3 (Down)
[(0, -0.1), (0, -1), (0, -10)]
],
# Order of Magnitude 1 (i.e. 1, 10, 100)
[
# Quadrant 0 (Right)
[(1, 0), (10, 0), (100, 0)],
# Quadrant 1 (Up)
[(0, 1), (0, 10), (0, 100)],
# Quadrant 2 (Left)
[(-1, 0), (-10, 0), (-100, 0)],
# Quadrant 3 (Down)
[(0, -1), (0, -10), (0, -100)]
]
]
def __init__(self, parent, moveCallback=None, homeCallback=None, ID=-1): def __init__(self, parent, moveCallback=None, homeCallback=None, ID=-1):
self.bg_bmp = wx.Image(imagefile("control_xy.png"),wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.bg_bmp = wx.Image(imagefile("control_xy.png"),wx.BITMAP_TYPE_PNG).ConvertToBitmap()
...@@ -67,29 +44,38 @@ class XYButtons(BufferedCanvas): ...@@ -67,29 +44,38 @@ class XYButtons(BufferedCanvas):
if evt.GetKeyCode() == wx.WXK_TAB: if evt.GetKeyCode() == wx.WXK_TAB:
self.setKeypadIndex(self.rotateKeypadIndex()) self.setKeypadIndex(self.rotateKeypadIndex())
elif evt.GetKeyCode() == wx.WXK_UP: elif evt.GetKeyCode() == wx.WXK_UP:
if self.moveCallback: self.quadrant = 1
x, y = XYButtons.distance[self.orderOfMagnitudeIdx][1][self.keypad_idx]
self.moveCallback(x, y)
elif evt.GetKeyCode() == wx.WXK_DOWN: elif evt.GetKeyCode() == wx.WXK_DOWN:
if self.moveCallback: self.quadrant = 3
x, y = XYButtons.distance[self.orderOfMagnitudeIdx][3][self.keypad_idx]
self.moveCallback(x, y)
elif evt.GetKeyCode() == wx.WXK_LEFT: elif evt.GetKeyCode() == wx.WXK_LEFT:
if self.moveCallback: self.quadrant = 2
x, y = XYButtons.distance[self.orderOfMagnitudeIdx][2][self.keypad_idx]
self.moveCallback(x, y)
elif evt.GetKeyCode() == wx.WXK_RIGHT: elif evt.GetKeyCode() == wx.WXK_RIGHT:
if self.moveCallback: self.quadrant = 0
x, y = XYButtons.distance[self.orderOfMagnitudeIdx][0][self.keypad_idx]
self.moveCallback(x, y)
else: else:
evt.Skip() evt.Skip()
return
if self.moveCallback:
self.concentric = self.keypad_idx
x, y = self.getMovement()
self.moveCallback(x, y)
def rotateKeypadIndex(self): def rotateKeypadIndex(self):
idx = self.keypad_idx + 1 idx = self.keypad_idx + 1
if idx > 2: idx = 0 if idx > 2: idx = 0
return idx return idx
def setKeypadIndex(self, idx):
self.keypad_idx = idx
self.update()
# self.keypad_bmp.Move(XYButtons.keypad_positions[self.keypad_idx])
def getMovement(self):
xdir = [1, 0, -1, 0][self.quadrant]
ydir = [0, 1, 0, -1][self.quadrant]
magnitude = math.pow(10, self.concentric-1)
return (magnitude * xdir, magnitude * ydir)
def lookupConcentric(self, radius): def lookupConcentric(self, radius):
idx = -1 idx = -1
for r in XYButtons.concentric_circle_radii: for r in XYButtons.concentric_circle_radii:
...@@ -98,11 +84,6 @@ class XYButtons(BufferedCanvas): ...@@ -98,11 +84,6 @@ class XYButtons(BufferedCanvas):
idx += 1 idx += 1
return None return None
def setKeypadIndex(self, idx):
self.keypad_idx = idx
self.update()
# self.keypad_bmp.Move(XYButtons.keypad_positions[self.keypad_idx])
def getQuadrantConcentricFromPosition(self, pos): def getQuadrantConcentricFromPosition(self, pos):
rel_x = pos[0] - XYButtons.center[0] rel_x = pos[0] - XYButtons.center[0]
rel_y = pos[1] - XYButtons.center[1] rel_y = pos[1] - XYButtons.center[1]
...@@ -133,9 +114,7 @@ class XYButtons(BufferedCanvas): ...@@ -133,9 +114,7 @@ class XYButtons(BufferedCanvas):
idx = self.mouseOverKeypad(mpos) idx = self.mouseOverKeypad(mpos)
self.quadrant = None self.quadrant = None
self.concentric = None self.concentric = None
if idx != None: if idx == None:
self.concentric = -1
else:
center = wx.Point(XYButtons.center[0], XYButtons.center[1]) center = wx.Point(XYButtons.center[0], XYButtons.center[1])
riseDist = self.distanceToLine(mpos, center.x-1, center.y-1, center.x+1, center.y+1) riseDist = self.distanceToLine(mpos, center.x-1, center.y-1, center.x+1, center.y+1)
fallDist = self.distanceToLine(mpos, center.x-1, center.y+1, center.x+1, center.y-1) fallDist = self.distanceToLine(mpos, center.x-1, center.y+1, center.x+1, center.y-1)
...@@ -150,13 +129,9 @@ class XYButtons(BufferedCanvas): ...@@ -150,13 +129,9 @@ class XYButtons(BufferedCanvas):
idx = self.mouseOverKeypad(mpos) idx = self.mouseOverKeypad(mpos)
if idx == None: if idx == None:
quadrant, concentric = self.getQuadrantConcentricFromPosition(mpos) self.quadrant, self.concentric = self.getQuadrantConcentricFromPosition(mpos)
# print 'click:', mpos, quadrant, concentric if self.quadrant != None and self.concentric != None:
if concentric == -1: x, y = self.getMovement()
if self.homeCallback:
self.homeCallback()
elif quadrant != None and concentric != None:
x, y = XYButtons.distance[self.orderOfMagnitudeIdx][quadrant][concentric]
if self.moveCallback: if self.moveCallback:
self.moveCallback(x, y) self.moveCallback(x, y)
else: else:
...@@ -230,10 +205,7 @@ class XYButtons(BufferedCanvas): ...@@ -230,10 +205,7 @@ class XYButtons(BufferedCanvas):
dc.DrawBitmap(self.bg_bmp, 0, 0) dc.DrawBitmap(self.bg_bmp, 0, 0)
if self.concentric == -1: if self.quadrant != None and self.concentric != None:
inner_ring_radius = XYButtons.concentric_circle_radii[0]
dc.DrawCircle(XYButtons.center[0], XYButtons.center[1], inner_ring_radius+2)
elif self.quadrant != None and self.concentric != None:
self.highlightQuadrant(dc, self.quadrant, self.concentric) self.highlightQuadrant(dc, self.quadrant, self.concentric)
pos = XYButtons.keypad_positions[self.keypad_idx] pos = XYButtons.keypad_positions[self.keypad_idx]
......
...@@ -10,8 +10,8 @@ def sign(n): ...@@ -10,8 +10,8 @@ def sign(n):
else: return 0 else: return 0
class ZButtons(BufferedCanvas): class ZButtons(BufferedCanvas):
button_ydistances = [16, 46, 80, 118] button_ydistances = [8, 30, 56, 84, 118]
center = (36, 147) center = (32, 146)
def __init__(self, parent, moveCallback=None, homeCallback=None, ID=-1): def __init__(self, parent, moveCallback=None, homeCallback=None, ID=-1):
self.bg_bmp = wx.Image(imagefile("control_z.png"),wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.bg_bmp = wx.Image(imagefile("control_z.png"),wx.BITMAP_TYPE_PNG).ConvertToBitmap()
...@@ -23,7 +23,7 @@ class ZButtons(BufferedCanvas): ...@@ -23,7 +23,7 @@ class ZButtons(BufferedCanvas):
BufferedCanvas.__init__(self, parent, ID) BufferedCanvas.__init__(self, parent, ID)
self.SetSize(wx.Size(84, 295)) self.SetSize(wx.Size(87, 295))
# Set up mouse and keyboard event capture # Set up mouse and keyboard event capture
self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
...@@ -40,16 +40,13 @@ class ZButtons(BufferedCanvas): ...@@ -40,16 +40,13 @@ class ZButtons(BufferedCanvas):
return None return None
def highlight(self, dc, rng, dir): def highlight(self, dc, rng, dir):
assert(rng >= -1 and rng <= 2) assert(rng >= -1 and rng <= 3)
assert(dir >= -1 and dir <= 1) assert(dir >= -1 and dir <= 1)
fudge = 10 fudge = 11
x = 0 + fudge x = 0 + fudge
w = 72 - fudge*2 w = 72 - fudge*2
if rng == -1: if rng >= 0:
y = ZButtons.center[1] - ZButtons.button_ydistances[0]
h = ZButtons.button_ydistances[0] * 2
else:
k = 1 if dir > 0 else 0 k = 1 if dir > 0 else 0
y = ZButtons.center[1] - (dir * ZButtons.button_ydistances[rng+k]) y = ZButtons.center[1] - (dir * ZButtons.button_ydistances[rng+k])
h = ZButtons.button_ydistances[rng+1] - ZButtons.button_ydistances[rng] h = ZButtons.button_ydistances[rng+1] - ZButtons.button_ydistances[rng]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment