Blender-Pipeline/UI/UI_color.py

88 lines
2.6 KiB
Python

####################################
# #
# COPYRIGHT NOTICE #
# #
# This file is a part of Victori- #
# ous Children Studio Organizer. #
# Or simply VCStudio. Copyright #
# of J.Y.Amihud. But don't be sad #
# because I released the entire #
# project under a GNU GPL license. #
# You may use Version 3 or later. #
# See www.gnu.org/licenses if your #
# copy has no License file. Please #
# note. Ones I used the GPL v2 for #
# it. It's no longer the case. #
# #
####################################
# This a console project manager.
import os
import math
# GTK module ( Graphical interface
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
import cairo
# Own modules
from settings import settings
from settings import talk
def get_table():
# This function will give a whole table of colors from a theme. So there will
# be no need to read from the theme.data file every time we need a color of
# somethings. It would've been stupid. So we load all the colors into RAM
# at this stage. Similar stuff should be done with talk.text() i guess.
# First let's find what is actually the theme we are using.
try:
data = open("settings/themes/"+settings.read("Theme")+"/theme.data")
except:
# If by any change it fails to read the theme from the Theme setting
# it will use the Default theme.
data = open("settings/themes/Default/theme.data")
settings.write("Theme", "Default")
data = data.read()
data = data.split("\n")
# Parsing
ret = {}
for d in data:
if d:
name = d.split(" = ")[0]
color = d.split(" = ")[1].split(",")
c = []
for co in color:
try:
c.append(float(co))
except:
c.append(0.0)
color = c
ret[name] = color
# Returning
return ret
def set(layer, win, color):
# One line code less to setup a color each time LOL
try:
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)
except:
layer.set_source_rgba(1,0,1,1)