Cursors change based on content
This commit is contained in:
Jeison Yehuda Amihud (Blender Dumbass) 2021-01-11 20:52:00 +00:00
parent ba704aa24c
commit 92533b7236
4 changed files with 43 additions and 3 deletions

View file

@ -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"

View file

@ -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":
@ -360,6 +362,8 @@ def scene_node(outlayer, win, x, y, width, height, name="Unknown", fraction=0.0)
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])\
@ -710,6 +714,8 @@ def link_node(outlayer, win, x, y, width=150, height=150, name="", num=0, linkty
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])\

View file

@ -1146,6 +1146,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.

View file

@ -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"
@ -1182,6 +1194,8 @@ def layer(win):
if savenow:
win.current["cursor"] = win.cursors["watch"]
# Now let's run the history record.
story.undo_record(win)