Skip to content
This repository was archived by the owner on Jun 11, 2024. It is now read-only.

Commit d66caa5

Browse files
committed
Add window boundary and valid orientation getters
1 parent c0ff184 commit d66caa5

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
![Python Version](https://img.shields.io/badge/Python-3.6-orange.svg) [![GitHub release](https://img.shields.io/github/release/sco1/dragpy.svg)](https://github.com/sco1/dragpy/releases)
1+
[![Python Version](https://img.shields.io/badge/Python-3.6-orange.svg)](https://www.python.org/downloads/release/python-360/) [![GitHub release](https://img.shields.io/github/release/sco1/dragpy.svg)](https://github.com/sco1/dragpy/releases)
22
# dragpy

dragpy/dragpy.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ def get_ydata(self, orig=True):
221221
"""
222222
return self.myobj.get_ydata(orig)
223223

224+
@staticmethod
225+
def get_validorientations():
226+
return ('vertical', 'horizontal')
224227

225228
class DragEllipse(_DragPatch):
226229
def __init__(self, ax, xy, width, height, angle=0.0, **kwargs):
@@ -297,6 +300,17 @@ def on_motion(self, event):
297300

298301
self.parentcanvas.draw()
299302

303+
def get_bounds(self):
304+
xy = self.myobj.get_xy()
305+
if self.orientation == 'vertical':
306+
return (xy[0], xy[0] + self.myobj.get_width())
307+
elif self.orientation == 'horizontal':
308+
return (xy[1], xy[1] + self.myobj.get_height())
309+
310+
@staticmethod
311+
def get_validorientations():
312+
return ('vertical', 'horizontal')
313+
300314

301315
class Window:
302316
def __init__(self, ax, primaryedge, windowstartsize, orientation='vertical', snapto=None,
@@ -306,6 +320,7 @@ def __init__(self, ax, primaryedge, windowstartsize, orientation='vertical', sna
306320
self.edges = []
307321
self.edges.append(DragLine2D(ax, primaryedge, orientation, snapto, color=edgecolor))
308322
self.edges.append(DragLine2D(ax, (primaryedge+windowstartsize), orientation, snapto, color=edgecolor))
323+
self.orientation = orientation
309324

310325
# Add spanning rectangle
311326
xy, width, height = self.spanpatchdims(*self.edges)
@@ -338,6 +353,17 @@ def spanpatchdims(edge1, edge2):
338353

339354
return xy, width, height
340355

356+
def get_bounds(self):
357+
xy = self.spanpatch.get_xy()
358+
if self.orientation == 'vertical':
359+
return (xy[0], xy[0] + self.spanpatch.get_width())
360+
elif self.orientation == 'horizontal':
361+
return (xy[1], xy[1] + self.spanpatch.get_height())
362+
363+
@staticmethod
364+
def get_validorientations():
365+
return ('vertical', 'horizontal')
366+
341367

342368
class DragArc(_DragPatch):
343369
def __init__(self, ax, xy, width, height, angle=0, theta1=0, theta2=360.00, **kwargs):

0 commit comments

Comments
 (0)