renderCursor renders the cursor on or off, as a sprite that is either on or off
(on bool)
| 84 | |
| 85 | // renderCursor renders the cursor on or off, as a sprite that is either on or off |
| 86 | func (ed *Editor) renderCursor(on bool) { |
| 87 | if ed == nil || ed.This == nil { |
| 88 | return |
| 89 | } |
| 90 | if !on { |
| 91 | if ed.Scene == nil { |
| 92 | return |
| 93 | } |
| 94 | ms := ed.Scene.Stage.Main |
| 95 | if ms == nil { |
| 96 | return |
| 97 | } |
| 98 | spnm := ed.cursorSpriteName() |
| 99 | ms.Sprites.InactivateSprite(spnm) |
| 100 | return |
| 101 | } |
| 102 | if !ed.IsVisible() { |
| 103 | return |
| 104 | } |
| 105 | if ed.renders == nil { |
| 106 | return |
| 107 | } |
| 108 | ed.cursorMu.Lock() |
| 109 | defer ed.cursorMu.Unlock() |
| 110 | |
| 111 | sp := ed.cursorSprite(on) |
| 112 | if sp == nil { |
| 113 | return |
| 114 | } |
| 115 | sp.Geom.Pos = ed.charStartPos(ed.CursorPos).ToPointFloor() |
| 116 | } |
| 117 | |
| 118 | // cursorSpriteName returns the name of the cursor sprite |
| 119 | func (ed *Editor) cursorSpriteName() string { |
no test coverage detected