@@ -1047,23 +1047,26 @@ def moveObject(self, obj : wmwpy.classes.Object | None = None, amount : tuple[fl
1047
1047
if (obj == None ) or isinstance (obj , tk .Event ):
1048
1048
obj = self .selectedObject
1049
1049
1050
- if obj == None :
1051
- return
1052
-
1053
- amount = numpy .array (amount )
1054
-
1055
- pos = tuple (obj .pos + amount )
1056
-
1057
- obj .pos = pos
1058
-
1059
- self .updateObject (obj )
1060
-
1061
- if self .selectedObject == obj :
1062
- if 'pos' in self .objectProperties :
1063
- self .objectProperties ['pos' ]['var' ][0 ].set (pos [0 ])
1064
- self .objectProperties ['pos' ]['var' ][1 ].set (pos [1 ])
1050
+ if self .selectedPart ['type' ]:
1051
+ self .dragPart (
1052
+ obj = obj ,
1053
+ amount = amount ,
1054
+ )
1055
+ else :
1056
+ if obj == None :
1057
+ return
1058
+
1059
+ amount = numpy .array (amount )
1060
+ pos = tuple (obj .pos + amount )
1061
+ obj .pos = pos
1062
+ self .updateObject (obj )
1063
+
1064
+ if self .selectedObject == obj :
1065
+ if 'pos' in self .objectProperties :
1066
+ self .objectProperties ['pos' ]['var' ][0 ].set (pos [0 ])
1067
+ self .objectProperties ['pos' ]['var' ][1 ].set (pos [1 ])
1065
1068
1066
- return pos
1069
+ return pos
1067
1070
1068
1071
def deleteObject (self , obj : wmwpy .classes .Object = None ):
1069
1072
if (obj == None ) or isinstance (obj , tk .Event ):
@@ -1893,7 +1896,12 @@ def selectPart(
1893
1896
# self.updateLayers()
1894
1897
logging .debug (f'selected part: { self .selectedPart } ' )
1895
1898
1896
- def dragPart (self , event : tk .Event = None , obj : wmwpy .classes .Object | None = None ):
1899
+ def dragPart (
1900
+ self ,
1901
+ event : tk .Event = None ,
1902
+ obj : wmwpy .classes .Object | None = None ,
1903
+ amount : tuple [float , float ] | None = None ,
1904
+ ):
1897
1905
if obj == None :
1898
1906
obj = self .selectedObject
1899
1907
if obj == None :
@@ -1905,10 +1913,15 @@ def dragPart(self, event: tk.Event = None, obj: wmwpy.classes.Object | None = No
1905
1913
is_global = False
1906
1914
if obj .Type and obj .Type .get_property ('PathIsGlobal' ):
1907
1915
is_global = True
1908
- pos = self .windowPosToWMWPos ((event .x , event .y ), (0.25 * is_global ) + 1 )
1909
1916
1910
- if not is_global :
1911
- pos = numpy .array (pos ) - (numpy .array (obj .pos ) * 1.25 )
1917
+ if amount :
1918
+ current = obj .Type .get_property (self .selectedPart ['property' ])
1919
+ pos = numpy .array (current ) + amount
1920
+ else :
1921
+ pos = self .windowPosToWMWPos ((event .x , event .y ), (0.25 * is_global ) + 1 )
1922
+
1923
+ if not is_global :
1924
+ pos = numpy .array (pos ) - (numpy .array (obj .pos ) * 1.25 )
1912
1925
1913
1926
logging .debug (f'new pos: { pos } ' )
1914
1927
obj .properties [self .selectedPart ['property' ]] = ' ' .join ([str (x ) for x in pos ])
0 commit comments