From 92533b7236f3b485c473b30b893a3fbf33b65115 Mon Sep 17 00:00:00 2001 From: "Jeison Yehuda Amihud (Blender Dumbass)" Date: Mon, 11 Jan 2021 20:52:00 +0000 Subject: [PATCH] Cursors Cursors change based on content --- studio/studio_gtk.py | 15 +++++++++++++++ studio/studio_nodes.py | 10 ++++++++-- studio/studio_scriptLayer.py | 5 +++++ studio/studio_storyLayer.py | 16 +++++++++++++++- 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/studio/studio_gtk.py b/studio/studio_gtk.py index 8271277..8a0ebf9 100644 --- a/studio/studio_gtk.py +++ b/studio/studio_gtk.py @@ -8,6 +8,7 @@ import datetime import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk +from gi.repository import Gdk import cairo import datetime import threading @@ -152,6 +153,7 @@ def run(project, win): win.current["script_find"] = [0,0] win.current["camera_arrived"] = False + if "pointers" not in win.story: win.story["pointers"] = {} # List of text pointers per scene @@ -236,6 +238,16 @@ def pmdrawing(pmdrawing, main_layer, win): win.current['w'] = win.get_size()[0] win.current['h'] = win.get_size()[1] + + win.cursors = { + "arrow":Gdk.Cursor.new(Gdk.CursorType.ARROW), + "watch":Gdk.Cursor.new(Gdk.CursorType.WATCH), + "text" :Gdk.Cursor.new(Gdk.CursorType.XTERM), + "hand" :Gdk.Cursor.new(Gdk.CursorType.HAND1), + "cross":Gdk.Cursor.new(Gdk.CursorType.CROSS) + } + win.current["cursor"] = win.cursors["arrow"] + # Attemt to make things straight when pressing Ctrl. if 65507 in win.current["keys"] and win.current["LMB"]: @@ -355,6 +367,9 @@ def pmdrawing(pmdrawing, main_layer, win): main_layer.set_source_surface(layer, 0 , 0) main_layer.paint() + + win.get_root_window().set_cursor(win.current["cursor"]) + # If you press ESC you get back from any window to the main menu. if 65307 in win.current["keys"] and win.url != "install_updates": win.url = "story_editor" diff --git a/studio/studio_nodes.py b/studio/studio_nodes.py index eed1502..d9fb0e7 100644 --- a/studio/studio_nodes.py +++ b/studio/studio_nodes.py @@ -66,6 +66,8 @@ def node_dot(layer, win, x, y, direction="in", entry="end"): fill=False) layer.stroke() + win.current["cursor"] = win.cursors["arrow"] + # Start drawing the line if not win.previous["LMB"] and win.current["LMB"] and direction != "in": @@ -359,7 +361,9 @@ def scene_node(outlayer, win, x, y, width, height, name="Unknown", fraction=0.0) # Launching the item if int(win.current["mx"]) in range(int(x), int(x+width))\ and int(win.current["my"]) in range(int(y), int(y+height)): - + + win.current["cursor"] = win.cursors["hand"] + if not win.current["LMB"] and win.previous["LMB"]\ and entry in win.story["selected"]\ and int(win.current["mx"]) == int(win.previous["LMB"][0])\ @@ -709,7 +713,9 @@ def link_node(outlayer, win, x, y, width=150, height=150, name="", num=0, linkty # Launching the item if int(win.current["mx"]) in range(int(x), int(x+width))\ and int(win.current["my"]) in range(int(y), int(y+height)): - + + win.current["cursor"] = win.cursors["hand"] + if not win.current["LMB"] and win.previous["LMB"]\ and entry in win.story["selected"]\ and int(win.current["mx"]) == int(win.previous["LMB"][0])\ diff --git a/studio/studio_scriptLayer.py b/studio/studio_scriptLayer.py index 3d78b95..66de164 100644 --- a/studio/studio_scriptLayer.py +++ b/studio/studio_scriptLayer.py @@ -1145,6 +1145,11 @@ def layer(win): win.cur = "/"+scene win.textactive = "" + + if int(win.current["my"]) in range(int(y+win.scroll["script"] + current_Y), int(y+win.scroll["script"] + current_Y)+25)\ + and int(win.current["mx"]-x) in range(tileX, tileX+len(word)*12+12): + + win.current["cursor"] = win.cursors["text"] # This is the logic to draw our selection and logic that # come with the selection. diff --git a/studio/studio_storyLayer.py b/studio/studio_storyLayer.py index dcea13e..eed8ab1 100644 --- a/studio/studio_storyLayer.py +++ b/studio/studio_storyLayer.py @@ -768,6 +768,14 @@ def layer(win): stf = datetime.datetime.now() ################################################################### + if win.url == "story_editor"\ + and int(win.current["mx"]) in range(50, int(win.current["w"]-50)) \ + and int(win.current["my"]) in range(50, int(win.current["h"]-30)): + + # The cross cursor + win.current["cursor"] = win.cursors["cross"] + + ####### NODES ####### # Clipping so it wont draw beyon the frame @@ -1099,6 +1107,8 @@ def layer(win): fill=False) layer.stroke() + win.current["cursor"] = win.cursors["arrow"] + if win.current["LMB"] and not win.previous["LMB"]: win.current["tool"] = "scale" @@ -1127,6 +1137,8 @@ def layer(win): if win.current["tool"] == "connect": + win.current["cursor"] = win.cursors["arrow"] + if not win.current["LMB"]: win.current["tool"] = "selection" @@ -1181,7 +1193,9 @@ def layer(win): savenow = True if savenow: - + + win.current["cursor"] = win.cursors["watch"] + # Now let's run the history record. story.undo_record(win)