codis 1.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- codis-1.1.1.dist-info/METADATA +194 -0
- codis-1.1.1.dist-info/RECORD +329 -0
- codis-1.1.1.dist-info/WHEEL +5 -0
- codis-1.1.1.dist-info/entry_points.txt +5 -0
- codis-1.1.1.dist-info/licenses/LICENSE +21 -0
- codis-1.1.1.dist-info/top_level.txt +2 -0
- run.py +190 -0
- src/__init__.py +1 -0
- src/__main__.py +81 -0
- src/_app_build.py +1507 -0
- src/_app_editor.py +1274 -0
- src/_app_kui.py +825 -0
- src/_app_lsp.py +625 -0
- src/_app_recovery.py +189 -0
- src/_app_settings.py +1385 -0
- src/_app_tools.py +2471 -0
- src/_app_webpreview.py +126 -0
- src/_font_safety.py +127 -0
- src/_shells.py +172 -0
- src/app.py +1488 -0
- src/chat/__init__.py +1 -0
- src/chat/adapters/__init__.py +33 -0
- src/chat/adapters/base.py +209 -0
- src/chat/adapters/discord.py +190 -0
- src/chat/adapters/http.py +78 -0
- src/chat/adapters/irc.py +360 -0
- src/chat/adapters/matrix.py +219 -0
- src/chat/adapters/mattermost.py +178 -0
- src/chat/adapters/mqtt.py +165 -0
- src/chat/adapters/slack.py +204 -0
- src/chat/adapters/telegram.py +117 -0
- src/chat/adapters/ws.py +154 -0
- src/chat/adapters/xmpp.py +337 -0
- src/chat/history.py +76 -0
- src/chat/models.py +207 -0
- src/chat/probe.py +79 -0
- src/chat/session.py +446 -0
- src/chat/util.py +125 -0
- src/collab/__init__.py +1 -0
- src/collab/net.py +411 -0
- src/collab/ot.py +311 -0
- src/collab/session.py +141 -0
- src/collab/tk_adapter.py +134 -0
- src/config.py +335 -0
- src/constants.py +2552 -0
- src/dep_catalog.py +446 -0
- src/diff/__init__.py +1 -0
- src/diff/engine.py +247 -0
- src/dpi.py +30 -0
- src/editor/__init__.py +1 -0
- src/editor/_pane_lsp.py +2937 -0
- src/editor/_pane_utils.py +171 -0
- src/editor/autocomplete.py +607 -0
- src/editor/code_folding.py +836 -0
- src/editor/color_preview.py +382 -0
- src/editor/complexity_lens.py +281 -0
- src/editor/diff_pane.py +623 -0
- src/editor/file_watcher.py +144 -0
- src/editor/focus_block.py +236 -0
- src/editor/heatmap.py +141 -0
- src/editor/inlay_hints.py +366 -0
- src/editor/inline_blame.py +429 -0
- src/editor/kdocs.py +3376 -0
- src/editor/large_file.py +488 -0
- src/editor/ligatures.py +180 -0
- src/editor/line_numbers.py +598 -0
- src/editor/minimap.py +691 -0
- src/editor/multi_cursor.py +269 -0
- src/editor/pane.py +2082 -0
- src/editor/rhythm.py +206 -0
- src/editor/save_hooks.py +43 -0
- src/editor/smart_selection.py +425 -0
- src/editor/smart_tips.py +719 -0
- src/editor/snippets.py +411 -0
- src/editor/sticky_note_gutter.py +410 -0
- src/editor/sticky_scroll.py +385 -0
- src/editor/suggest.py +464 -0
- src/editor/text_transforms.py +310 -0
- src/editor/vim_mode.py +1074 -0
- src/events/__init__.py +84 -0
- src/events/bus.py +427 -0
- src/events/correlator.py +244 -0
- src/events/kinds.py +125 -0
- src/events/pipeline.py +264 -0
- src/events/stream.py +416 -0
- src/events/window.py +204 -0
- src/extcompat/__init__.py +19 -0
- src/extcompat/code/__init__.py +13 -0
- src/extcompat/code/consent.py +162 -0
- src/extcompat/code/host.py +353 -0
- src/extcompat/code/hosts/py_host.py +763 -0
- src/extcompat/code/locate.py +105 -0
- src/extcompat/code/manager.py +325 -0
- src/extcompat/code/permissions.py +154 -0
- src/extcompat/code/sandbox.py +60 -0
- src/extcompat/colors.py +131 -0
- src/extcompat/common.py +184 -0
- src/extcompat/cson.py +269 -0
- src/extcompat/formats/__init__.py +22 -0
- src/extcompat/formats/_tm.py +189 -0
- src/extcompat/formats/_util.py +31 -0
- src/extcompat/formats/base16.py +66 -0
- src/extcompat/formats/brackets.py +172 -0
- src/extcompat/formats/eclipse.py +193 -0
- src/extcompat/formats/emacs.py +361 -0
- src/extcompat/formats/geany.py +147 -0
- src/extcompat/formats/generic.py +184 -0
- src/extcompat/formats/gtksource.py +117 -0
- src/extcompat/formats/helix.py +91 -0
- src/extcompat/formats/jetbrains.py +343 -0
- src/extcompat/formats/kate.py +130 -0
- src/extcompat/formats/micro.py +131 -0
- src/extcompat/formats/nano.py +111 -0
- src/extcompat/formats/notepadpp.py +140 -0
- src/extcompat/formats/pulsar.py +165 -0
- src/extcompat/formats/pyides.py +163 -0
- src/extcompat/formats/sublime.py +340 -0
- src/extcompat/jsonc.py +65 -0
- src/extcompat/lessish.py +128 -0
- src/extcompat/manager.py +122 -0
- src/extcompat/market/__init__.py +63 -0
- src/extcompat/market/sources.py +211 -0
- src/extcompat/model.py +88 -0
- src/extcompat/net.py +228 -0
- src/extcompat/openvsx.py +63 -0
- src/extcompat/readers.py +362 -0
- src/extcompat/registry.py +73 -0
- src/extcompat/safexml.py +63 -0
- src/extcompat/sexp.py +187 -0
- src/extcompat/sources.py +105 -0
- src/extcompat/store.py +276 -0
- src/extcompat/textmate.py +214 -0
- src/extcompat/themes.py +487 -0
- src/extcompat/yamlite.py +294 -0
- src/fileio.py +94 -0
- src/fs_ops.py +106 -0
- src/i18n.py +233 -0
- src/ia/__init__.py +1 -0
- src/ia/actions.py +295 -0
- src/ia/approval_gate.py +672 -0
- src/ia/checkpoints.py +308 -0
- src/ia/context_builder.py +921 -0
- src/ia/dialdiff.py +408 -0
- src/ia/iaspace.py +2078 -0
- src/ia/pair.py +296 -0
- src/ia/providers.py +954 -0
- src/ia/session.py +335 -0
- src/ia/toolbox.py +2524 -0
- src/launcher_actions.py +204 -0
- src/lint/__init__.py +1 -0
- src/lint/manager.py +1058 -0
- src/locales/.translate_manifest.json +64170 -0
- src/locales/de.json +4936 -0
- src/locales/en.json +4936 -0
- src/locales/es.json +4936 -0
- src/locales/fr.json +4936 -0
- src/locales/it.json +4936 -0
- src/locales/ja.json +4936 -0
- src/locales/ko.json +4936 -0
- src/locales/nl.json +4936 -0
- src/locales/pl.json +4936 -0
- src/locales/pt-BR.json +4936 -0
- src/locales/ru.json +4936 -0
- src/locales/tr.json +4936 -0
- src/locales/uk.json +4936 -0
- src/locales/zh-CN.json +4936 -0
- src/lsp/__init__.py +26 -0
- src/lsp/client.py +2300 -0
- src/lsp/dap_client.py +480 -0
- src/lsp/edits.py +84 -0
- src/lsp/framing.py +73 -0
- src/lsp/protocol.py +931 -0
- src/main.py +260 -0
- src/memtrim.py +91 -0
- src/plugins/__init__.py +1 -0
- src/plugins/api.py +1761 -0
- src/plugins/loader.py +571 -0
- src/plugins/process_runner.py +519 -0
- src/plugins/registry.py +342 -0
- src/plugins/safety.py +367 -0
- src/plugins/startup.py +195 -0
- src/plugins/store.py +1178 -0
- src/proc_registry.py +278 -0
- src/pyexec.py +394 -0
- src/recovery.py +259 -0
- src/stall_trace.py +92 -0
- src/standalone.py +1070 -0
- src/startup_profile.py +35 -0
- src/syntax/__init__.py +1 -0
- src/syntax/highlighter.py +776 -0
- src/syntax/patterns.py +584 -0
- src/system_profile.py +430 -0
- src/terminal/backends.py +658 -0
- src/terminal/internal.py +346 -0
- src/terminal/keys.py +138 -0
- src/terminal/palette.py +67 -0
- src/terminal/session.py +283 -0
- src/terminal/shells.py +79 -0
- src/terminal/view.py +489 -0
- src/terminal/vt.py +870 -0
- src/textfmt.py +22 -0
- src/theme/__init__.py +1 -0
- src/theme/base.py +1281 -0
- src/theme/colors.py +49 -0
- src/theme/manager.py +602 -0
- src/theme/utils.py +312 -0
- src/toolbox.py +329 -0
- src/trash_core.py +531 -0
- src/ui/__init__.py +1 -0
- src/ui/_perf_utils.py +285 -0
- src/ui/_persistence_utils.py +93 -0
- src/ui/accessibility.py +843 -0
- src/ui/activity_bar.py +860 -0
- src/ui/app_embed.py +434 -0
- src/ui/archive_panel.py +608 -0
- src/ui/bookmarks.py +314 -0
- src/ui/breadcrumb.py +383 -0
- src/ui/calculator_panel.py +982 -0
- src/ui/calendar_panel.py +1218 -0
- src/ui/chat_panel.py +1271 -0
- src/ui/chat_profile_dialog.py +278 -0
- src/ui/chat_render.py +128 -0
- src/ui/clock_panel.py +810 -0
- src/ui/code_outline.py +364 -0
- src/ui/code_runner.py +729 -0
- src/ui/code_stats.py +546 -0
- src/ui/collab_panel.py +1009 -0
- src/ui/color_picker.py +547 -0
- src/ui/command_palette.py +452 -0
- src/ui/cursor_manager.py +750 -0
- src/ui/custom_keywords_panel.py +413 -0
- src/ui/debug_panel.py +1037 -0
- src/ui/dependency_graph.py +692 -0
- src/ui/diff_panel.py +381 -0
- src/ui/docs_panel.py +514 -0
- src/ui/doom_embed.py +349 -0
- src/ui/dropdown.py +321 -0
- src/ui/easter_eggs.py +979 -0
- src/ui/env_manager.py +666 -0
- src/ui/extcode_bridge.py +215 -0
- src/ui/extcode_dialogs.py +412 -0
- src/ui/extcompat_dialog.py +583 -0
- src/ui/file_timeline.py +319 -0
- src/ui/file_tree.py +1208 -0
- src/ui/find_in_files.py +1355 -0
- src/ui/flowchart_panel.py +727 -0
- src/ui/formatter_panel.py +490 -0
- src/ui/git_auth.py +763 -0
- src/ui/git_clone_dialog.py +487 -0
- src/ui/git_panel.py +1483 -0
- src/ui/grab_safe.py +84 -0
- src/ui/internal_python_dialog.py +98 -0
- src/ui/k_ui/__init__.py +1305 -0
- src/ui/k_ui/_bgrenderer.py +317 -0
- src/ui/k_ui/_colors.py +213 -0
- src/ui/k_ui/_dock.py +545 -0
- src/ui/k_ui/_easter.py +290 -0
- src/ui/k_ui/_engine.py +5448 -0
- src/ui/k_ui/_perf.py +333 -0
- src/ui/k_ui/_tkutil.py +7 -0
- src/ui/k_ui/_tooltip.py +365 -0
- src/ui/k_ui/_widgets.py +1204 -0
- src/ui/k_ui/_world.py +837 -0
- src/ui/key_remapper.py +856 -0
- src/ui/launcher.py +1252 -0
- src/ui/lazy_panel.py +73 -0
- src/ui/macro_recorder.py +610 -0
- src/ui/menu_bar.py +898 -0
- src/ui/output_panel.py +321 -0
- src/ui/paint_canvas.py +1000 -0
- src/ui/paint_engine.py +535 -0
- src/ui/paint_panel.py +888 -0
- src/ui/panel_detach.py +112 -0
- src/ui/performance_panel.py +861 -0
- src/ui/pip_manager.py +1758 -0
- src/ui/plugin_panel.py +1586 -0
- src/ui/pomodoro_panel.py +447 -0
- src/ui/problems.py +566 -0
- src/ui/process_manager.py +1657 -0
- src/ui/project_templates.py +775 -0
- src/ui/recovery_dialog.py +122 -0
- src/ui/regex_playground.py +304 -0
- src/ui/remote_adapters.py +1398 -0
- src/ui/remote_browser.py +1224 -0
- src/ui/remote_profile_dialog.py +342 -0
- src/ui/render_panel.py +1293 -0
- src/ui/rest_client.py +549 -0
- src/ui/scratchpad.py +548 -0
- src/ui/search_bar.py +1274 -0
- src/ui/settings_editor.py +3349 -0
- src/ui/settings_window.py +1554 -0
- src/ui/snippets_panel.py +597 -0
- src/ui/sql_studio.py +1815 -0
- src/ui/status_bar.py +438 -0
- src/ui/tab_bar.py +654 -0
- src/ui/task_manager.py +1773 -0
- src/ui/terminal.py +525 -0
- src/ui/theme_preview_panel.py +851 -0
- src/ui/thread_safe_tk.py +152 -0
- src/ui/time_tracker.py +574 -0
- src/ui/tkbind.py +43 -0
- src/ui/todo_panel.py +358 -0
- src/ui/toolbox_panels.py +658 -0
- src/ui/trash_manager.py +657 -0
- src/ui/ui_scale.py +294 -0
- src/ui/ux_enhancements.py +41 -0
- src/ui/web_preview.py +397 -0
- src/ui/webdev.py +630 -0
- src/ui/welcome.py +567 -0
- src/ui/window_embed.py +1500 -0
- src/ui/wizard.py +1550 -0
- src/ui/workspace_switcher.py +418 -0
- src/ui/workspace_trust.py +370 -0
- src/ui/zen_audio.py +354 -0
- src/ui/zen_media.py +2271 -0
- src/ui/zen_media_client.py +303 -0
- src/ui/zen_media_host.py +329 -0
- src/ui/zen_player.py +907 -0
- src/ui/zen_player_widgets.py +700 -0
- src/updater/__init__.py +11 -0
- src/updater/assets.py +145 -0
- src/updater/backup.py +101 -0
- src/updater/channel.py +221 -0
- src/updater/dialog.py +492 -0
- src/updater/integrity.py +111 -0
- src/updater/manager.py +727 -0
- src/updater/result.py +114 -0
- src/venv_runtime.py +531 -0
- src/workspace_state.py +25 -0
src/ui/cursor_manager.py
ADDED
|
@@ -0,0 +1,750 @@
|
|
|
1
|
+
"""Codis - Gerenciador de Cursor Customizável.
|
|
2
|
+
|
|
3
|
+
Permite substituir o ponteiro do mouse do sistema por um cursor de software:
|
|
4
|
+
emoji, texto, imagem (PNG/SVG via Pillow) ou combinações.
|
|
5
|
+
|
|
6
|
+
Como funciona:
|
|
7
|
+
- O cursor do sistema é ocultado (``root.config(cursor="none")``) na janela inteira.
|
|
8
|
+
- Um Toplevel transparente e clicável segue o mouse em tempo real.
|
|
9
|
+
- O Toplevel exibe o cursor escolhido como Label ou Canvas.
|
|
10
|
+
- Cliques atravessam normalmente (WM_EX_TRANSPARENT no Windows,
|
|
11
|
+
``-type splash`` / ``-alpha 0.01`` no Linux/Mac para passthrough).
|
|
12
|
+
|
|
13
|
+
Suporte por plataforma:
|
|
14
|
+
- Windows: transparência real via ``wm_attributes("-transparentcolor", ...)``
|
|
15
|
+
+ ``SetWindowLong`` para passthrough de eventos.
|
|
16
|
+
- Linux/macOS: Toplevel ultra-fino (1px) + ``wm_attributes("-alpha", 0.99)``.
|
|
17
|
+
|
|
18
|
+
Limitações:
|
|
19
|
+
- Emojis dependem da fonte disponível no SO.
|
|
20
|
+
- Imagens requerem Pillow (``pip install Pillow``).
|
|
21
|
+
- O cursor de software tem latência de ~1 frame (<=16ms) em relação ao real.
|
|
22
|
+
|
|
23
|
+
API pública:
|
|
24
|
+
mgr = CursorManager(root, tmgr, cfg)
|
|
25
|
+
mgr.set_cursor(CursorPreset.STAR) # predefinição
|
|
26
|
+
mgr.set_emoji("🔥") # emoji livre
|
|
27
|
+
mgr.set_image(Path("cursor.png"), size=32) # imagem
|
|
28
|
+
mgr.set_text("✦", color="#f9e2af") # texto customizado
|
|
29
|
+
mgr.set_system() # volta ao cursor do sistema
|
|
30
|
+
mgr.enable(True/False) # liga/desliga sem trocar preset
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
from __future__ import annotations
|
|
34
|
+
|
|
35
|
+
import contextlib
|
|
36
|
+
import logging
|
|
37
|
+
import sys
|
|
38
|
+
import tkinter as tk
|
|
39
|
+
from enum import StrEnum
|
|
40
|
+
from pathlib import Path
|
|
41
|
+
from typing import Any
|
|
42
|
+
|
|
43
|
+
from src.constants import FONT_UI
|
|
44
|
+
|
|
45
|
+
logger = logging.getLogger("Codis.CursorManager")
|
|
46
|
+
|
|
47
|
+
try:
|
|
48
|
+
from PIL import Image, ImageTk # type: ignore[import]
|
|
49
|
+
|
|
50
|
+
_HAS_PIL = True
|
|
51
|
+
except ImportError:
|
|
52
|
+
_HAS_PIL = False
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class CursorPreset(StrEnum):
|
|
56
|
+
"""Cursor predefinidos prontos para uso."""
|
|
57
|
+
|
|
58
|
+
SYSTEM = "system"
|
|
59
|
+
DOT = "dot"
|
|
60
|
+
CROSSHAIR = "crosshair"
|
|
61
|
+
STAR = "star"
|
|
62
|
+
HEART = "heart"
|
|
63
|
+
FIRE = "fire"
|
|
64
|
+
LIGHTNING = "lightning"
|
|
65
|
+
DIAMOND = "diamond"
|
|
66
|
+
ARROW_GLOW = "arrow_glow"
|
|
67
|
+
POINTER_HEX = "pointer_hex"
|
|
68
|
+
SKULL = "skull"
|
|
69
|
+
RAINBOW = "rainbow"
|
|
70
|
+
GHOST = "ghost"
|
|
71
|
+
SWORD = "sword"
|
|
72
|
+
MAGIC_WAND = "magic_wand"
|
|
73
|
+
ROBOT = "robot"
|
|
74
|
+
ALIEN = "alien"
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
_PRESET_DATA: dict[CursorPreset, tuple[str, int, str | None]] = {
|
|
78
|
+
CursorPreset.DOT: ("•", 14, None),
|
|
79
|
+
CursorPreset.CROSSHAIR: ("✛", 20, None),
|
|
80
|
+
CursorPreset.STAR: ("✦", 22, "#f9e2af"),
|
|
81
|
+
CursorPreset.HEART: ("♥", 22, "#f38ba8"),
|
|
82
|
+
CursorPreset.FIRE: ("🔥", 24, None),
|
|
83
|
+
CursorPreset.LIGHTNING: ("⚡", 24, None),
|
|
84
|
+
CursorPreset.DIAMOND: ("◆", 22, "#89dceb"),
|
|
85
|
+
CursorPreset.ARROW_GLOW: ("➤", 20, "#cba6f7"),
|
|
86
|
+
CursorPreset.POINTER_HEX: ("⬡", 22, "#89b4fa"),
|
|
87
|
+
CursorPreset.SKULL: ("💀", 24, None),
|
|
88
|
+
CursorPreset.RAINBOW: ("🌈", 24, None),
|
|
89
|
+
CursorPreset.GHOST: ("👻", 24, None),
|
|
90
|
+
CursorPreset.SWORD: ("⚔", 22, "#a6e3a1"),
|
|
91
|
+
CursorPreset.MAGIC_WAND: ("🪄", 24, None),
|
|
92
|
+
CursorPreset.ROBOT: ("🤖", 24, None),
|
|
93
|
+
CursorPreset.ALIEN: ("👽", 24, None),
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
class _SoftCursor:
|
|
98
|
+
"""Toplevel que segue o mouse exibindo o cursor escolhido."""
|
|
99
|
+
|
|
100
|
+
_POLL_MS = 8
|
|
101
|
+
|
|
102
|
+
def __init__(self, root: tk.Tk) -> None:
|
|
103
|
+
self._root = root
|
|
104
|
+
self._win: tk.Toplevel | None = None
|
|
105
|
+
self._label: tk.Label | None = None
|
|
106
|
+
self._canvas: tk.Canvas | None = None
|
|
107
|
+
self._photo: Any = None
|
|
108
|
+
self._job: str | None = None
|
|
109
|
+
self._active = False
|
|
110
|
+
self._offset_x = 0
|
|
111
|
+
self._offset_y = 0
|
|
112
|
+
|
|
113
|
+
def show(
|
|
114
|
+
self,
|
|
115
|
+
content: str | None,
|
|
116
|
+
size: int,
|
|
117
|
+
color: str,
|
|
118
|
+
image: Path | None,
|
|
119
|
+
offset: tuple[int, int],
|
|
120
|
+
) -> None:
|
|
121
|
+
"""Cria / atualiza o cursor de software."""
|
|
122
|
+
self._offset_x, self._offset_y = offset
|
|
123
|
+
self._destroy_win()
|
|
124
|
+
self._active = True
|
|
125
|
+
self._build_win(content, size, color, image)
|
|
126
|
+
if self._win is None:
|
|
127
|
+
self._active = False
|
|
128
|
+
return
|
|
129
|
+
self._poll()
|
|
130
|
+
|
|
131
|
+
def hide(self) -> None:
|
|
132
|
+
self._active = False
|
|
133
|
+
if self._job:
|
|
134
|
+
with contextlib.suppress(tk.TclError):
|
|
135
|
+
self._root.after_cancel(self._job)
|
|
136
|
+
self._job = None
|
|
137
|
+
self._destroy_win()
|
|
138
|
+
|
|
139
|
+
def _destroy_win(self) -> None:
|
|
140
|
+
if self._win:
|
|
141
|
+
with contextlib.suppress(tk.TclError):
|
|
142
|
+
self._win.destroy()
|
|
143
|
+
self._win = None
|
|
144
|
+
self._label = None
|
|
145
|
+
self._canvas = None
|
|
146
|
+
self._photo = None
|
|
147
|
+
|
|
148
|
+
def _build_win(
|
|
149
|
+
self, content: str | None, size: int, color: str, image: Path | None
|
|
150
|
+
) -> None:
|
|
151
|
+
win = tk.Toplevel(self._root)
|
|
152
|
+
win.wm_overrideredirect(True)
|
|
153
|
+
win.wm_attributes("-topmost", True)
|
|
154
|
+
win.wm_geometry("+9999+9999")
|
|
155
|
+
|
|
156
|
+
bg_key = "#010101"
|
|
157
|
+
win.config(bg=bg_key)
|
|
158
|
+
|
|
159
|
+
if image and _HAS_PIL and image.exists():
|
|
160
|
+
self._build_image(win, bg_key, image, size)
|
|
161
|
+
else:
|
|
162
|
+
self._build_text(win, bg_key, content or "✦", size, color)
|
|
163
|
+
|
|
164
|
+
self._win = win
|
|
165
|
+
|
|
166
|
+
if sys.platform == "win32":
|
|
167
|
+
with contextlib.suppress(tk.TclError):
|
|
168
|
+
win.wm_attributes("-transparentcolor", bg_key)
|
|
169
|
+
win.update_idletasks()
|
|
170
|
+
|
|
171
|
+
win.update_idletasks()
|
|
172
|
+
self._apply_click_passthrough(win)
|
|
173
|
+
else:
|
|
174
|
+
with contextlib.suppress(tk.TclError):
|
|
175
|
+
win.wm_attributes("-alpha", 0.99)
|
|
176
|
+
with contextlib.suppress(tk.TclError):
|
|
177
|
+
win.wm_attributes("-type", "splash")
|
|
178
|
+
|
|
179
|
+
def _apply_click_passthrough(self, win: tk.Toplevel) -> None:
|
|
180
|
+
"""Adiciona WS_EX_TRANSPARENT ao HWND real da janela (aditivo).
|
|
181
|
+
|
|
182
|
+
Lê o estilo estendido atual e apenas liga o bit WS_EX_TRANSPARENT,
|
|
183
|
+
sem reescrever WS_EX_LAYERED - esse já foi configurado pelo próprio
|
|
184
|
+
Tk ao aplicar -transparentcolor, e sobrescrevê-lo apagaria a
|
|
185
|
+
color-key (causa do "quadrado preto" sólido). Se a aplicação falhar,
|
|
186
|
+
a janela é destruída em vez de permanecer um overlay -topmost opaco
|
|
187
|
+
a cliques cobrindo a tela inteira - preferimos "sem cursor
|
|
188
|
+
customizado" a "app travado".
|
|
189
|
+
"""
|
|
190
|
+
try:
|
|
191
|
+
import ctypes
|
|
192
|
+
|
|
193
|
+
hwnd = int(win.winfo_id())
|
|
194
|
+
if not hwnd:
|
|
195
|
+
raise OSError("HWND inválido (0) após mapeamento da janela.")
|
|
196
|
+
GWL_EXSTYLE = -20
|
|
197
|
+
WS_EX_TRANSPARENT = 0x00000020
|
|
198
|
+
user32 = ctypes.WinDLL("user32", use_last_error=True)
|
|
199
|
+
old = user32.GetWindowLongW(hwnd, GWL_EXSTYLE)
|
|
200
|
+
if old & WS_EX_TRANSPARENT:
|
|
201
|
+
return
|
|
202
|
+
new = old | WS_EX_TRANSPARENT
|
|
203
|
+
ctypes.set_last_error(0)
|
|
204
|
+
user32.SetWindowLongW(hwnd, GWL_EXSTYLE, new)
|
|
205
|
+
confirm = user32.GetWindowLongW(hwnd, GWL_EXSTYLE)
|
|
206
|
+
if not confirm & WS_EX_TRANSPARENT:
|
|
207
|
+
raise OSError("WS_EX_TRANSPARENT não foi aplicado.")
|
|
208
|
+
except Exception as exc:
|
|
209
|
+
logger.warning(
|
|
210
|
+
"Cursor de software: passthrough de cliques falhou (%s). "
|
|
211
|
+
"Desativando overlay para evitar travamento da interface.",
|
|
212
|
+
exc,
|
|
213
|
+
)
|
|
214
|
+
self._destroy_win()
|
|
215
|
+
self._active = False
|
|
216
|
+
|
|
217
|
+
def _build_text(
|
|
218
|
+
self, win: tk.Toplevel, bg: str, text: str, size: int, color: str
|
|
219
|
+
) -> None:
|
|
220
|
+
lbl = tk.Label(
|
|
221
|
+
win,
|
|
222
|
+
text=text,
|
|
223
|
+
bg=bg,
|
|
224
|
+
fg=color,
|
|
225
|
+
font=(FONT_UI, size),
|
|
226
|
+
padx=0,
|
|
227
|
+
pady=0,
|
|
228
|
+
)
|
|
229
|
+
lbl.pack()
|
|
230
|
+
self._label = lbl
|
|
231
|
+
|
|
232
|
+
def _build_image(self, win: tk.Toplevel, bg: str, path: Path, size: int) -> None:
|
|
233
|
+
try:
|
|
234
|
+
img = Image.open(path).convert("RGBA")
|
|
235
|
+
resample = getattr(
|
|
236
|
+
Image, "LANCZOS", getattr(Image, "ANTIALIAS", 1))
|
|
237
|
+
img = img.resize((size, size), resample)
|
|
238
|
+
photo = ImageTk.PhotoImage(img)
|
|
239
|
+
self._photo = photo
|
|
240
|
+
lbl = tk.Label(win, image=photo, bg=bg, padx=0, pady=0)
|
|
241
|
+
lbl.pack()
|
|
242
|
+
self._label = lbl
|
|
243
|
+
except Exception as exc:
|
|
244
|
+
logger.warning("Imagem de cursor falhou: %s", exc)
|
|
245
|
+
self._build_text(win, bg, "✦", size, "#ffffff")
|
|
246
|
+
|
|
247
|
+
def _poll(self) -> None:
|
|
248
|
+
if not self._active:
|
|
249
|
+
return
|
|
250
|
+
if not self._win:
|
|
251
|
+
return
|
|
252
|
+
try:
|
|
253
|
+
x = self._root.winfo_pointerx() + self._offset_x
|
|
254
|
+
y = self._root.winfo_pointery() + self._offset_y
|
|
255
|
+
self._win.wm_geometry(f"+{x}+{y}")
|
|
256
|
+
except tk.TclError:
|
|
257
|
+
self._active = False
|
|
258
|
+
self._job = None
|
|
259
|
+
self._win = None
|
|
260
|
+
return
|
|
261
|
+
self._job = self._root.after(self._POLL_MS, self._poll)
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
class CursorManager:
|
|
265
|
+
"""Gerencia o cursor customizável para toda a janela do Codis."""
|
|
266
|
+
|
|
267
|
+
def __init__(self, root: tk.Tk, tmgr: Any, cfg: Any) -> None:
|
|
268
|
+
self._root = root
|
|
269
|
+
self._tmgr = tmgr
|
|
270
|
+
self._cfg = cfg
|
|
271
|
+
self._soft = _SoftCursor(root)
|
|
272
|
+
self._enabled = False
|
|
273
|
+
self._current_preset: str = CursorPreset.SYSTEM
|
|
274
|
+
self._current_emoji: str = "✦"
|
|
275
|
+
self._current_size: int = 22
|
|
276
|
+
self._current_color: str = "#cdd6f4"
|
|
277
|
+
self._current_image: Path | None = None
|
|
278
|
+
self._hotspot: tuple[int, int] = (0, 0)
|
|
279
|
+
|
|
280
|
+
self._load_from_cfg()
|
|
281
|
+
|
|
282
|
+
def set_system(self) -> None:
|
|
283
|
+
"""Restaura o cursor nativo do sistema operacional."""
|
|
284
|
+
self._enabled = False
|
|
285
|
+
self._current_preset = CursorPreset.SYSTEM
|
|
286
|
+
self._soft.hide()
|
|
287
|
+
self._restore_system_cursor()
|
|
288
|
+
self._save_cfg()
|
|
289
|
+
|
|
290
|
+
def set_preset(self, preset: CursorPreset | str) -> None:
|
|
291
|
+
"""Aplica uma das predefinições de cursor."""
|
|
292
|
+
preset = CursorPreset(preset) if isinstance(preset, str) else preset
|
|
293
|
+
self._current_preset = preset
|
|
294
|
+
if preset == CursorPreset.SYSTEM:
|
|
295
|
+
self.set_system()
|
|
296
|
+
return
|
|
297
|
+
emoji, size, color = _PRESET_DATA.get(preset, ("✦", 22, None))
|
|
298
|
+
color = color or self._tmgr.theme.fg
|
|
299
|
+
self._current_emoji = emoji
|
|
300
|
+
self._current_size = size
|
|
301
|
+
self._current_color = color
|
|
302
|
+
self._current_image = None
|
|
303
|
+
self._hotspot = (0, 0)
|
|
304
|
+
self._apply()
|
|
305
|
+
self._save_cfg()
|
|
306
|
+
|
|
307
|
+
def set_emoji(self, emoji: str, size: int = 22, color: str | None = None) -> None:
|
|
308
|
+
"""Define um emoji livre como cursor."""
|
|
309
|
+
self._current_preset = "__custom__"
|
|
310
|
+
self._current_emoji = emoji
|
|
311
|
+
self._current_size = size
|
|
312
|
+
self._current_color = color or self._tmgr.theme.fg
|
|
313
|
+
self._current_image = None
|
|
314
|
+
self._apply()
|
|
315
|
+
self._save_cfg()
|
|
316
|
+
|
|
317
|
+
def set_text(self, text: str, size: int = 20, color: str | None = None) -> None:
|
|
318
|
+
"""Define um caractere / símbolo Unicode como cursor."""
|
|
319
|
+
self.set_emoji(text, size, color)
|
|
320
|
+
|
|
321
|
+
def set_image(
|
|
322
|
+
self, path: Path | str, size: int = 32, hotspot: tuple[int, int] = (0, 0)
|
|
323
|
+
) -> None:
|
|
324
|
+
"""Define uma imagem (PNG, etc.) como cursor. Requer Pillow."""
|
|
325
|
+
path = Path(path)
|
|
326
|
+
if not _HAS_PIL:
|
|
327
|
+
logger.warning(
|
|
328
|
+
"Pillow não instalado - cursor de imagem indisponível.")
|
|
329
|
+
return
|
|
330
|
+
if not path.exists():
|
|
331
|
+
logger.warning("Imagem de cursor não encontrada: %s", path)
|
|
332
|
+
return
|
|
333
|
+
self._current_preset = "__image__"
|
|
334
|
+
self._current_image = path
|
|
335
|
+
self._current_size = size
|
|
336
|
+
self._hotspot = hotspot
|
|
337
|
+
self._apply()
|
|
338
|
+
self._save_cfg()
|
|
339
|
+
|
|
340
|
+
def enable(self, on: bool) -> None:
|
|
341
|
+
"""Liga ou desliga o cursor customizado sem alterar o preset."""
|
|
342
|
+
if on:
|
|
343
|
+
if self._current_preset in (CursorPreset.SYSTEM, "__none__"):
|
|
344
|
+
return
|
|
345
|
+
self._apply()
|
|
346
|
+
else:
|
|
347
|
+
self._soft.hide()
|
|
348
|
+
self._restore_system_cursor()
|
|
349
|
+
self._enabled = on
|
|
350
|
+
|
|
351
|
+
@property
|
|
352
|
+
def current_preset(self) -> str:
|
|
353
|
+
return self._current_preset
|
|
354
|
+
|
|
355
|
+
def _apply(self) -> None:
|
|
356
|
+
self._hide_system_cursor()
|
|
357
|
+
self._soft.show(
|
|
358
|
+
content=self._current_emoji,
|
|
359
|
+
size=self._current_size,
|
|
360
|
+
color=self._current_color,
|
|
361
|
+
image=self._current_image,
|
|
362
|
+
offset=self._hotspot,
|
|
363
|
+
)
|
|
364
|
+
self._enabled = True
|
|
365
|
+
|
|
366
|
+
def _hide_system_cursor(self) -> None:
|
|
367
|
+
"""Oculta o cursor em todos os widgets da janela (inclusive filhos).
|
|
368
|
+
|
|
369
|
+
root.config(cursor="none") não propaga para widgets que definem seu
|
|
370
|
+
próprio cursor. Percorremos a árvore inteira e forçamos "none" em
|
|
371
|
+
cada widget - guardando o valor original para restauração posterior.
|
|
372
|
+
"""
|
|
373
|
+
self._original_cursors: dict[str, str] = {}
|
|
374
|
+
with contextlib.suppress(tk.TclError):
|
|
375
|
+
self._set_cursor_recursive(self._root, "none")
|
|
376
|
+
|
|
377
|
+
def _restore_system_cursor(self) -> None:
|
|
378
|
+
saved = getattr(self, "_original_cursors", {})
|
|
379
|
+
with contextlib.suppress(tk.TclError):
|
|
380
|
+
if saved:
|
|
381
|
+
for widget_path, orig in saved.items():
|
|
382
|
+
with contextlib.suppress(tk.TclError, KeyError):
|
|
383
|
+
w = self._root.nametowidget(widget_path)
|
|
384
|
+
w.config(cursor=orig)
|
|
385
|
+
self._original_cursors = {}
|
|
386
|
+
else:
|
|
387
|
+
self._root.config(cursor="")
|
|
388
|
+
|
|
389
|
+
def _set_cursor_recursive(self, widget: tk.Widget, cursor: str) -> None:
|
|
390
|
+
"""Aplica *cursor* em *widget* e em todos os seus descendentes."""
|
|
391
|
+
with contextlib.suppress(tk.TclError):
|
|
392
|
+
try:
|
|
393
|
+
orig = widget.cget("cursor")
|
|
394
|
+
except tk.TclError:
|
|
395
|
+
orig = ""
|
|
396
|
+
path = str(widget)
|
|
397
|
+
if path not in self._original_cursors:
|
|
398
|
+
self._original_cursors[path] = orig
|
|
399
|
+
widget.config(cursor=cursor)
|
|
400
|
+
for child in widget.winfo_children():
|
|
401
|
+
self._set_cursor_recursive(child, cursor)
|
|
402
|
+
|
|
403
|
+
def _save_cfg(self) -> None:
|
|
404
|
+
with contextlib.suppress(Exception):
|
|
405
|
+
self._cfg.set("cursor_preset", self._current_preset)
|
|
406
|
+
self._cfg.set("cursor_emoji", self._current_emoji)
|
|
407
|
+
self._cfg.set("cursor_size", self._current_size)
|
|
408
|
+
self._cfg.set("cursor_color", self._current_color)
|
|
409
|
+
|
|
410
|
+
def _load_from_cfg(self) -> None:
|
|
411
|
+
preset = self._cfg.get("cursor_preset", CursorPreset.SYSTEM)
|
|
412
|
+
if preset == CursorPreset.SYSTEM:
|
|
413
|
+
return
|
|
414
|
+
self._current_emoji = self._cfg.get("cursor_emoji", "✦")
|
|
415
|
+
self._current_size = self._cfg.get("cursor_size", 22)
|
|
416
|
+
self._current_color = self._cfg.get("cursor_color", "#cdd6f4")
|
|
417
|
+
with contextlib.suppress(Exception):
|
|
418
|
+
self._apply()
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
class CursorPickerPanel(tk.Frame):
|
|
422
|
+
"""Painel visual para escolher e personalizar o cursor."""
|
|
423
|
+
|
|
424
|
+
def __init__(self, parent: tk.Widget, mgr: CursorManager, tmgr: Any) -> None:
|
|
425
|
+
t = tmgr.theme
|
|
426
|
+
super().__init__(parent, bg=t.panel_bg)
|
|
427
|
+
self._mgr = mgr
|
|
428
|
+
self._tmgr = tmgr
|
|
429
|
+
self._build(t)
|
|
430
|
+
|
|
431
|
+
def _build(self, t) -> None:
|
|
432
|
+
for child in self.winfo_children():
|
|
433
|
+
with contextlib.suppress(tk.TclError):
|
|
434
|
+
child.destroy()
|
|
435
|
+
|
|
436
|
+
hdr = tk.Frame(self, bg=t.panel_bg)
|
|
437
|
+
hdr.pack(fill="x", padx=16, pady=(14, 4))
|
|
438
|
+
tk.Label(
|
|
439
|
+
hdr,
|
|
440
|
+
text="🖱 Cursor Customizável",
|
|
441
|
+
bg=t.panel_bg,
|
|
442
|
+
fg=t.fg,
|
|
443
|
+
font=(FONT_UI, 11, "bold"),
|
|
444
|
+
anchor="w",
|
|
445
|
+
).pack(side="left")
|
|
446
|
+
|
|
447
|
+
self._status_var = tk.StringVar(value=self._status_text())
|
|
448
|
+
tk.Label(
|
|
449
|
+
hdr,
|
|
450
|
+
textvariable=self._status_var,
|
|
451
|
+
bg=t.panel_bg,
|
|
452
|
+
fg=t.fg_muted,
|
|
453
|
+
font=(FONT_UI, 8),
|
|
454
|
+
anchor="e",
|
|
455
|
+
).pack(side="right")
|
|
456
|
+
|
|
457
|
+
tk.Frame(self, bg=t.border, height=1).pack(fill="x", padx=16)
|
|
458
|
+
|
|
459
|
+
tk.Label(
|
|
460
|
+
self,
|
|
461
|
+
text=" Predefinições",
|
|
462
|
+
bg=t.panel_bg,
|
|
463
|
+
fg=t.fg_muted,
|
|
464
|
+
font=(FONT_UI, 8, "bold"),
|
|
465
|
+
anchor="w",
|
|
466
|
+
).pack(fill="x", padx=16, pady=(10, 2))
|
|
467
|
+
|
|
468
|
+
grid_frame = tk.Frame(self, bg=t.panel_bg)
|
|
469
|
+
grid_frame.pack(fill="x", padx=12, pady=(0, 8))
|
|
470
|
+
|
|
471
|
+
presets = [
|
|
472
|
+
(CursorPreset.SYSTEM, "⬚ Sistema"),
|
|
473
|
+
(CursorPreset.DOT, "• Ponto"),
|
|
474
|
+
(CursorPreset.CROSSHAIR, "✛ Mira"),
|
|
475
|
+
(CursorPreset.STAR, "✦ Estrela"),
|
|
476
|
+
(CursorPreset.HEART, "♥ Coração"),
|
|
477
|
+
(CursorPreset.FIRE, "🔥 Fogo"),
|
|
478
|
+
(CursorPreset.LIGHTNING, "⚡ Raio"),
|
|
479
|
+
(CursorPreset.DIAMOND, "◆ Diamante"),
|
|
480
|
+
(CursorPreset.ARROW_GLOW, "➤ Seta"),
|
|
481
|
+
(CursorPreset.POINTER_HEX, "⬡ Hex"),
|
|
482
|
+
(CursorPreset.SKULL, "💀 Caveira"),
|
|
483
|
+
(CursorPreset.GHOST, "👻 Fantasma"),
|
|
484
|
+
(CursorPreset.SWORD, "⚔ Espada"),
|
|
485
|
+
(CursorPreset.MAGIC_WAND, "🪄 Varinha"),
|
|
486
|
+
(CursorPreset.ROBOT, "🤖 Robô"),
|
|
487
|
+
(CursorPreset.ALIEN, "👽 Alien"),
|
|
488
|
+
]
|
|
489
|
+
|
|
490
|
+
cols = 4
|
|
491
|
+
for i, (preset, label) in enumerate(presets):
|
|
492
|
+
row, col = divmod(i, cols)
|
|
493
|
+
is_active = self._mgr.current_preset == preset
|
|
494
|
+
btn = tk.Frame(
|
|
495
|
+
grid_frame,
|
|
496
|
+
bg=t.sel_bg if is_active else t.sidebar_bg,
|
|
497
|
+
cursor="hand2",
|
|
498
|
+
highlightthickness=1,
|
|
499
|
+
highlightbackground=(
|
|
500
|
+
getattr(t, "accent", t.border) if is_active else t.border
|
|
501
|
+
),
|
|
502
|
+
)
|
|
503
|
+
btn.grid(row=row, column=col, padx=4, pady=4, sticky="ew")
|
|
504
|
+
grid_frame.columnconfigure(col, weight=1)
|
|
505
|
+
|
|
506
|
+
tk.Label(
|
|
507
|
+
btn,
|
|
508
|
+
text=label,
|
|
509
|
+
bg=t.sel_bg if is_active else t.sidebar_bg,
|
|
510
|
+
fg=t.sel_fg if is_active else t.fg,
|
|
511
|
+
font=(FONT_UI, 9),
|
|
512
|
+
anchor="w",
|
|
513
|
+
padx=8,
|
|
514
|
+
pady=6,
|
|
515
|
+
cursor="hand2",
|
|
516
|
+
).pack(fill="x")
|
|
517
|
+
|
|
518
|
+
def _pick(p=preset, b=btn):
|
|
519
|
+
self._mgr.set_preset(p)
|
|
520
|
+
self._status_var.set(self._status_text())
|
|
521
|
+
self.after_idle(lambda: self._build(self._tmgr.theme))
|
|
522
|
+
|
|
523
|
+
btn.bind("<Button-1>", lambda _e, fn=_pick: fn())
|
|
524
|
+
for child in btn.winfo_children():
|
|
525
|
+
child.bind("<Button-1>", lambda _e, fn=_pick: fn())
|
|
526
|
+
|
|
527
|
+
tk.Frame(self, bg=t.border, height=1).pack(
|
|
528
|
+
fill="x", padx=16, pady=(4, 8))
|
|
529
|
+
|
|
530
|
+
tk.Label(
|
|
531
|
+
self,
|
|
532
|
+
text=" Emoji ou símbolo customizado",
|
|
533
|
+
bg=t.panel_bg,
|
|
534
|
+
fg=t.fg_muted,
|
|
535
|
+
font=(FONT_UI, 8, "bold"),
|
|
536
|
+
anchor="w",
|
|
537
|
+
).pack(fill="x", padx=16, pady=(0, 4))
|
|
538
|
+
|
|
539
|
+
custom_row = tk.Frame(self, bg=t.panel_bg)
|
|
540
|
+
custom_row.pack(fill="x", padx=16, pady=(0, 8))
|
|
541
|
+
|
|
542
|
+
self._emoji_var = tk.StringVar(value=self._mgr._current_emoji)
|
|
543
|
+
tk.Entry(
|
|
544
|
+
custom_row,
|
|
545
|
+
textvariable=self._emoji_var,
|
|
546
|
+
bg=t.editor_bg,
|
|
547
|
+
fg=t.fg,
|
|
548
|
+
insertbackground=t.cursor,
|
|
549
|
+
font=(FONT_UI, 16),
|
|
550
|
+
width=4,
|
|
551
|
+
relief="flat",
|
|
552
|
+
highlightthickness=1,
|
|
553
|
+
highlightbackground=t.border,
|
|
554
|
+
).pack(side="left", padx=(0, 8))
|
|
555
|
+
|
|
556
|
+
tk.Label(
|
|
557
|
+
custom_row, text="Tamanho:", bg=t.panel_bg, fg=t.fg_muted, font=(FONT_UI, 9)
|
|
558
|
+
).pack(side="left")
|
|
559
|
+
self._size_var = tk.IntVar(value=self._mgr._current_size)
|
|
560
|
+
tk.Spinbox(
|
|
561
|
+
custom_row,
|
|
562
|
+
from_=10,
|
|
563
|
+
to=64,
|
|
564
|
+
textvariable=self._size_var,
|
|
565
|
+
bg=t.editor_bg,
|
|
566
|
+
fg=t.fg,
|
|
567
|
+
buttonbackground=t.sidebar_bg,
|
|
568
|
+
width=4,
|
|
569
|
+
font=(FONT_UI, 9),
|
|
570
|
+
relief="flat",
|
|
571
|
+
).pack(side="left", padx=(4, 12))
|
|
572
|
+
|
|
573
|
+
tk.Label(
|
|
574
|
+
custom_row, text="Cor:", bg=t.panel_bg, fg=t.fg_muted, font=(FONT_UI, 9)
|
|
575
|
+
).pack(side="left")
|
|
576
|
+
self._color_var = tk.StringVar(value=self._mgr._current_color)
|
|
577
|
+
color_entry = tk.Entry(
|
|
578
|
+
custom_row,
|
|
579
|
+
textvariable=self._color_var,
|
|
580
|
+
bg=t.editor_bg,
|
|
581
|
+
fg=t.fg,
|
|
582
|
+
insertbackground=t.cursor,
|
|
583
|
+
font=(FONT_UI, 9),
|
|
584
|
+
width=9,
|
|
585
|
+
relief="flat",
|
|
586
|
+
highlightthickness=1,
|
|
587
|
+
highlightbackground=t.border,
|
|
588
|
+
)
|
|
589
|
+
color_entry.pack(side="left", padx=(4, 8))
|
|
590
|
+
|
|
591
|
+
self._preview_box = tk.Label(
|
|
592
|
+
custom_row,
|
|
593
|
+
text=" ",
|
|
594
|
+
bg=self._mgr._current_color,
|
|
595
|
+
width=2,
|
|
596
|
+
relief="flat",
|
|
597
|
+
cursor="hand2",
|
|
598
|
+
)
|
|
599
|
+
self._preview_box.pack(side="left", padx=(0, 8))
|
|
600
|
+
self._preview_box.bind("<Button-1>", self._pick_color)
|
|
601
|
+
self._color_var.trace_add("write", self._on_color_change)
|
|
602
|
+
|
|
603
|
+
tk.Button(
|
|
604
|
+
custom_row,
|
|
605
|
+
text="Aplicar",
|
|
606
|
+
bg=getattr(t, "accent", t.sel_bg),
|
|
607
|
+
fg=t.sel_fg if hasattr(t, "sel_fg") else "#ffffff",
|
|
608
|
+
font=(FONT_UI, 9),
|
|
609
|
+
relief="flat",
|
|
610
|
+
cursor="hand2",
|
|
611
|
+
command=self._apply_custom,
|
|
612
|
+
padx=10,
|
|
613
|
+
).pack(side="left")
|
|
614
|
+
|
|
615
|
+
if _HAS_PIL:
|
|
616
|
+
tk.Frame(self, bg=t.border, height=1).pack(
|
|
617
|
+
fill="x", padx=16, pady=(4, 8))
|
|
618
|
+
tk.Label(
|
|
619
|
+
self,
|
|
620
|
+
text=" Cursor de imagem (PNG / WebP / GIF)",
|
|
621
|
+
bg=t.panel_bg,
|
|
622
|
+
fg=t.fg_muted,
|
|
623
|
+
font=(FONT_UI, 8, "bold"),
|
|
624
|
+
anchor="w",
|
|
625
|
+
).pack(fill="x", padx=16, pady=(0, 4))
|
|
626
|
+
|
|
627
|
+
img_row = tk.Frame(self, bg=t.panel_bg)
|
|
628
|
+
img_row.pack(fill="x", padx=16, pady=(0, 8))
|
|
629
|
+
|
|
630
|
+
self._img_var = tk.StringVar(
|
|
631
|
+
value=str(
|
|
632
|
+
self._mgr._current_image) if self._mgr._current_image else ""
|
|
633
|
+
)
|
|
634
|
+
tk.Entry(
|
|
635
|
+
img_row,
|
|
636
|
+
textvariable=self._img_var,
|
|
637
|
+
bg=t.editor_bg,
|
|
638
|
+
fg=t.fg,
|
|
639
|
+
insertbackground=t.cursor,
|
|
640
|
+
font=(FONT_UI, 9),
|
|
641
|
+
relief="flat",
|
|
642
|
+
highlightthickness=1,
|
|
643
|
+
highlightbackground=t.border,
|
|
644
|
+
).pack(side="left", fill="x", expand=True, padx=(0, 8))
|
|
645
|
+
|
|
646
|
+
tk.Button(
|
|
647
|
+
img_row,
|
|
648
|
+
text="Procurar…",
|
|
649
|
+
bg=t.sidebar_bg,
|
|
650
|
+
fg=t.fg,
|
|
651
|
+
font=(FONT_UI, 9),
|
|
652
|
+
relief="flat",
|
|
653
|
+
cursor="hand2",
|
|
654
|
+
command=self._browse_image,
|
|
655
|
+
padx=8,
|
|
656
|
+
).pack(side="left", padx=(0, 4))
|
|
657
|
+
|
|
658
|
+
tk.Button(
|
|
659
|
+
img_row,
|
|
660
|
+
text="Usar imagem",
|
|
661
|
+
bg=getattr(t, "accent", t.sel_bg),
|
|
662
|
+
fg=t.sel_fg if hasattr(t, "sel_fg") else "#ffffff",
|
|
663
|
+
font=(FONT_UI, 9),
|
|
664
|
+
relief="flat",
|
|
665
|
+
cursor="hand2",
|
|
666
|
+
command=self._apply_image,
|
|
667
|
+
padx=8,
|
|
668
|
+
).pack(side="left")
|
|
669
|
+
else:
|
|
670
|
+
tk.Label(
|
|
671
|
+
self,
|
|
672
|
+
text=" ℹ Instale Pillow para usar cursores de imagem: pip install Pillow",
|
|
673
|
+
bg=t.panel_bg,
|
|
674
|
+
fg=t.fg_muted,
|
|
675
|
+
font=(FONT_UI, 8),
|
|
676
|
+
anchor="w",
|
|
677
|
+
).pack(fill="x", padx=16, pady=4)
|
|
678
|
+
|
|
679
|
+
tk.Frame(self, bg=t.border, height=1).pack(
|
|
680
|
+
fill="x", padx=16, pady=(4, 8))
|
|
681
|
+
footer = tk.Frame(self, bg=t.panel_bg)
|
|
682
|
+
footer.pack(fill="x", padx=16, pady=(0, 12))
|
|
683
|
+
tk.Button(
|
|
684
|
+
footer,
|
|
685
|
+
text="↩ Restaurar cursor do sistema",
|
|
686
|
+
bg=t.sidebar_bg,
|
|
687
|
+
fg=t.fg_muted,
|
|
688
|
+
font=(FONT_UI, 9),
|
|
689
|
+
relief="flat",
|
|
690
|
+
cursor="hand2",
|
|
691
|
+
command=self._reset,
|
|
692
|
+
padx=10,
|
|
693
|
+
).pack(side="left")
|
|
694
|
+
|
|
695
|
+
def _status_text(self) -> str:
|
|
696
|
+
p = self._mgr.current_preset
|
|
697
|
+
if p == CursorPreset.SYSTEM:
|
|
698
|
+
return "Sistema (padrão)"
|
|
699
|
+
if p == "__image__":
|
|
700
|
+
img = self._mgr._current_image
|
|
701
|
+
return f"Imagem: {img.name if img else '?'}"
|
|
702
|
+
emoji = self._mgr._current_emoji
|
|
703
|
+
return f"Cursor: {emoji} · {self._mgr._current_size}px"
|
|
704
|
+
|
|
705
|
+
def _on_color_change(self, *_) -> None:
|
|
706
|
+
color = self._color_var.get()
|
|
707
|
+
with contextlib.suppress(tk.TclError):
|
|
708
|
+
self._preview_box.config(bg=color)
|
|
709
|
+
|
|
710
|
+
def _pick_color(self, _e=None) -> None:
|
|
711
|
+
from tkinter import colorchooser
|
|
712
|
+
|
|
713
|
+
result = colorchooser.askcolor(
|
|
714
|
+
title="Cor do cursor",
|
|
715
|
+
color=self._color_var.get(),
|
|
716
|
+
parent=self,
|
|
717
|
+
)
|
|
718
|
+
if result and result[1]:
|
|
719
|
+
self._color_var.set(result[1])
|
|
720
|
+
|
|
721
|
+
def _apply_custom(self) -> None:
|
|
722
|
+
emoji = self._emoji_var.get().strip() or "✦"
|
|
723
|
+
size = max(10, min(64, self._size_var.get()))
|
|
724
|
+
color = self._color_var.get().strip() or "#cdd6f4"
|
|
725
|
+
self._mgr.set_emoji(emoji, size, color)
|
|
726
|
+
self._status_var.set(self._status_text())
|
|
727
|
+
|
|
728
|
+
def _browse_image(self) -> None:
|
|
729
|
+
from tkinter import filedialog
|
|
730
|
+
|
|
731
|
+
p = filedialog.askopenfilename(
|
|
732
|
+
title="Selecionar imagem de cursor",
|
|
733
|
+
filetypes=[
|
|
734
|
+
("Imagens", "*.png *.webp *.gif *.bmp *.jpg *.jpeg *.ico"),
|
|
735
|
+
("Todos", "*.*"),
|
|
736
|
+
],
|
|
737
|
+
)
|
|
738
|
+
if p:
|
|
739
|
+
self._img_var.set(p)
|
|
740
|
+
|
|
741
|
+
def _apply_image(self) -> None:
|
|
742
|
+
path = self._img_var.get().strip()
|
|
743
|
+
if path:
|
|
744
|
+
self._mgr.set_image(Path(path), size=32)
|
|
745
|
+
self._status_var.set(self._status_text())
|
|
746
|
+
|
|
747
|
+
def _reset(self) -> None:
|
|
748
|
+
self._mgr.set_system()
|
|
749
|
+
self._status_var.set(self._status_text())
|
|
750
|
+
self.after_idle(lambda: self._build(self._tmgr.theme))
|