Skip to content

Commit

Permalink
Update SceneViewUI.py
Browse files Browse the repository at this point in the history
Added camera guide code.
  • Loading branch information
BrianHanke authored Oct 1, 2024
1 parent 0e9cc38 commit 89febdd
Showing 1 changed file with 86 additions and 0 deletions.
86 changes: 86 additions & 0 deletions python/GafferSceneUI/SceneViewUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,64 @@ def __menuDefinition( self ) :
}
)

# BHGC START

m.append( "/GuidesDivider", { "divider" : True } )

titleSafeEnabled = self.getPlug()["titleSafeEnabled"].getValue()
actionSafeEnabled = self.getPlug()["actionSafeEnabled"].getValue()
customGridEnabled = self.getPlug()["customGridEnabled"].getValue()

# possible way to iterate over all guides instead of doing them one by one:

# cameraGuides = self.getPlug()["guidesEnabled"].getValue()

# allGuides = [ "Title Safe", "Action Safe", "Rule of Thirds" ]
# for guide in allGuides :
# newGuides = IECore.StringVectorData( [
# g for g in allGuides
# if
# ( g == guide )
# ] )
# m.append(
# "/Guides/{}".format( guide ),
# {
# "checkBox" : cameraGuidesEnabled,
# #"active" : cameraGuidesEnabled,
# #"command" : functools.partial( self.getPlug()["cameraGuides"]["value"].setValue, newGuides ),
# "command" : functools.partial( Gaffer.WeakMethod( self.__enableGuides ), "" )
# }
# )

# doing them one by one for now (not sure if the "active" thing is needed):

m.append(
"/Guides/Action Safe",
{
"checkBox" : actionSafeEnabled,
# "active" : actionSafeEnabled,
"command" : functools.partial( Gaffer.WeakMethod( self.__enableActionSafe ), "" )
}
)
m.append(
"/Guides/Title Safe",
{
"checkBox" : titleSafeEnabled,
# "active" : titleSafeEnabled,
"command" : functools.partial( Gaffer.WeakMethod( self.__enableTitleSafe ), "" )
}
)
m.append(
"/Guides/Rule of Thirds",
{
"checkBox" : customGridEnabled,
# "active" : customGridEnabled,
"command" : functools.partial( Gaffer.WeakMethod( self.__enableCustomGrid ), "" )
}
)

# BHGC END

m.append( "/BrowseDivider", { "divider" : True } )

m.append(
Expand Down Expand Up @@ -835,6 +893,34 @@ def __lookThrough( self, path, *unused ) :

self.getPlug()["lookThroughEnabled"].setValue( True )
self.getPlug()["lookThroughCamera"].setValue( path )

# BHGC START

# separate functions for each guide, should probably combine these
# is there a better way to toggle than checking if off or on first?

def __enableTitleSafe( self, *unused ) :

if( self.getPlug()["titleSafeEnabled"].getValue() ) :
self.getPlug()["titleSafeEnabled"].setValue( False )
else :
self.getPlug()["titleSafeEnabled"].setValue( True )

def __enableActionSafe( self, *unused ) :

if( self.getPlug()["actionSafeEnabled"].getValue() ) :
self.getPlug()["actionSafeEnabled"].setValue( False )
else :
self.getPlug()["actionSafeEnabled"].setValue( True )

def __enableCustomGrid( self, *unused ) :

if( self.getPlug()["customGridEnabled"].getValue() ) :
self.getPlug()["customGridEnabled"].setValue( False )
else :
self.getPlug()["customGridEnabled"].setValue( True )

# BHGC END

def __browse( self ) :

Expand Down

0 comments on commit 89febdd

Please sign in to comment.