Skip to content

Commit

Permalink
#3 customizing work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
nishimotz committed May 12, 2019
1 parent 8316b41 commit 7654514
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 18 deletions.
88 changes: 71 additions & 17 deletions addon/globalPlugins/focusHighlight.py
@@ -1,27 +1,29 @@
# focus highlight
# 2019-05-03
# 2019-05-12
# Takuya Nishimoto

import os
import sys
import threading
import time
from ctypes import (WINFUNCTYPE, FormatError, GetLastError, Structure,
WinError, byref, c_char, c_char_p, c_float, c_int, c_long,
c_uint, c_uint32, c_ulong, c_void_p, pointer, windll)
from ctypes.wintypes import BOOL, COLORREF
try:
from ctypes import POINTER
except:
from ctypes.wintypes import POINTER
from io import BytesIO

import api
import config
import configobj
import controlTypes
import globalPluginHandler
import globalVars
import gui
import oleacc
import speech
import tones
import ui
import validate
import virtualBuffers
import winUser
import wx
Expand All @@ -35,6 +37,12 @@
WS_CAPTION, WS_DISABLED, WS_EX_APPWINDOW, WS_EX_LAYERED,
WS_EX_TOOLWINDOW, WS_EX_TRANSPARENT, WS_POPUP,
WS_VISIBLE)

try:
from ctypes import POINTER
except:
from ctypes.wintypes import POINTER

try:
from windowUtils import physicalToLogicalPoint
except:
Expand Down Expand Up @@ -175,20 +183,51 @@ def makeARGB(a,r,g,b):
transColor.value = TRANS_RGB
transBrush = windll.gdi32.CreateSolidBrush(transColor)

CONFIG_FILENAME = 'focusHighlight.ini'
path = os.path.join(globalVars.appArgs.configPath, CONFIG_FILENAME)
config = configobj.ConfigObj(path, configspec=BytesIO(b"""
[passthrough]
color = string(min=6, default='2222ff')
dashStyle = integer(default=2)
thickness = integer(default=12)
[focus]
color = string(min=6, default='ff0000')
dashStyle = integer(default=0)
thickness = integer(default=6)
[navigator]
color = string(min=6, default='00ff00')
dashStyle = integer(default=3)
thickness = integer(default=4)
""")
)
config.validate(validate.Validator(), copy=True)
config.filename = path
config.write()


def getConfigARGB(category):
color = config[category]['color']
r = int(color[0:2], 16)
g = int(color[2:4], 16)
b = int(color[4:6], 16)
return makeARGB(255, r, g, b)

# focus (passthrough)
ptARGB = makeARGB(255, 0x22, 0x22, 0xff)
ptDashStyle = 2
ptThickness = 6
#ptARGB = makeARGB(255, 0x22, 0x22, 0xff)
#ptDashStyle = 2
#ptThickness = 6

# focus
fcARGB = makeARGB(255, 0xff, 0x00, 0x00)
fcDashStyle = 0
fcThickness = 6
#fcARGB = makeARGB(255, 0xff, 0x00, 0x00)
#fcDashStyle = 0
#fcThickness = 6

# navigator
navARGB = makeARGB(255, 0x00, 0xff, 0x00)
navDashStyle = 3
navThickness = 4
#navARGB = makeARGB(255, 0x00, 0xff, 0x00)
#navDashStyle = 3
#navThickness = 4

PADDING_THIN = 10
PADDING_THICK = 5
Expand Down Expand Up @@ -333,9 +372,19 @@ def doPaint(hwnd):
if currentAppSleepMode:
pass
elif passThroughMode:
argb, dashStyle, thickness, padding = ptARGB, ptDashStyle, ptThickness, PADDING_THICK
argb, dashStyle, thickness, padding = (
getConfigARGB('passthrough'),
config['passthrough']['dashStyle'],
config['passthrough']['thickness'],
PADDING_THICK
)
else:
argb, dashStyle, thickness, padding = fcARGB, fcDashStyle, fcThickness, PADDING_THICK
argb, dashStyle, thickness, padding = (
getConfigARGB('focus'),
config['focus']['dashStyle'],
config['focus']['thickness'],
PADDING_THICK
)
if rectEquals(focusRect, navigatorRect):
if not passThroughMode and thickness is not None:
thickness *= 2
Expand All @@ -346,7 +395,12 @@ def doPaint(hwnd):
elif rectEquals(focusRect, navigatorRect):
pass
else:
argb, dashStyle, thickness, padding = navARGB, navDashStyle, navThickness, PADDING_THIN
argb, dashStyle, thickness, padding = (
getConfigARGB('navigator'),
config['navigator']['dashStyle'],
config['navigator']['thickness'],
PADDING_THIN
)

if argb is None:
windll.user32.EndPaint(c_int(hwnd), byref(ps))
Expand Down
2 changes: 1 addition & 1 deletion buildVars.py
Expand Up @@ -19,7 +19,7 @@
# Translators: Long description to be shown for this add-on on add-on information from add-ons manager
"addon_description" : _("Highlight the focused location."),
# version
"addon_version" : "6.0",
"addon_version" : "6.1",
# Author(s)
"addon_author" : u"Takuya Nishimoto <nishimotz@gmail.com>",
# URL for the add-on documentation support
Expand Down

0 comments on commit 7654514

Please sign in to comment.