From c0b2ea678ca3adaf14546226af73f68ff902a4c1 Mon Sep 17 00:00:00 2001 From: "Jeison Yehuda Amihud (Blender Dumbass)" Date: Sun, 3 Jan 2021 13:47:00 +0000 Subject: [PATCH] More theming Support --- UI/UI_elements.py | 60 ++++++++++++++++++++++++++++++++++++--------- UI/UI_helpDialog.py | 4 +++ 2 files changed, 52 insertions(+), 12 deletions(-) diff --git a/UI/UI_elements.py b/UI/UI_elements.py index 583d757..88c5804 100644 --- a/UI/UI_elements.py +++ b/UI/UI_elements.py @@ -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 # each with it's own loading problems. + + # 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 # something about it. @@ -250,8 +252,11 @@ def loadimage(layer, win ,path, x, y, width, height, fit, cell=0): try: load1 = GdkPixbuf.Pixbuf.new_from_file(path) 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 for f in fileformats.videos: if path.endswith(f): @@ -283,8 +288,10 @@ def loadimage(layer, win ,path, x, y, width, height, fit, cell=0): pass 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 for f in ["blend", "blend1"]: @@ -324,14 +331,22 @@ def loadimage(layer, win ,path, x, y, width, height, fit, cell=0): pass 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 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 Px = load1.get_width() Py = load1.get_height() @@ -372,10 +387,11 @@ def loadimage(layer, win ,path, x, y, width, height, fit, cell=0): imagedraw.scale(factor, factor) dx = (width/2)/factor -(load2.get_width() /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() else: 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 # 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 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"] # 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 diff --git a/UI/UI_helpDialog.py b/UI/UI_helpDialog.py index f588a34..4634ba7 100644 --- a/UI/UI_helpDialog.py +++ b/UI/UI_helpDialog.py @@ -168,6 +168,10 @@ def layer(win, call): talk.text("documentation_render"):[ ["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"] + ], + 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"] ] }