More theming Support

This commit is contained in:
Jeison Yehuda Amihud (Blender Dumbass) 2021-01-03 13:47:00 +00:00
parent 9a69445782
commit c0b2ea678c
2 changed files with 52 additions and 12 deletions

View file

@ -229,6 +229,8 @@ def loadimage(layer, win ,path, x, y, width, height, fit, cell=0):
# an image file. Like png or jpeg. Either a video file. Or a blend file # an image file. Like png or jpeg. Either a video file. Or a blend file
# each with it's own loading problems. # each with it's own loading problems.
# While cairo can read pngs directly. It's not the best way of doing it # While cairo can read pngs directly. It's not the best way of doing it
# since it's not capable of reading jpegs and other files. So let's do # since it's not capable of reading jpegs and other files. So let's do
# something about it. # something about it.
@ -250,8 +252,11 @@ def loadimage(layer, win ,path, x, y, width, height, fit, cell=0):
try: try:
load1 = GdkPixbuf.Pixbuf.new_from_file(path) load1 = GdkPixbuf.Pixbuf.new_from_file(path)
except: except:
load1 = GdkPixbuf.Pixbuf.new_from_file("settings/themes/"+win.settings["Theme"]+"/icons/image.png") try:
load1 = GdkPixbuf.Pixbuf.new_from_file("settings/themes/"+win.settings["Theme"]+"/icons/image.png")
except:
load1 = GdkPixbuf.Pixbuf.new_from_file("settings/themes/Default/icons/image.png")
# VIDEOFILES # VIDEOFILES
for f in fileformats.videos: for f in fileformats.videos:
if path.endswith(f): if path.endswith(f):
@ -283,8 +288,10 @@ def loadimage(layer, win ,path, x, y, width, height, fit, cell=0):
pass pass
except: except:
load1 = GdkPixbuf.Pixbuf.new_from_file("settings/themes/"+win.settings["Theme"]+"/icons/video.png") try:
load1 = GdkPixbuf.Pixbuf.new_from_file("settings/themes/"+win.settings["Theme"]+"/icons/video.png")
except:
load1 = GdkPixbuf.Pixbuf.new_from_file("settings/themes/Default/icons/video.png")
# BLEND FILES # BLEND FILES
for f in ["blend", "blend1"]: for f in ["blend", "blend1"]:
@ -324,14 +331,22 @@ def loadimage(layer, win ,path, x, y, width, height, fit, cell=0):
pass pass
except: except:
load1 = GdkPixbuf.Pixbuf.new_from_file("settings/themes/"+win.settings["Theme"]+"/icons/blender.png")
try:
load1 = GdkPixbuf.Pixbuf.new_from_file("settings/themes/"+win.settings["Theme"]+"/icons/blender.png")
except:
load1 = GdkPixbuf.Pixbuf.new_from_file("settings/themes/Default/icons/blender.png")
if not foundformat: if not foundformat:
# If you can't find any format. Just use the file icon then # If you can't find any format. Just use the file icon then
load1 = GdkPixbuf.Pixbuf.new_from_file("settings/themes/"+win.settings["Theme"]+"/icons/file.png") try:
load1 = GdkPixbuf.Pixbuf.new_from_file("settings/themes/"+win.settings["Theme"]+"/icons/file.png")
except:
load1 = GdkPixbuf.Pixbuf.new_from_file("settings/themes/Default/icons/file.png")
# Then to convert the pixbuf to a cairo surface # Then to convert the pixbuf to a cairo surface
Px = load1.get_width() Px = load1.get_width()
Py = load1.get_height() Py = load1.get_height()
@ -372,10 +387,11 @@ def loadimage(layer, win ,path, x, y, width, height, fit, cell=0):
imagedraw.scale(factor, factor) imagedraw.scale(factor, factor)
dx = (width/2)/factor -(load2.get_width() /2) dx = (width/2)/factor -(load2.get_width() /2)
dy = (height/2)/factor -(load2.get_height()/2) dy = (height/2)/factor -(load2.get_height()/2)
# Let's make an ability for theme makers to simply color the standard
# icons into any shade.
imagedraw.set_source_surface(load2, dx, dy)
imagedraw.set_source_surface(load2, dx, dy)
imagedraw.paint() imagedraw.paint()
else: else:
imagesurface = load2 imagesurface = load2
@ -433,6 +449,12 @@ def image(layer, win ,path, x, y, width=0, height=0, fit="crop", cell=0):
# that on a special redraw call. We are going to check hashes storred with # that on a special redraw call. We are going to check hashes storred with
# those from the file. And only if a file really changed. Then update the image. # those from the file. And only if a file really changed. Then update the image.
# First the icon might not exist in the icon pack. Since I want to make
# packs using
if win.settings["Theme"] in path and not os.path.exists(path):
path = path.replace(win.settings["Theme"], "Default")
if path not in win.images[cell] or win.images[cell][path]["loading"]: if path not in win.images[cell] or win.images[cell][path]["loading"]:
# If this is the first time this image is draw we want to create it a data # If this is the first time this image is draw we want to create it a data
@ -467,8 +489,22 @@ def image(layer, win ,path, x, y, width=0, height=0, fit="crop", cell=0):
imagesurface = win.images[cell][path]["image"] imagesurface = win.images[cell][path]["image"]
# Writting the image to the screen # Writting the image to the screen
layer.set_source_surface(imagesurface, x, y)
layer.paint()
if "icons" in win.color and "settings/themes/" in path:
UI_color.set(layer, win, "icons")
layer.rectangle(x,y,0,0)
layer.fill()
layer.mask_surface(imagesurface, x, y)
UI_color.set(layer, win, "icons")
layer.fill()
else:
layer.set_source_surface(imagesurface, x, y)
layer.paint()
# And if testing # And if testing

View file

@ -168,6 +168,10 @@ def layer(win, call):
talk.text("documentation_render"):[ talk.text("documentation_render"):[
["scene", "https://notabug.org/jyamihud/VCStudio/wiki/Documenation+%7C+Rendering+%7C+Version+20.128"], ["scene", "https://notabug.org/jyamihud/VCStudio/wiki/Documenation+%7C+Rendering+%7C+Version+20.128"],
["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"]
],
talk.text("documentation_multiuser"):[
["scene", "https://notabug.org/jyamihud/VCStudio/wiki/Documenation+%7C+Multiuser+%7C+Version+21.1"],
["update", "https://notabug.org/jyamihud/VCStudio/wiki/Version+21.0"]
] ]
} }