Skip to content

Commit

Permalink
fixed color picker bugs
Browse files Browse the repository at this point in the history
1) fixed bug where color picker couldn't be tapped out of the normal way.

2) fixed bug where second color picker when editing s/v would jump to hue of last color parameter.
  • Loading branch information
EnviralDesign committed Apr 29, 2021
1 parent d3e4393 commit 449688c
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 6 deletions.
Binary file modified UGV4.tox
Binary file not shown.
Binary file modified UberGui_V4_Release.toe
Binary file not shown.
59 changes: 57 additions & 2 deletions python/UG4.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import json
import traceback
import traceback, inspect

class UG4:

Expand All @@ -22,6 +22,8 @@ def __init__(self, ownerComp):
self.fieldCOMP = op('field')
self.menuCOMP = op('menu')
self.colorpickerCOMP = op('colorpicker')
self.nonDragTypes = [ '_cp', '_fp', '_mp', ]
self.nonTapHoldTypes = [ '_cp', '_fp', '_mp', ]


def Regenerate(self, SRC ):
Expand Down Expand Up @@ -1071,6 +1073,9 @@ def Interact_Touch_Tap( self , action , u , v ):
if ScrollContext == 'scroll':

if action == 'down':
pikStr = self.webInfo['title',1].val
pikDict = self.ParseTitle(pikStr)
ipar.Widget.Pikdict = pikDict
self.Interact_Hover( 0 , u , v )
# pass

Expand Down Expand Up @@ -1647,4 +1652,54 @@ def SetMode_Mouse(self):

def SetMode_Touch(self):
if self.ownerComp.par.Inputmode.eval() != 'touch':
self.ownerComp.par.Inputmode = 'touch'
self.ownerComp.par.Inputmode = 'touch'

def IsDraggable(self, parName):
'''
things like color pickers, menu pickers, etc are not draggable.
this function expects the full par name returned from ubergui, with suffix and all.
this will be tested against a list of pre determined suffixes.
'''
return not max( [ parName.endswith(x) for x in self.nonDragTypes ] )

def IsTapHoldable(self, parName):
'''
things like color pickers, menu pickers, etc are not tap holdable.
this function expects the full par name returned from ubergui, with suffix and all.
this will be tested against a list of pre determined suffixes.
'''
return not max( [ parName.endswith(x) for x in self.nonTapHoldTypes ] )

def TraceFunctionCall( self ):
'''
This function will print the entire function call's stack trace showing what called what where.
Obviously if you use scriptDat.run() it will break the function call chain.
'''
inspectedStack = inspect.stack()

source = []
line = []
function = []
for f in inspectedStack[::-1]:
frameInfo = inspect.getframeinfo(f[0])
source += [frameInfo[0]]
line += [str(frameInfo[1])]
function += [frameInfo[2]]

source_max = max( [len(x) for x in source] )
line_max = max( [len(x) for x in line] )
function_max = max( [len(x) for x in function] )

print('-'*(source_max+line_max+function_max+11))

for i,f in enumerate(zip(source,line,function)):
f = list(f)
source_ = f[0].ljust(source_max)
line_ = f[1].ljust(line_max)
function_ = (f[2]+'()').ljust(function_max)

print('%i) %s : %s : %s'%(i,source_,line_,function_))

print('-'*(source_max+line_max+function_max+11))

return
17 changes: 14 additions & 3 deletions python/colorpicker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ class colorpicker:
def __init__(self, ownerComp):
# The component to which this extension is attached
self.ownerComp = ownerComp
self.hsvChop = op('null_hsv')
self.hsvDat = op('table_hsv')
self.h_comp = op('hue')
self.sv_comp = op('hue')


def Launch(self, OPS , PAR, LEFT, RIGHT, BOTTOM, TOP):
Expand All @@ -17,9 +21,17 @@ def Launch(self, OPS , PAR, LEFT, RIGHT, BOTTOM, TOP):

parent.colorpicker.par.display = 1

# parent.colorpicker.store('isModified' , 0)
ipar.Widget.Ismodified = 0



self.hsvChop.cook(force=True)
h = self.hsvChop['h']
s = self.hsvChop['s']
v = self.hsvChop['v']
self.hsvDat['h',1] = h
self.hsvDat['s',1] = s
self.hsvDat['v',1] = v

parent.Widget.op('container_foreground_focus').par.display = 1


Expand All @@ -42,7 +54,6 @@ def Close(self):

parent.Widget.ParamChange(pars=initPars)

# parent.colorpicker.store('isModified' , 0)
ipar.Widget.Ismodified = 0

parent.Widget.op('container_foreground_focus').par.display = 0
Expand Down
7 changes: 6 additions & 1 deletion python/field.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


paramInfo = parent.Widget.op('null_paramInfo')

class field:
Expand Down Expand Up @@ -168,6 +170,9 @@ def Delayed_Close(self):

def Close(self):
# triggered if user cancels field interaction.

parent.field.par.display = 0
parent.Widget.par.Fieldmode = 0
parent.Widget.op('container_foreground_focus').par.display = 0
parent.Widget.op('container_foreground_focus').par.display = 0

# TraceFunctionCall()

0 comments on commit 449688c

Please sign in to comment.