UI updates

This commit is contained in:
Jeison Yehuda Amihud (Blender Dumbass) 2021-06-14 16:01:30 +00:00
parent 91e026594d
commit fb065b6627
4 changed files with 218 additions and 94 deletions

View file

@ -17,6 +17,7 @@
#################################### ####################################
import os import os
import urllib3
# GTK module ( Graphical interface # GTK module ( Graphical interface
import gi import gi
@ -56,27 +57,45 @@ def Open(win, filename, name):
# If the file is local. AKA exists in the folder. And can be read. # If the file is local. AKA exists in the folder. And can be read.
# Also it could be not .md # Also it could be not .md
if filename.startswith("lbry://"):
# Sometimes the link is linking an lbry or https source.
# meaning this link is has to be retrieved from the network.
# For this we have to retrieve the data from the network.
# The LBRY protocol has a little serive called spee.ch that
# simply redirects you to the file on the protocol. Let's
# try using it. ( the lbry3.vanwanet.com/speech/ is the
# actuall link it redircts to )
filename = filename.replace("lbry://", "https://lbry3.vanwanet.com/speech/")
http = urllib3.PoolManager()
resp = http.request('GET', filename)
md = resp.data.decode('utf-8')
elif not filename.endswith(".md"):
if not filename.endswith(".md"):
1/0 # Quick fail switch 1/0 # Quick fail switch
# Sometimes a language File is provided. let's else:
# look for it. # Sometimes a language File is provided. let's
# look for it.
l = win.settings["Language"] l = win.settings["Language"]
if os.path.exists(os.getcwd()+"/"+filename[:-3]+"_"+l+".md"):
filename = filename[:-3]+"_"+l+".md"
md = open(filename)
md = md.read()
if os.path.exists(os.getcwd()+"/"+filename[:-3]+"_"+l+".md"):
filename = filename[:-3]+"_"+l+".md"
md = open(filename)
md = md.read()
except: except:
# If reading fails. For example if it's a link to something on the # If reading fails. For example if it's a link to something on the
# web. Then try just opening it in the standard application. # web. Then try just opening it in the standard application.
md = "" md = ""
oscalls.Open(filename) oscalls.Open(filename)
win.current["mdfs"][name] = win.current["mdfs"]["failsafe"] win.current["mdfs"][name] = win.current["mdfs"]["failsafe"]
@ -363,7 +382,7 @@ def draw(outlayer, win, name, x, y, width, height):
# The # sing usually calls for search with in the text. # The # sing usually calls for search with in the text.
if "#" in filename: if "#" in filename and not "@" in filename:
filename, search = filename.split("#") filename, search = filename.split("#")
win.current["mdfs"][name] = filename win.current["mdfs"][name] = filename
else: else:
@ -406,7 +425,7 @@ def draw(outlayer, win, name, x, y, width, height):
UI_elements.text(outlayer, win, "markdown_name", UI_elements.text(outlayer, win, "markdown_name",
x+10, x+10,
y+5, y+5,
int(width)-120, int(width/2)-120,
40, 40,
set_text=filename, set_text=filename,
fill=False) fill=False)
@ -425,7 +444,7 @@ def draw(outlayer, win, name, x, y, width, height):
win.current["mdfs"][name] = win.text["markdown_name"]["text"] win.current["mdfs"][name] = win.text["markdown_name"]["text"]
UI_elements.roundrect(outlayer, win, UI_elements.roundrect(outlayer, win,
x+int(width)-150, x+int(width/2)-150,
y+5, y+5,
40, 40,
40, 40,
@ -438,41 +457,85 @@ def draw(outlayer, win, name, x, y, width, height):
except: except:
pass pass
# Users should be able to chose whether automatic downloading of stuff
# will be done by the software. This is why I want to add this setting
# here too. And not barried somewhere in the settings.
if width > 350:
download_ok = "unchecked"
if win.settings["auto_download_images"]:
download_ok = "checked"
def do():
win.settings["auto_download_images"] = not win.settings["auto_download_images"]
settings.write("auto_download_images", win.settings["auto_download_images"])
UI_elements.roundrect(outlayer, win,
x+int(width/2)-100,
y+5,
int(width/2)-150,
40,
10,
button=do,
icon=download_ok,
tip=talk.text("auto_download_images"))
UI_color.set(outlayer, win, "text_normal")
outlayer.set_font_size(20)
outlayer.move_to(x+int(width/2)-50,
y+30)
outlayer.show_text(talk.text("auto_download_images")[:int((int(width/2)-150)/9)])
# I want to include 2 button to the top raw besides the adress bar. # I want to include 2 button to the top raw besides the adress bar.
# A button to open the file in the standard application. ( Edit ) # A button to open the file in the standard application. ( Edit )
# A button to open the NoABug repository version ( NotABug ) # A button to open the NoABug repository version ( NotABug )
if width > 150 and not filename.startswith("lbry://"):
# EDIT
# EDIT def do():
oscalls.Open(filename)
def do(): UI_elements.roundrect(outlayer, win,
oscalls.Open(filename) x+int(width)-100,
y+5,
40,
40,
10,
button=do,
icon="edit",
tip=talk.text("edit_markdown"))
# NOTABUG
def do():
oscalls.Open("https://notabug.org/jyamihud/VCStudio/src/master/"+filename)
UI_elements.roundrect(outlayer, win,
x+int(width)-50,
y+5,
40,
40,
10,
button=do,
icon="notabug",
tip=talk.text("notabug_markdown"))
elif width > 100:
# ODYSEE ( LBRY ) open in browser
def do():
oscalls.Open(filename.replace("lbry://", "https://odysee.com/"))
UI_elements.roundrect(outlayer, win,
x+int(width)-50,
y+5,
40,
40,
10,
button=do,
icon="lbry",
tip="Odysee.com (LBRY)")
UI_elements.roundrect(outlayer, win,
x+int(width)-100,
y+5,
40,
40,
10,
button=do,
icon="edit",
tip=talk.text("edit_markdown"))
# NOTABUG
def do():
oscalls.Open("https://notabug.org/jyamihud/VCStudio/src/master/"+filename)
UI_elements.roundrect(outlayer, win,
x+int(width)-50,
y+5,
40,
40,
10,
button=do,
icon="notabug",
tip=talk.text("notabug_markdown"))
# Now let's draw the bastard. We are going to do it the same way as in the # Now let's draw the bastard. We are going to do it the same way as in the
# script writer. But rather simplified. For example we are not making an # script writer. But rather simplified. For example we are not making an
# editor. But only a reader. So we don't need the selection. And we don't # editor. But only a reader. So we don't need the selection. And we don't
@ -645,7 +708,7 @@ def draw(outlayer, win, name, x, y, width, height):
# a button to download it. We need to offset the link button. SO. # a button to download it. We need to offset the link button. SO.
def do(): def do():
if block[2].endswith(".md"): if block[3].endswith(".md"):
win.current["mdfs"]["failsafe"] = filename win.current["mdfs"]["failsafe"] = filename
win.current["mdfs"][name] = block[3] win.current["mdfs"][name] = block[3]
win.current["current_help_selected"] = "" win.current["current_help_selected"] = ""
@ -730,16 +793,14 @@ def draw(outlayer, win, name, x, y, width, height):
# AHh... I'll do a clicker here. # AHh... I'll do a clicker here.
if not win.current["LMB"] and win.previous["LMB"]: if not win.current["LMB"] and win.previous["LMB"]:
if block[2].endswith(".md"): if block[2].startswith("#"):
win.current["mdfs"][name] = win.current["mdfs"][name] + block[2]
win.current["current_help_selected"] = ""
else:
win.current["mdfs"]["failsafe"] = filename win.current["mdfs"]["failsafe"] = filename
win.current["mdfs"][name] = block[2] win.current["mdfs"][name] = block[2]
win.current["current_help_selected"] = "" win.current["current_help_selected"] = ""
win.scroll["markdown"] = 0 win.scroll["markdown"] = 0
elif block[2].startswith("#"):
win.current["mdfs"][name] = win.current["mdfs"][name] + block[2]
win.current["current_help_selected"] = ""
else:
oscalls.Open(block[2])
elif win.current["mx"] not in range(win.previous["mx"]-5, win.previous["mx"]+5): elif win.current["mx"] not in range(win.previous["mx"]-5, win.previous["mx"]+5):

View file

@ -56,6 +56,17 @@ def set(layer, win, color):
# One line code less to setup a color each time LOL # One line code less to setup a color each time LOL
try: try:
r,g,b,a = win.color[color] r,g,b,a = win.color[color]
# If blur is off I want the transparent to be less
# noticable. Since blur helped a lot in readability.
# Without blur the same amount of alpha is not going
# to be as readable. So we have to boost it without
# the blur.
if a < 1 and not win.settings["Blur"]:
a = min(0.9, a*2)
layer.set_source_rgba(r,g,b,a) layer.set_source_rgba(r,g,b,a)
except: except:
layer.set_source_rgba(1,0,1,1) layer.set_source_rgba(1,0,1,1)

View file

@ -252,6 +252,14 @@ def loadimage(layer, win ,path, x, y, width, height, fit, cell=0):
settings.write("auto_download_images", win.settings["auto_download_images"]) settings.write("auto_download_images", win.settings["auto_download_images"])
filename = "/tmp/"+path.replace("/","_") filename = "/tmp/"+path.replace("/","_")
# It could an image data without an image .png thing
found = False
for f in fileformats.images:
if filename.endswith(f):
found = True
if not found:
filename = filename+".png"
tmppath = "" tmppath = ""
if path.startswith("http") and not os.path.exists(filename): if path.startswith("http") and not os.path.exists(filename):
@ -289,8 +297,9 @@ def loadimage(layer, win ,path, x, y, width, height, fit, cell=0):
elif path.startswith("http"): elif path.startswith("http"):
tmppath = path tmppath = path
path = filename path = filename
# Also I don't want downloading to happen here. Since if it's not # Also I don't want downloading to happen here. Since if it's not
# downloaded # downloaded

View file

@ -39,6 +39,14 @@ def layer(win, call):
# This file will give the user documentation about various part of VCStudio # This file will give the user documentation about various part of VCStudio
########################################################################## ##########################################################################
# Determening whether we are in a Tiny mode or not. Whether to shrink
# everything or keep it full screen.
tiny = False
if win.current["w"] < 1280:
tiny = True
# Making the layer # Making the layer
@ -59,13 +67,15 @@ def layer(win, call):
) )
layer.fill() layer.fill()
nodeX = 500
if tiny:
nodeX = 100
UI_color.set(layer, win, "node_background") UI_color.set(layer, win, "node_background")
UI_elements.roundrect(layer, win, UI_elements.roundrect(layer, win,
100, 100,
100, 100,
500, nodeX,
win.current["h"]-200, win.current["h"]-200,
10) 10)
@ -77,9 +87,12 @@ def layer(win, call):
def do(): def do():
win.current["calls"][call]["var"] = False win.current["calls"][call]["var"] = False
exitX = 560
if tiny:
exitX = 150
UI_elements.roundrect(layer, win, UI_elements.roundrect(layer, win,
560, exitX,
win.current["h"]-140, win.current["h"]-140,
40, 40,
40, 40,
@ -91,32 +104,34 @@ def layer(win, call):
x = 110 x = 110
y = 170 y = 170
width = 500 - 20 width = nodeX - 20
height = win.current["h"]-270 height = win.current["h"]-270
# Search # Search
if not tiny:
UI_elements.image(layer, win, "settings/themes/"\ UI_elements.image(layer, win, "settings/themes/"\
+win.settings["Theme"]+"/icons/search.png", +win.settings["Theme"]+"/icons/search.png",
x+width/4, x+width/4,
y-50, y-50,
40, 40,
40) 40)
UI_elements.text(layer, win, "in_help", UI_elements.text(layer, win, "in_help",
x+width/4+50, x+width/4+50,
y-50, y-50,
width/2-50, width/2-50,
40) 40)
### MARKDOWN ### MARKDOWN
UI_Markdown.draw(layer, win, "help_markdown", UI_Markdown.draw(layer, win, "help_markdown",
700, nodeX+200,
100, 100,
win.current["w"]-800, win.current["w"]-(nodeX+300),
win.current["h"]-200) win.current["h"]-200)
@ -158,43 +173,53 @@ def layer(win, call):
documentations = { documentations = {
talk.text("readme"):[ talk.text("readme"):[
["Markdown", "README.md"], ["Markdown", "README.md"],
["scene", "https://notabug.org/jyamihud/VCStudio/src/master/README.md"] ["icon", "scene"]
], ],
talk.text("license"):[ talk.text("license"):[
["Markdown", "LICENSE.md"], ["Markdown", "LICENSE.md"],
["icon", "scene"]
], ],
talk.text("documentation_installation"):[ talk.text("documentation_installation"):[
["Markdown", "wiki/docs/Installation.md"], ["Markdown", "wiki/docs/Installation.md"],
["video", "https://open.lbry.com/@blender-organizer:5/rnd0001-4061:1?r=7YADjAZEbHJg8n4qV5rAuBh5Hca7cZQK"] ["video", "https://open.lbry.com/@blender-organizer:5/rnd0001-4061:1?r=7YADjAZEbHJg8n4qV5rAuBh5Hca7cZQK"],
["icon", "new"]
], ],
talk.text("documentation_project_manager"):[ talk.text("documentation_project_manager"):[
["Markdown", "wiki/docs/Project-Manager.md"], ["Markdown", "wiki/docs/Project-Manager.md"],
["video", "https://open.lbry.com/@blender-organizer:5/Victorious-Children-Studio-Organizer-%28-VCStudio-%29---Project-Manager-Tutorial---Creating-Projects---Scanning-the-OS---Settings:7?r=7YADjAZEbHJg8n4qV5rAuBh5Hca7cZQK"] ["video", "https://open.lbry.com/@blender-organizer:5/Victorious-Children-Studio-Organizer-%28-VCStudio-%29---Project-Manager-Tutorial---Creating-Projects---Scanning-the-OS---Settings:7?r=7YADjAZEbHJg8n4qV5rAuBh5Hca7cZQK"],
["icon", "configure_file"]
], ],
talk.text("documentation_story_editor"):[ talk.text("documentation_story_editor"):[
["Markdown", "wiki/docs/Story-Editor.md"], ["Markdown", "wiki/docs/Story-Editor.md"],
["icon", "node"]
], ],
talk.text("documentation_script_writer"):[ talk.text("documentation_script_writer"):[
["Markdown", "wiki/docs/Script-Writer.md"], ["Markdown", "wiki/docs/Script-Writer.md"],
["icon", "frase"]
], ],
talk.text("documentation_analytics"):[ talk.text("documentation_analytics"):[
["Markdown", "wiki/docs/Analytics.md"], ["Markdown", "wiki/docs/Analytics.md"],
["icon", "analytics"]
], ],
talk.text("documentation_assets"):[ talk.text("documentation_assets"):[
["Markdown", "wiki/docs/Assets.md"], ["Markdown", "wiki/docs/Assets.md"],
["update", "https://notabug.org/jyamihud/VCStudio/wiki/Version+20.1211+%28Asset+Manager+Alpha+++Default+Blend+Files++Project%27s+Settings%29"] ["update", "https://notabug.org/jyamihud/VCStudio/wiki/Version+20.1211+%28Asset+Manager+Alpha+++Default+Blend+Files++Project%27s+Settings%29"],
["icon", "obj"]
], ],
talk.text("documentation_link_assets"):[ talk.text("documentation_link_assets"):[
["Markdown", "wiki/docs/LinkingAssets.md"], ["Markdown", "wiki/docs/LinkingAssets.md"],
["update", "https://notabug.org/jyamihud/VCStudio/wiki/Version+20.1263+%28+Linking+Assets+++Configuring+Assets+%29"] ["update", "https://notabug.org/jyamihud/VCStudio/wiki/Version+20.1263+%28+Linking+Assets+++Configuring+Assets+%29"],
["icon", "link"]
], ],
talk.text("documentation_render"):[ talk.text("documentation_render"):[
["scene", "https://notabug.org/jyamihud/VCStudio/wiki/Documenation+%7C+Rendering+%7C+Version+20.128"], ["Markdown", "wiki/docs/Rendering.md"],
["update", "https://notabug.org/jyamihud/VCStudio/wiki/Version+20.1266+%28+Rendering+Of+Shots+%29"] ["update", "https://notabug.org/jyamihud/VCStudio/wiki/Version+20.1266+%28+Rendering+Of+Shots+%29"],
["icon", "render"]
], ],
talk.text("documentation_multiuser"):[ talk.text("documentation_multiuser"):[
["scene", "https://notabug.org/jyamihud/VCStudio/wiki/Documenation+%7C+Multiuser+%7C+Version+21.1"], ["Markdown", "wiki/docs/Multiuser.md"],
["update", "https://notabug.org/jyamihud/VCStudio/wiki/Version+21.0"] ["update", "https://notabug.org/jyamihud/VCStudio/wiki/Version+21.0"],
["icon", "multiuser"]
] ]
} }
@ -229,23 +254,34 @@ def layer(win, call):
win.current["current_help_selected"] = name win.current["current_help_selected"] = name
else: else:
win.current["current_help_selected"] = False win.current["current_help_selected"] = False
# I want to make sure that there is no icon before making it
# be "question"
showicon = "question"
for entry in doc:
if entry[0] == "icon":
showicon = entry[1]
UI_elements.roundrect(layer, win, UI_elements.roundrect(layer, win,
x, x,
y+current_Y + win.scroll["help"], y+current_Y + win.scroll["help"],
width, width,
40, 40,
10, 10,
icon="question", icon=showicon,
button=do) button=do,
tip=name)
# And a text. The name of the entry # And a text. The name of the entry
UI_color.set(layer, win, "text_normal") if not tiny:
layer.set_font_size(20)
layer.move_to(x+50, UI_color.set(layer, win, "text_normal")
y+current_Y + win.scroll["help"]+25) layer.set_font_size(20)
layer.show_text(name) layer.move_to(x+50,
y+current_Y + win.scroll["help"]+25)
layer.show_text(name)
# Now if it's selected we going to see what links are inside. # Now if it's selected we going to see what links are inside.
if name == win.current["current_help_selected"]: if name == win.current["current_help_selected"]:
@ -278,13 +314,17 @@ def layer(win, call):
#win.current["current_help_selected"] = "" #win.current["current_help_selected"] = ""
continue continue
# icon do not show
elif entry[0] == "icon":
continue
# Launch button # Launch button
def do(): def do():
oscalls.Open(entry[-1]) oscalls.Open(entry[-1])
UI_elements.roundrect(layer, win, UI_elements.roundrect(layer, win,
x+20, x+10,
y+current_Y + win.scroll["help"], y+current_Y + win.scroll["help"],
width-20, width-20,
40, 40,
@ -294,12 +334,15 @@ def layer(win, call):
tip=entry[-1]) tip=entry[-1])
# And a text. The name of the entry # And a text. The name of the entry
UI_color.set(layer, win, "text_normal")
layer.set_font_size(20) if not tiny:
layer.move_to(x+70,
y+current_Y + win.scroll["help"]+25) UI_color.set(layer, win, "text_normal")
layer.show_text(talk.text("documentation_type_"+entry[0])) layer.set_font_size(20)
layer.move_to(x+70,
y+current_Y + win.scroll["help"]+25)
layer.show_text(talk.text("documentation_type_"+entry[0]))
current_Y = current_Y + 50 current_Y = current_Y + 50
else: else: