Upload files to 'UI'

This commit is contained in:
Jeison Yehuda Amihud (Blender Dumbass) 2020-12-06 13:51:23 +00:00
parent 72f002497c
commit 4e96b3e9d2

View file

@ -61,3 +61,77 @@ def rectangle_overlap(rectangle1, rectangle2):
return overlap return overlap
def rectangle_surround( win, name, target_pos, target_size, now_pos, now_size ):
# This function does surrounding operations. For example you have N amount
# of nodes selected. And you want to draw a rectangle arround all of them.
# for this you will have to find out the smallest of all values and biggest
# and so this is what this funtion is for.
now_pos = now_pos.copy()
now_size = now_size.copy()
# We are going to start by refrashing the current position of the rectangle
# for this we need to know whether at this frame there was a refresh already.
if win.current["frame"] != win.surround["frame"]:# and win.current["frame"] % 2 == 0:
win.surround["frame"] = win.current["frame"]
win.surround["rects"] = []
# Now let's see if a given name is in the data of those refrashed.
if name not in win.surround["rects"]:
target_pos[0] = now_pos[0]
target_pos[1] = now_pos[1]
target_size[0] = now_size[0]
target_size[1] = now_size[1]
win.surround["rects"].append(name)
# Now you maybe wondering why I would not just make the whole targer_size
# for example = [0,0]. And it because lists are linked from some other
# data. And I don't create new lists. But change the link lists.
# Now let's do the checking and overwritting of all the rest of the data.
if now_pos[0] < target_pos[0]:
target_size[0] += target_pos[0] - now_pos[0]
target_pos[0] = now_pos[0]
if now_pos[1] < target_pos[1]:
target_size[1] += target_pos[1] - now_pos[1]
target_pos[1] = now_pos[1]
# Now the size. It's a bit trickier. But not too hard. We need to remember
# the the ultimate bottom, right point is a combintation of position and
# size.
if now_pos[0] + now_size[0] > target_pos[0] + target_size[0]:
target_size[0] = now_size[0] + now_pos[0] - target_pos[0]
if now_pos[1] + now_size[1] > target_pos[1] + target_size[1]:
target_size[1] = now_size[1] + now_pos[1] - target_pos[1]
def filter_arrows(win):
# This function filters the arrow connections. I copied it from the
# Blender_Organizer's code. at py_data/modules/story_editor.py
# Doing some clever magic I forgot the purpose of
for num, arrow in enumerate(win.story["arrows"]):
for num2, arrow2 in enumerate(win.story["arrows"]):
if arrow[0] == arrow2[0] or arrow[1] == arrow2[1]:
win.story["arrows"][num] = arrow2
# Removing doubles
tmp = []
for i in win.story["arrows"]:
if i not in tmp:
tmp.append(i)
win.story["arrows"] = tmp