12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355 |
- # THIS FILE IS A PART OF VCStudio
- # PYTHON 3
- import os
- import cairo
- try:
- from gi.repository import Gtk
- from gi.repository import Gdk
- except:
- pass
- #UI modules
- from UI import UI_elements
- from UI import UI_color
- #settings
- from settings import talk
- #studio
- from studio import analytics
- from studio import story
- from studio import history
- def get_list(filepath):
-
- # This fucntion converts text documents. (.progress) into a more machine
- # friendly recursive dict.
-
- # In the original organizer evaluation of the checklist was done separatelly
- # in a different function. Which made it very messy for recursive stuff.
- # I will attemp to combine it. And make it more clean as a result.
-
- checklist = {
- "fraction":0.0, # The percentage of a checklist. From 0.0 to 1.0
- "string":filepath,
- "editing":False,# Whether the string is during editing. UI.
- "selected":False,# Whether the current task is selected.
- "open":True, # Whether to draw the suptasks. UI.
- "subtasks":[] # List of subtastks. (In the same format as the checklist)
- }
-
-
- data = open(filepath)
- data = data.read()
- data = data.split("\n")
-
- # Let's filter out all the comments. Lines starting with #. For some reason
- # in the old organizer. I just thought it wasn't important. LOL. And just
- # started reading from the 10th line.
-
- # Here is an example of the first 9 lines.
-
- # 1 #### Blender orgainizer checklist format
- # 2 #### INDINTATION (4 SPACES LONG)
- # 3 #### STR means Start date of the ASSET
- # 4 #### FIN means Finish deadline of the asset
- # 5 #### [ ] means that task is on list
- # 6 #### [V] means that tast is finished
- # 7 #### DO NOT USE EMPTY LINES
- # 8 STR 24/02/2020
- # 9 FIN 01/05/2021
-
- # You can see a trace from a very long time ago. From the first versions
- # of the blender organizer. The STR and FIN values. Which are start and
- # deadline of the project.
-
- # I guess we need to filter it out a bit differently. Checking whether a
- # given line starts with a [ or with a number of spaces and [. This will
- # make the file a little more open to editing by hand. Without too much
- # worrying that something will break.
-
- cleandata = []
-
- for line in data:
-
- # So not to mangle the line.
- tmp = line
- while tmp.startswith(" "):
- tmp = tmp[1:]
-
- # Checking
- if tmp.startswith("[ ]") or tmp.startswith("[V]"):
- cleandata.append(line)
-
- # Now since we have the cleandata. We can try to parse it somehow into a
- # checklist thing. For this we need a reqursion. I gonna use a method from
- # the blender-organizer. By running the function with in itself. It's not
- # very wise. I know. In python3 it will give you no more then 996 recursions
- # untill it will declare an error. BUT. It's 996 layers of a subtaks.
- # For now I don't see a need in so many subtasks. Let's think of layers of
- # subtasks as of memory. This laptop has only 8 GB of RAM. I can't put more
- # data into it even if I wanted.
-
- def convert(part, indent=0):
- # If a thing have subtasks it should not even be a checkbox. So trying
- # To evaluate it's fraction by whether it's a [ ] or [V] shoun't be
- # done.
-
- subtask = []
-
- for num, line in enumerate(part):
-
- # Let's get the NEXT line. I'm not kidding. We gonna work with the
- # next line to see whether to count this lines [V]
-
-
- if line[indent:].startswith("["):
-
- thisline = {
- "fraction":0.0,
- "string":line[line.find("]")+2:],
- "editing":False,
- "selected":False,
- "open":False,
- "subtasks":[]
- }
-
- try:
- nextline = part[num+1]
- except:
- nextline = ""
-
- if not line[line.find("]")+1] == ".":
- thisline["open"] = True
-
- if nextline.find("[")-1 <= indent:
- if line[indent:].startswith("[V]"):
- thisline["fraction"] = 1.0
-
- else:
- subpart = []
- subdent = indent
- for n, l in enumerate(part[num+1:]):
- if n == 0:
- subdent = l.find("[")
-
- if l.find("[")-1 <= indent:
- break
-
- else:
- subpart.append(l)
-
- #print(subpart)
- thisline["subtasks"] = convert(subpart, subdent)
-
- fracs = []
- for task in thisline["subtasks"]:
- if not task["string"].startswith("#"):
- fracs.append(task["fraction"])
-
- try:
- thisline["fraction"] = sum(fracs) / len(fracs)
- except:
- thisline["fraction"] = 0.0
-
- # Sometime it was showing 99% when infect it's 100%
- if thisline["fraction"] == 0.9999:
- thisline["fraction"] = 1.0
-
-
- subtask.append(thisline)
-
- return subtask
-
-
- checklist["subtasks"] = convert(cleandata)
- fracs = []
- for task in checklist["subtasks"]:
- if not task["string"].startswith("#"):
- fracs.append(task["fraction"])
-
- try:
- checklist["fraction"] = sum(fracs) / len(fracs)
- except:
- checklist["fraction"] = 0.0
-
- # Sometime it was showing 99% when infect it's 100%
- if checklist["fraction"] == 0.9999:
- checklist["fraction"] = 1.0
-
-
- return checklist
- def get_fraction(win, path):
- ############################################################################
-
- # This function will return a fraction of a given checklist. It will ignore
- # complitelly what is the asset / shot / project the checklist is from.
-
- # For sake of making this function actually somewhat useful, aka not bloated3
- # I will use it to cashe the whole checklist data objects. So they could be
- # easily accesable later on.
-
- # This is usefull so I would not need to create 2 cash data structures. One
- # for fractions and for the checklists them selves.
-
- ############################################################################
-
-
- if path not in win.checklists:
-
- # Let's check if path exists in the project first.
-
- if os.path.exists(win.project+"/"+path):
- win.checklists[path] = get_list(win.project+"/"+path)
- else:
- win.checklists[path] = get_list(path)
-
-
- # Let's now return back the fraction
-
- return win.checklists[path]["fraction"]
- def get_task_by_path(tasks, path, p=[]):
-
- ############################################################################
-
- # This function will give the information about a given task from a non
- # recursive URL such as ["Task", "Sub-task", "Sub-task2"]. This will look
- # the recursive list and output the given task. In this case "Sub-task2"
- # with all the information inside it.
-
- ############################################################################
-
-
- for task in tasks:
-
- pa = p.copy()
- pa.append(" "+task["string"])
-
-
- if pa == path:
- return task
-
- if task["subtasks"]:
- t = get_task_by_path(task["subtasks"], path, pa)
- if t:
- return t
-
- return False
-
- def filter_tasks(data):
-
- ############################################################################
-
- # This function going to remove all selections and all edits from a given
- # checklist. This is nessesary for being able to select one task without
- # manually deselcting the other. And since the checklist is recursive it's
- # not a trivial task.
-
- ############################################################################
-
- data["selected"] = False
- data["editing"] = False
-
- if data["subtasks"]:
- for i in data["subtasks"]:
- filter_tasks(i)
-
-
- def save(path, data):
-
- ############################################################################
-
- # This funtion will save the checklist into a .progress file. Formatted
- # similarly as in the old Blender-Organizer. But as easy to understand.
- #
- # NOTE: I will remove some stuff from the file. Mainly the comments in the
- # beginning and the STR and END data. Which are no longer needed in a
- # VCStudio project.
- #
- # But since some part of Legacy Organizer relies on those, it's not adviced
- # to open the projects that you are planning to work on with Blender-Organizer
- # in VCStudio.
-
- ############################################################################
-
- indent = [0]
-
- lines = []
-
- def writetasks(tasks):
-
- for task in tasks:
- if task["fraction"] and not task["subtasks"]:
- v = "[V]"
- else:
- v = "[ ]"
-
- if task["open"]:
- o = " "
- else:
- o = "."
-
- lines.append(" "*indent[0]+v+o+task["string"])
-
- if task["subtasks"]:
- indent[0] = indent[0] + 4
- writetasks(task["subtasks"])
- indent[0] = indent[0] - 4
-
- writetasks(data["subtasks"])
- if path:
- # Writting to file
- w = open(path, "w")
-
- for i in lines:
- w.write(i+"\n")
-
- w.close()
- ret = ""
- for i in lines:
- ret = ret+"\n"+i
- ret = ret[1:]
- return ret
-
- def draw(outlayer, win, path, back="story_editor"):
-
- ############################################################################
-
- # This function will draw the checklists to the screen.
-
- # You probably noticed that there is no x, y, width or height values that
- # you can input. This due to one idea that I have in mind.
-
- # I'm planning to make scheduling a kind of interactive process rather then
- # a boring date selection. Something that's going to be somewhat fun to do.
-
- # The idea is to grab the task and to drug it outside the checklist. Which
- # will call for an analytics window to show up, where you can put the
- # schedules into a given date.
-
- # For this reason the checklist should always be in the same spot on the
- # screen. Which is a (window width) / 4 at the right side.
-
- ############################################################################
-
- if path not in win.checklists:
-
- # Let's check if path exists in the project first.
-
- if os.path.exists(win.project+"/"+path):
- win.checklists[path] = get_list(win.project+"/"+path)
- elif os.path.exists(win.project+"/rnd"+path):
- win.checklists[path] = get_list(win.project+"/rnd"+path)
- else:
- win.checklists[path] = get_list(path)
-
-
- x = win.current["w"] / 4 * 3 + 10
- y = 10
- width = win.current["w"] / 4 - 20
- height = win.current["h"] - 20
-
- # Now let's make a layer.
-
- # Making the layer
- surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, int(width), int(height))
- layer = cairo.Context(surface)
- layer.select_font_face("Monospace", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
-
- # Clip
- UI_elements.roundrect(layer, win,
- 0,
- 0,
- width,
- height,
- 10,
- fill=False)
- layer.clip()
-
-
-
- # Checklist icon.
- UI_color.set(layer, win, "node_background")
- UI_elements.roundrect(layer, win,
- 0,
- 0,
- width,
- 50,
- 10)
-
- UI_elements.image(layer, win,
- "settings/themes/"+win.settings["Theme"]+"/icons/checklist.png",
- 5, 5, 40, 40)
- # If not in the analytics window. I want to have a button to go to analyitcs.
- if win.url != "analytics":
- reducing = 60
- def do():
- win.cur = "/set"
- win.url = "analytics"
- UI_elements.roundrect(layer, win,
- width - 55,
- 5,
- 40,
- 40,
- 10,
- do,
- offset=[x,y],
- icon="analytics")
- else:
- reducing = 0
- # Fraction
-
- fraction = win.checklists[path]["fraction"]
-
- UI_color.set(layer, win, "progress_background")
- UI_elements.roundrect(layer, win,
- 50,
- 17,
- width - 60 -reducing,
- 0,
- 7)
-
- UI_color.set(layer, win, "progress_active")
- UI_elements.roundrect(layer, win,
- 50,
- 17,
- (width - 60 -reducing)*fraction,
- 0,
- 7)
-
- # Clip
- UI_elements.roundrect(layer, win,
- 0,
- 60,
- width,
- height,
- 10,
- fill=False)
- layer.clip()
-
-
- ###########################################################################
-
- # NOW THIS IS THE HARD RECURSION PART! THERE IS GOING TO BE SOME REDIC!
-
- ###########################################################################
-
- tileX = 0
- current_Y = 70
-
- # There is some bullshit regarding the Global variables. I gonna do a bit
- # trickier. Since lists are only links to lists. Let's do this.
-
- cXY = [tileX, current_Y]
-
- if "checklist" not in win.scroll:
- win.scroll["checklist"] = 0
-
- if "moving_task_now" not in win.current:
- win.current["moving_task_now"] = False
-
- def draw_tasks(tasks, cXY, schedulep):
-
-
-
- #########################################
- # #
- # THIS IS THE RECURSIVE FUNCTION #
- # #
- #########################################
-
- # I will try to explain what is going on here. But it will require me
- # understanding the code myself. And it's a bit redic. There was a hell
- # of a lot of copy-paste, edit value, continue.
-
- for num , task in enumerate(tasks):
-
- # This is the code that will be done for each task in the list. Or
- # subtask if a task have them.
-
- # Let's get a schedule path. A folder like structure.
- # Exacmple:
-
- # Instead of:
- # Task
- # Sub-Task
- # Sub-Task 2
-
- # We get:
- # [" Task", " Sub-Task", " Sub-Task 2"]
-
- schedulepath = schedulep.copy()
- schedulepath.append(" "+task["string"])
-
-
- ###### SCHEDULING STUFF BACKWARD ######
-
- # This is a set of stuff to make schedules work with checklists.
-
- if "schedule_task_selected" not in win.current:
- win.current["schedule_task_selected"] = False
-
- if win.current["schedule_task_selected"] and win.cur == win.current["schedule_task_selected"][-1]\
- or win.current["schedule_task_selected"] and win.cur == "/set" and win.current["schedule_task_selected"][-1] == "":
- csl = win.current["schedule_task_selected"][0][0][4]
-
-
- if " "+task["string"] in csl and not task["open"]:
- task["open"] = True
-
- if schedulepath == csl and not task["selected"]:
- filter_tasks(win.checklists[path])
- task["selected"] = True
- win.scroll["checklist"] = 0 - cXY[1] + height/2
-
-
- #### DELETE SHORT KEY ####
-
- # There is probably a reason to put it here. Probably something
- # breaks if you put it anywhere else. IDK actually. Test it. I
- # don't remember
-
- if 65535 in win.current["keys"] and task["selected"] and not win.current["schedule_task_selected"]:
- del tasks[num]
- win.current["keys"] = []
-
- # Saving
- save(path, win.checklists[path])
- win.story = story.load(win.project)
- win.checklists = {}
- win.assets = {}
- win.analytics = analytics.load(win.project)
- win.multiuser["last_request"] = ""
-
- #### THE GRABBING FUNCTION ####
-
- # This is the activation of the grab tool. It uses the same
- # win.current["tool"] = "grab" as the story editor. Because it makes
- # sense to reuse it if it already exists. For sake of conviniense.
-
- # It doesn't mean that it uses the same code. It's a bit different.
- # due to the nature of lists vs free positioning items.
-
- # Now let's set up a few positional variables. So I could move the tasks
- # while moving the currently selected task. And in the same time will not
- # screw the data.
-
- # So I copy the X and the Y locations like this.
-
- sx = cXY[0]
- sy = win.scroll["checklist"] + cXY[1]
-
- grabY = 40
- if task["subtasks"]:
- grabY = 60
-
- # Grab
- if win.current["LMB"]\
- and int(win.current["LMB"][0]) in range(int(x+sx), int(x+sx+width))\
- and int(win.current["LMB"][1]) in range(int(y+sy), int(y+sy+grabY))\
- and win.current["tool"] == "selection"\
- and int(win.current["LMB"][0]) not in range(int(win.current["mx"]-2), int(win.current["mx"]+2))\
- and int(win.current["LMB"][1]) not in range(int(win.current["my"]-2), int(win.current["my"]+2)):
-
- # So here we set up the grab tool and creating a little variable.
- # This variable (moving_task_now) will consist of 2 parts on release.
-
- # 1. The entire task ( with subtasks ) using pop. Which is not simply
- # a copy. But also removing the task from the checklist's list.
-
- # 2. The current frame of poping. So to offset insertion for 1 frame.
- # This insures that you insert the task in the correct spot.
-
- filter_tasks(win.checklists[path])
- task["selected"] = True
- win.current["schedule_task_selected"] = False
-
- win.current["tool"] = "grab"
- win.current["moving_task_now"] = False
-
- # Now let's actually setup the pop. So when the mouse is now pressed, but
- # was on a previous framae, and our current tool is grab.
-
- if not win.current["LMB"] and win.previous["LMB"] and win.current["tool"] == "grab"\
- and task["selected"]:
-
- # We remove the task from the list. And write it to the variable. With
- # the current frame.
-
- win.current["moving_task_now"] = [tasks.pop(num), win.current["frame"]]
-
-
-
- # Now I can touch the sx and sy without screwing up the cXY or scroll.
-
- thismoving = False # This is going to be True is this is the task that's
- # moving currently
- somemoving = False # This is going to be True if any task is moving
- someXY = [0,0] # And this is the mouse position translated to location
- # of the checklist. (x, y coordinates of the whole
- # widget). Or in other words position of the task.
-
- # Then comes some logic to determen those 3 values.
-
- if win.current["tool"] == "grab":
-
- # Okay so here. If grab first we assume that it's some other
- # task. And now currently selected one.
-
- somemoving = True
- someXY = [
- win.current["mx"]-x,
- win.current["my"]-y
- ]
-
- # Now this is the editing of the sx and sy values. To be at
- # the position of the mouse.
-
- if task["selected"]:
-
- # Calculating so the mouse will end up about in the centre
- # of the task while the task is at motion.
-
- sx = win.current["mx"] - x - (width - cXY[0])/2
- sy = win.current["my"] - y - 10
- task["open"] = False
- thismoving = True
- somemoving = False
-
- # Now if the mouse is outside the frame of the checklist
- # it will activate the scheduling.
-
- ############################################################
- # SCHEDULING PART #
- ############################################################
-
- if win.current["mx"] < x:
- win.url = "analytics"
- win.current["grab_data"] = [path, back, win.cur, schedulepath, win.settings["Username"]]
- win.current["tool"] = "schedule"
- #
- #
- #
- # SEE studio/studio_analyticsLayer.py
- # for more details about scheduling
- #
-
- # And if back into frame it will return to normal grab mode.
-
- elif win.current["tool"] == "schedule" and win.current["mx"] > x:
- win.url = back
- win.current["tool"] = "grab"
-
- ####################################################################
- # SCHEDULING PART END #
- ####################################################################
-
-
- inside = False
- between = False
-
- if sy-10 < someXY[1] < sy+10 and somemoving and not task["selected"]:
-
- if win.current["moving_task_now"] and win.current["moving_task_now"][1] != win.current["frame"]:
- tasks.insert(num, win.current["moving_task_now"][0])
- win.current["tool"] = "selection"
- win.current["LMB"] = False
- win.previous["LMB"] = False
-
- # Saving
- save(path, win.checklists[path])
- win.story = story.load(win.project)
- win.checklists = {}
- win.assets = {}
- win.analytics = analytics.load(win.project)
- win.multiuser["last_request"] = ""
-
- elif win.current["LMB"]:
-
- for line in range(int(cXY[0]/20)):
-
- line = line * 20 + 10
-
- UI_color.set(layer, win, "node_background")
- layer.move_to(line, win.scroll["checklist"] + cXY[1]-10)
- layer.line_to(line, win.scroll["checklist"] + cXY[1]+40)
- layer.stroke()
-
- cXY[1] = cXY[1] + 50
-
- sx = cXY[0]
- sy = win.scroll["checklist"] + cXY[1]
-
- between = True
- somemoving = False
-
- elif sy < someXY[1] < sy + 40 and somemoving and not task["selected"]:
-
- if win.current["moving_task_now"] and win.current["moving_task_now"][1] != win.current["frame"]:
- task["subtasks"].append(win.current["moving_task_now"][0])
- win.current["tool"] = "selection"
- win.current["LMB"] = False
- win.previous["LMB"] = False
-
- # Saving
- save(path, win.checklists[path])
- win.story = story.load(win.project)
- win.checklists = {}
- win.assets = {}
- win.analytics = analytics.load(win.project)
- win.multiuser["last_request"] = ""
-
- elif win.current["LMB"]:
- inside = True
-
- # Selection
- if win.textactive != "editing_task" and win.current["tool"] == "selection":
- def do():
- ed = task["selected"] and not task["editing"]
- filter_tasks(win.checklists[path])
- win.current["schedule_task_selected"] = False
- task["selected"] = True
- if ed:
- task["editing"] = True
- UI_elements.roundrect(layer, win,
- sx+40,
- sy,
- width - cXY[0]-40,
- grabY,
- 10,
- button=do,
- offset=[x,y],
- fill=False)
- layer.stroke()
-
- # Background
- if not task["subtasks"]:
- UI_color.set(layer, win, "node_background")
- if task["string"].startswith("#"):
- UI_color.set(layer, win, "dark_overdrop")
- UI_elements.roundrect(layer, win,
- sx,
- sy,
- width - cXY[0],
- 40,
- 10)
-
- if inside:
- UI_color.set(layer, win, "progress_background")
- UI_elements.roundrect(layer, win,
- sx,
- sy,
- width - cXY[0],
- 40,
- 10,
- fill=False)
- layer.stroke()
-
- if task["selected"]:
- UI_color.set(layer, win, "text_normal")
- UI_elements.roundrect(layer, win,
- sx,
- sy,
- width - cXY[0],
- 40,
- 10,
- fill=False)
- layer.stroke()
- # Line to see how deep you are in
-
- for line in range(int(cXY[0]/20)):
-
- line = line * 20 + 10
-
- UI_color.set(layer, win, "node_background")
- layer.move_to(line, win.scroll["checklist"] + cXY[1]-10)
- layer.line_to(line, win.scroll["checklist"] + cXY[1]+40)
- layer.stroke()
-
- if not task["string"].startswith("#"):
- if task["fraction"]:
- im = "checked"
- else:
- im = "unchecked"
-
- # CHECK BUTTON
-
- def do():
- # Before we overwrite the button
- before_star = win.analytics.get("star", 0)
-
- if task["fraction"]:
- task["fraction"] = 0.0
- history.record(win, path, "[Un-Checked]", schedulepath)
- win.textactive = ""
- try: del win.text["editing_task"]
- except: pass
- else:
- task["fraction"] = 1.0
- history.record(win, path, "[Checked]", schedulepath)
- win.textactive = ""
- try: del win.text["editing_task"]
- except: pass
-
- # Saving
- save(path, win.checklists[path])
- win.story = story.load(win.project)
- win.checklists = {}
- win.assets = {}
- win.multiuser["last_request"] = ""
- win.analytics = analytics.load(win.project)
- after_star = win.analytics.get("star", 0)
- # Calculating the amount got right
- difference = after_star - before_star
- positive = difference >= 0
- if positive:
- difference = "+" + str(round(difference*100,2))
- else:
- difference = str(round(difference*100,2))
- result = str(round(after_star*100, 2)) + "% ( "+difference+"% )"
- floaty_surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, int(len(result)*9+40), int(50))
- floaty_layer = cairo.Context(floaty_surface)
- floaty_layer.select_font_face("Monospace", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
-
-
- UI_color.set(floaty_layer, win, "node_background")
- UI_elements.roundrect(floaty_layer, win,
- 0,
- 0,
- int(len(result)*9+40),
- 50,
- 10)
- floaty_layer.select_font_face("Monospace", cairo.FONT_SLANT_NORMAL,
- cairo.FONT_WEIGHT_NORMAL)
- floaty_layer.set_font_size(15)
- UI_color.set(floaty_layer, win, "text_normal")
- if not positive:
- UI_color.set(floaty_layer, win, "node_badfile")
- floaty_layer.move_to(20,20)
- floaty_layer.show_text(result)
- UI_color.set(floaty_layer, win, "progress_background")
- UI_elements.roundrect(floaty_layer, win,
- 5,
- 35,
- int(len(result)*9+30),
- 10,
- 5)
- if positive:
- UI_color.set(floaty_layer, win, "progress_active")
- UI_elements.roundrect(floaty_layer, win,
- 5,
- 35,
- int(len(result)*9+30)*min(1,after_star),
- 10,
- 5)
- UI_color.set(floaty_layer, win, "text_link")
- UI_elements.roundrect(floaty_layer, win,
- 5,
- 35,
- int(len(result)*9+30)*min(1,before_star),
- 10,
- 5)
- else:
- UI_color.set(floaty_layer, win, "node_badfile")
- UI_elements.roundrect(floaty_layer, win,
- 5,
- 35,
- int(len(result)*9+30)*min(1,before_star),
- 10,
- 5)
- UI_color.set(floaty_layer, win, "text_link")
- UI_elements.roundrect(floaty_layer, win,
- 5,
- 35,
- int(len(result)*9+30)*min(1,after_star),
- 10,
- 5)
-
- floaty = {"fx":win.current["mx"],
- "fy":win.current["my"],
- "tx":win.current["w"]/2,
- "ty":0,
- "ff":win.current["frame"],
- "tf":win.current["frame"]+200,
- "sf":floaty_surface}
- win.floaters.append(floaty)
-
- UI_elements.roundrect(layer, win,
- sx,
- sy,
- 40,
- 40,
- 10,
- button=do,
- icon=im,
- offset=[x,y])
-
-
- else:
- UI_color.set(layer, win, "node_background")
- if task["string"].startswith("#"):
- UI_color.set(layer, win, "dark_overdrop")
- UI_elements.roundrect(layer, win,
- sx,
- sy,
- width - cXY[0],
- 60,
- 10)
-
- if inside:
- UI_color.set(layer, win, "progress_background")
- UI_elements.roundrect(layer, win,
- sx,
- sy,
- width - cXY[0],
- 60,
- 10,
- fill=False)
- layer.stroke()
-
-
- if task["selected"]:
- UI_color.set(layer, win, "text_normal")
- UI_elements.roundrect(layer, win,
- sx,
- sy,
- width - cXY[0],
- 60,
- 10,
- fill=False)
- layer.stroke()
-
- # Line to see how deep you are in
-
- for line in range(int(cXY[0]/20)):
-
- line = line * 20 + 10
-
- UI_color.set(layer, win, "node_background")
- layer.move_to(line, win.scroll["checklist"] + cXY[1]-10)
- layer.line_to(line, win.scroll["checklist"] + cXY[1]+60)
- layer.stroke()
-
- # Fraction
- if not task["string"].startswith("#"):
- fraction = task["fraction"]
-
- UI_color.set(layer, win, "progress_background")
- UI_elements.roundrect(layer, win,
- sx+10,
- sy+45,
- width-20 - cXY[0],
- 0,
- 5)
-
- UI_color.set(layer, win, "progress_active")
- UI_elements.roundrect(layer, win,
- sx+10,
- sy+45,
- (width -20 - cXY[0])*fraction,
- 0,
- 5)
-
- if task["open"]:
- im = "open"
- else:
- im = "closed"
-
- def do():
- task["open"] = not task["open"]
- win.current["schedule_task_selected"] = False
- # Saving
- save(path, win.checklists[path])
- win.multiuser["last_request"] = ""
-
- UI_elements.roundrect(layer, win,
- sx,
- sy,
- 40,
- 60,
- 10,
- button=do,
- icon=im,
- offset=[x,y])
-
-
-
-
- # TEXT
-
- # ECS
- if 65307 in win.current["keys"] and task["editing"]:
-
- # It's here because Text entry has it's own ESC
-
- win.textactive = ""
- task["editing"] = False
- del win.text["editing_task"]
- win.current["keys"] = []
-
- # Saving
- save(path, win.checklists[path])
- win.story = story.load(win.project)
- win.checklists = {}
- win.assets = {}
- win.analytics = analytics.load(win.project)
- win.multiuser["last_request"] = ""
-
- if not task["editing"]:
- layer.set_font_size(20)
- layer.move_to(
- sx+50,
- sy+25
- )
- if task["string"].startswith("#"):
- UI_color.set(layer, win, "progress_background")
- if not task["subtasks"]:
- layer.move_to(
- sx+10,
- sy+25
- )
- layer.show_text(task["string"][1:])
- else:
- UI_color.set(layer, win, "text_normal")
- layer.show_text(task["string"])
- else:
-
-
- UI_elements.text(layer, win, "editing_task",
- sx+39,
- sy,
- width - cXY[0] - 40,
- 40,
- set_text=task["string"],
- offset=[x,y])
-
- win.textactive = "editing_task"
-
- # Assigning the text
-
-
- def do():
- task["string"] = win.text["editing_task"]["text"]
- win.textactive = ""
- filter_tasks(win.checklists[path])
- del win.text["editing_task"]
-
- # Saving
- save(path, win.checklists[path])
- win.multiuser["last_request"] = ""
-
- def button():
- do()
- win.checklists = {}
- win.assets = {}
-
- UI_elements.roundrect(layer, win,
- sx+39 + width - cXY[0] - 80,
- sy,
- 40,
- 40,
- 10,
- button=button,
- icon="ok",
- tip=talk.text("checked"),
- offset=[x,y])
-
- # Enter
- if 65293 in win.current["keys"]:
- button()
- win.current["keys"] = []
-
-
- # Tab
- if 65289 in win.current["keys"]:
- do()
- tasks.append(
- {
- "fraction":0.0,
- "string":"",
- "editing":True,
- "selected":True,
- "open":False,
- "subtasks":[]
- }
- )
- win.current["keys"] = []
-
- # RECURSION
- if not thismoving:
- if not task["subtasks"]:
- cXY[1] = cXY[1] + 50
- else:
- cXY[1] = cXY[1] + 70
-
- cXY[0] = cXY[0] + 20
-
- # THERE IS YOUR RECURSION
-
- if task["open"]:
- draw_tasks(task["subtasks"], cXY, schedulepath)
-
- cXY[0] = cXY[0] - 20
-
- # Adding subtasks
-
- if ((task["subtasks"] and task["open"] and task["selected"])\
- or (task["selected"] and not task["subtasks"]))\
- and win.textactive != "editing_task"\
- and win.current["tool"] == "selection":
-
- cXY[0] = cXY[0] + 20
-
- def do():
- task["open"] = True
- filter_tasks(win.checklists[path])
- task["subtasks"].append(
- {
- "fraction":0.0,
- "string":"",
- "editing":True,
- "selected":True,
- "open":False,
- "subtasks":[]
- }
- )
-
-
- UI_elements.roundrect(layer, win,
- cXY[0],
- win.scroll["checklist"] + cXY[1],
- width - cXY[0],
- 40,
- 10,
- button=do,
- icon="new",
- offset=[x,y])
-
- UI_color.set(layer, win, "progress_background")
- UI_elements.roundrect(layer, win,
- cXY[0],
- win.scroll["checklist"] + cXY[1],
- width - cXY[0],
- 40,
- 10,
- fill=False)
- layer.stroke()
-
- layer.set_font_size(20)
- layer.move_to(
- cXY[0]+50,
- win.scroll["checklist"] + cXY[1]+25
- )
- layer.show_text(talk.text("add_new_subtask"))
-
- for line in range(int(cXY[0]/20)):
-
- line = line * 20 + 10
-
- UI_color.set(layer, win, "node_background")
- layer.move_to(line, win.scroll["checklist"] + cXY[1]-10)
- layer.line_to(line, win.scroll["checklist"] + cXY[1]+40)
- layer.stroke()
-
-
- cXY[0] = cXY[0] - 20
- cXY[1] = cXY[1] + 50
-
- schedulepath = []
- draw_tasks(win.checklists[path]["subtasks"], cXY, schedulepath)
-
- # Go to the bottom.
-
- if win.current["tool"] == "grab"\
- and win.current["my"] - y > win.scroll["checklist"] + cXY[1]:
-
- if win.current["moving_task_now"] and win.current["moving_task_now"][1] != win.current["frame"]:
- win.checklists[path]["subtasks"].append(win.current["moving_task_now"][0])
- win.current["tool"] = "selection"
- win.current["LMB"] = False
- win.previous["LMB"] = False
-
- # Saving
- save(path, win.checklists[path])
- win.story = story.load(win.project)
- win.checklists = {}
- win.assets = {}
- win.analytics = analytics.load(win.project)
- win.multiuser["last_request"] = ""
-
-
-
- # Adding a task.
- if win.textactive != "editing_task"\
- and win.current["tool"] == "selection":
- def do():
- filter_tasks(win.checklists[path])
- win.checklists[path]["subtasks"].append(
- {
- "fraction":0.0,
- "string":"",
- "editing":True,
- "selected":True,
- "open":False,
- "subtasks":[]
- }
- )
-
- UI_elements.roundrect(layer, win,
- cXY[0],
- win.scroll["checklist"] + cXY[1],
- width - cXY[0],
- 40,
- 10,
- button=do,
- icon="new",
- offset=[x,y])
-
- UI_color.set(layer, win, "progress_background")
- UI_elements.roundrect(layer, win,
- cXY[0],
- win.scroll["checklist"] + cXY[1],
- width - cXY[0],
- 40,
- 10,
- fill=False)
- layer.stroke()
-
- layer.set_font_size(20)
- layer.move_to(
- cXY[0]+50,
- win.scroll["checklist"] + cXY[1]+25
- )
- layer.show_text(talk.text("add_new_task"))
- cXY[1] = cXY[1] + 100
- def do():
- raw = save(False, win.checklists[path])
- clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
- clipboard.set_text( raw , -1)
-
- UI_elements.roundrect(layer, win,
- cXY[0],
- win.scroll["checklist"] + cXY[1],
- width - cXY[0],
- 40,
- 10,
- button=do,
- icon="copy_file",
- offset=[x,y])
-
- UI_color.set(layer, win, "progress_background")
- UI_elements.roundrect(layer, win,
- cXY[0],
- win.scroll["checklist"] + cXY[1],
- width - cXY[0],
- 40,
- 10,
- fill=False)
- layer.stroke()
-
- layer.set_font_size(20)
- layer.move_to(
- cXY[0]+50,
- win.scroll["checklist"] + cXY[1]+25
- )
- layer.show_text(talk.text("copy_checklist_to_clipboard"))
- cXY[1] = cXY[1] + 50
-
- def do():
- clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
- cliptext = str(clipboard.wait_for_text())
- savetext = ""
- for i in cliptext.split("\n"):
- if "[ ]" in i or "[V]" in i or "[v]" in i:
- savetext = savetext + "\n"+i.replace("[V]", "[ ]").replace("[v]", "[ ]")
- else:
- savetext = savetext + "\n[ ] #"+i
- cliptext = savetext[1:]
-
-
- s = open(path, 'ab')
- s.write(cliptext.encode("utf-8"))
- s.close()
- win.checklists[path] = get_list(path)
-
-
- UI_elements.roundrect(layer, win,
- cXY[0],
- win.scroll["checklist"] + cXY[1],
- width - cXY[0],
- 40,
- 10,
- button=do,
- icon="copy_file",
- offset=[x,y])
-
- UI_color.set(layer, win, "progress_background")
- UI_elements.roundrect(layer, win,
- cXY[0],
- win.scroll["checklist"] + cXY[1],
- width - cXY[0],
- 40,
- 10,
- fill=False)
- layer.stroke()
-
- layer.set_font_size(20)
- layer.move_to(
- cXY[0]+50,
- win.scroll["checklist"] + cXY[1]+25
- )
- layer.show_text(talk.text("copy_to_checklist_from_clipboard"))
-
-
-
- tileX, current_Y = cXY
-
- # So there would not be jumps of stuff. Let's add heigh to the scroll while
- # in grab.
- if win.current["tool"] == "grab":
- current_Y = current_Y + height
-
-
-
- # Outputting the layer
- outlayer.set_source_surface(surface, x, y)
- outlayer.paint()
-
- # Scroll
- UI_elements.scroll_area(outlayer, win, "checklist",
- x+0,
- y+50,
- width,
- height-50,
- current_Y,
- bar=True,
- mmb=True)
-
-
-
-
-
|