Upload files to 'UI'
This commit is contained in:
parent
76f6ab9863
commit
28550084f5
1 changed files with 102 additions and 13 deletions
|
@ -459,19 +459,21 @@ def scroll_area(layer, win, name, x, y, width, height, maxlength,
|
|||
if win.current['mx'] in range(x, x+width) \
|
||||
and win.current['my'] in range(y, y+height) :
|
||||
if not mmb_only:
|
||||
if not sideways:
|
||||
amount = win.current["scroll"][1]*strenght
|
||||
else:
|
||||
amount = win.current["scroll"][0]*strenght
|
||||
|
||||
|
||||
amount = win.current["scroll"][1]*strenght
|
||||
|
||||
|
||||
if mmb_only:
|
||||
mmb = True
|
||||
|
||||
# Middle mouse button scroll, or using a graphical tablet.
|
||||
if mmb:
|
||||
if win.current["MMB"]:
|
||||
amount = 0 - ( win.current["my"] - win.previous["my"] )
|
||||
|
||||
if not sideways:
|
||||
amount = 0 - ( win.current["my"] - win.previous["my"] )
|
||||
else:
|
||||
amount = 0 - ( win.current["mx"] - win.previous["mx"] )
|
||||
|
||||
# I guess I need to separate the logic into a separate minifunction.
|
||||
# I will use later for the scroll bar thingy. So not to rewrite the code
|
||||
# Here is a function thingy.
|
||||
|
@ -482,12 +484,20 @@ def scroll_area(layer, win, name, x, y, width, height, maxlength,
|
|||
# Scroll logic
|
||||
win.scroll[name] -= amount
|
||||
|
||||
# If too low
|
||||
if win.scroll[name] < (1-maxlength+height):
|
||||
win.scroll[name] = (1-maxlength+height)
|
||||
# If too high
|
||||
if win.scroll[name] > 0:
|
||||
win.scroll[name] = 0
|
||||
if not sideways:
|
||||
# If too low
|
||||
if win.scroll[name] < (1-maxlength+height):
|
||||
win.scroll[name] = (1-maxlength+height)
|
||||
# If too high
|
||||
if win.scroll[name] > 0:
|
||||
win.scroll[name] = 0
|
||||
else:
|
||||
# If too low
|
||||
if win.scroll[name] < (1-maxlength+width):
|
||||
win.scroll[name] = (1-maxlength+width)
|
||||
# If too high
|
||||
if win.scroll[name] > 0:
|
||||
win.scroll[name] = 0
|
||||
logic()
|
||||
# Not BAR. Which is going to be drawn at a side of what ever content there
|
||||
# Basically a scrollbar. But implemented from scratch. Because I'm crazy.
|
||||
|
@ -577,7 +587,86 @@ def scroll_area(layer, win, name, x, y, width, height, maxlength,
|
|||
LSy,
|
||||
5
|
||||
)
|
||||
|
||||
else:
|
||||
|
||||
# Fist let's make some math in front. Because things like this
|
||||
# require ton of maths. And it's good to have some predone.
|
||||
|
||||
tobreak = False # Also if we can abort the operation early with it.
|
||||
fraction = width / maxlength # Similar to progress bar for now
|
||||
if fraction > 1:
|
||||
tobreak = True
|
||||
|
||||
# To break parameter basically says. To draw it the bar only when
|
||||
# it's actully needed. When content aka maxlength is bigger then
|
||||
# our viewport.
|
||||
|
||||
if not tobreak:
|
||||
|
||||
# Now the offset value. That will move our progress bar with
|
||||
# the scroll value.
|
||||
|
||||
offset = (width-60)*( (1-win.scroll[name]) / maxlength )
|
||||
|
||||
# Background bar
|
||||
|
||||
UI_color.set(layer, win, "background")
|
||||
roundrect(layer, win,
|
||||
x+30,
|
||||
(y+height)-20,
|
||||
width-60,
|
||||
10,
|
||||
5
|
||||
)
|
||||
|
||||
# Active bar
|
||||
|
||||
UI_color.set(layer, win, "button_active")
|
||||
|
||||
# Let's save a little bit more math because it's going to be
|
||||
# vild. And I love it.
|
||||
|
||||
Lx = (y+height)-20
|
||||
LSx = 10
|
||||
Ly = x+30+offset
|
||||
LSy = (width-60)*fraction
|
||||
|
||||
# Mouse over thingy. To make the bat a tiny bit brighter.
|
||||
# indicating to the user that it's now could be used.
|
||||
|
||||
if win.current['my'] in range(int(Lx), int(Lx+LSx)) \
|
||||
and win.current['mx'] in range(int(Ly), int(Lx+LSy)) :
|
||||
UI_color.set(layer, win, "button_clicked")
|
||||
|
||||
# Now separatelly we gonna check for if the mouse pressed.
|
||||
# Remember if it's not pressed it's False. It's written in one
|
||||
# of the files. Basically I want to be able to move the mouse
|
||||
# outside the bar while moving. And so it won't cancel the motion.
|
||||
|
||||
# It seems like I did something wrong. Anyways it works.
|
||||
|
||||
if win.current["LMB"]:
|
||||
if int(win.current['LMB'][1]) in range(int(Lx), int(Lx+LSx)) \
|
||||
and int(win.current['LMB'][0]) in range(int(x), int(x+(width-60))) :
|
||||
|
||||
UI_color.set(layer, win, "button_clicked")
|
||||
|
||||
# A bit more math to set the value back.
|
||||
amount = ( win.current["mx"] - win.previous["mx"] ) / \
|
||||
(width-60) * maxlength
|
||||
logic() # Yeah. Look a few lines back.
|
||||
|
||||
# And only after all of this nonsense we can draw the cube. Or
|
||||
# should I say roundrect? A button? Aaaaaa....
|
||||
|
||||
roundrect(layer, win,
|
||||
Ly,
|
||||
Lx,
|
||||
LSy,
|
||||
LSx,
|
||||
5
|
||||
)
|
||||
|
||||
def text(outlayer, win, name, x, y, width, height, set_text="", parse=False, fill=True,
|
||||
editable=True, multiline=False , linebreak=False, centered=False, tip="",
|
||||
|
|
Loading…
Add table
Reference in a new issue