Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StandardPathColumn, IconPathColumn : Support full CellData in header #5584

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,15 @@ Fixes
API
---

- PathColumn : Added `CellData::sortValue` member, to provide additional control over sorting in the PathListingWidget.
- PathColumn :
- Added `CellData::sortValue` member, to provide additional control over sorting in the PathListingWidget.
- Added missing Python binding for `headerData()` method.
- StandardPathColumn :
- Added constructor which allows the full header CellData to be specified.
- Added missing Python binding for `property()` method.
- IconPathColumn :
- Added constructor which allows the full header CellData to be specified.
- Added `prefix()` and `property()` accessors.
- LocalDispatcher :
- Added `Job.status()` and `Job.statusChangedSignal()` methods.
- Added `Job.messages()` and `Job.messagesChangedSignal()` methods.
Expand Down
9 changes: 7 additions & 2 deletions include/GafferUI/PathColumn.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ class GAFFERUI_API StandardPathColumn : public PathColumn
IE_CORE_DECLAREMEMBERPTR( StandardPathColumn )

StandardPathColumn( const std::string &label, IECore::InternedString property, PathColumn::SizeMode sizeMode = Default );
StandardPathColumn( const CellData &headerData, IECore::InternedString property, PathColumn::SizeMode sizeMode = Default );

IECore::InternedString property() const;

Expand All @@ -187,7 +188,7 @@ class GAFFERUI_API StandardPathColumn : public PathColumn

private :

IECore::ConstStringDataPtr m_label;
const CellData m_headerData;
IECore::InternedString m_property;

};
Expand All @@ -209,13 +210,17 @@ class GAFFERUI_API IconPathColumn : public PathColumn
/// - IntData, UInt44Data
/// - BoolData
IconPathColumn( const std::string &label, const std::string &prefix, IECore::InternedString property, PathColumn::SizeMode sizeMode = Default );
IconPathColumn( const CellData &headerData, const std::string &prefix, IECore::InternedString property, PathColumn::SizeMode sizeMode = Default );

const std::string &prefix() const;
IECore::InternedString property() const;

CellData cellData( const Gaffer::Path &path, const IECore::Canceller *canceller ) const override;
CellData headerData( const IECore::Canceller *canceller ) const override;

private :

IECore::ConstStringDataPtr m_label;
const CellData m_headerData;
std::string m_prefix;
IECore::InternedString m_property;

Expand Down
34 changes: 34 additions & 0 deletions python/GafferUITest/PathColumnTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,39 @@ def testSizeMode( self ) :
p.setSizeMode( GafferUI.PathColumn.SizeMode.Interactive )
self.assertEqual( p.getSizeMode(), GafferUI.PathColumn.SizeMode.Interactive )

def testStandardPathColumnConstructors( self ) :

c = GafferUI.StandardPathColumn( "label", "property" )
self.assertEqual( c.property(), "property" )
self.assertEqual( c.getSizeMode(), GafferUI.PathColumn.SizeMode.Default )
self.assertEqual( c.headerData().value, "label" )

c = GafferUI.StandardPathColumn(
GafferUI.PathColumn.CellData( value = "label", toolTip = "help!" ),
"property", GafferUI.PathColumn.SizeMode.Stretch
)
self.assertEqual( c.property(), "property" )
self.assertEqual( c.getSizeMode(), GafferUI.PathColumn.SizeMode.Stretch )
self.assertEqual( c.headerData().value, "label" )
self.assertEqual( c.headerData().toolTip, "help!" )

def testIconPathColumnConstructors( self ) :

c = GafferUI.IconPathColumn( "label", "prefix", "property" )
self.assertEqual( c.prefix(), "prefix" )
self.assertEqual( c.property(), "property" )
self.assertEqual( c.getSizeMode(), GafferUI.PathColumn.SizeMode.Default )
self.assertEqual( c.headerData().value, "label" )

c = GafferUI.IconPathColumn(
GafferUI.PathColumn.CellData( value = "label", toolTip = "help!" ),
"prefix", "property", GafferUI.PathColumn.SizeMode.Stretch
)
self.assertEqual( c.prefix(), "prefix" )
self.assertEqual( c.property(), "property" )
self.assertEqual( c.getSizeMode(), GafferUI.PathColumn.SizeMode.Stretch )
self.assertEqual( c.headerData().value, "label" )
self.assertEqual( c.headerData().toolTip, "help!" )

if __name__ == "__main__":
unittest.main()
28 changes: 24 additions & 4 deletions src/GafferUI/PathColumn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,12 @@ PathColumn::ButtonSignal &PathColumn::buttonDoubleClickSignal()
//////////////////////////////////////////////////////////////////////////

StandardPathColumn::StandardPathColumn( const std::string &label, IECore::InternedString property, SizeMode sizeMode )
: PathColumn( sizeMode ), m_label( new IECore::StringData( label ) ), m_property( property )
: StandardPathColumn( CellData( new StringData( label ) ), property, sizeMode )
{
}

StandardPathColumn::StandardPathColumn( const CellData &headerData, IECore::InternedString property, PathColumn::SizeMode sizeMode )
: PathColumn( sizeMode ), m_headerData( headerData ), m_property( property )
{
}

Expand Down Expand Up @@ -159,18 +164,33 @@ PathColumn::CellData StandardPathColumn::cellData( const Gaffer::Path &path, con

PathColumn::CellData StandardPathColumn::headerData( const IECore::Canceller *canceller ) const
{
return CellData( m_label );
return m_headerData;
}

//////////////////////////////////////////////////////////////////////////
// IconPathColumn
//////////////////////////////////////////////////////////////////////////

IconPathColumn::IconPathColumn( const std::string &label, const std::string &prefix, IECore::InternedString property, SizeMode sizeMode )
: PathColumn( sizeMode ), m_label( new StringData( label ) ), m_prefix( prefix ), m_property( property )
: IconPathColumn( CellData( new StringData( label ) ), prefix, property, sizeMode )
{
}

IconPathColumn::IconPathColumn( const CellData &headerData, const std::string &prefix, IECore::InternedString property, PathColumn::SizeMode sizeMode )
: PathColumn( sizeMode ), m_headerData( headerData ), m_prefix( prefix ), m_property( property )
{
}

const std::string &IconPathColumn::prefix() const
{
return m_prefix;
}

IECore::InternedString IconPathColumn::property() const
{
return m_property;
}

PathColumn::CellData IconPathColumn::cellData( const Gaffer::Path &path, const IECore::Canceller *canceller ) const
{
CellData result;
Expand Down Expand Up @@ -207,7 +227,7 @@ PathColumn::CellData IconPathColumn::cellData( const Gaffer::Path &path, const I

PathColumn::CellData IconPathColumn::headerData( const IECore::Canceller *canceller ) const
{
return CellData( m_label );
return m_headerData;
}

//////////////////////////////////////////////////////////////////////////
Expand Down
18 changes: 18 additions & 0 deletions src/GafferUIModule/PathColumnBinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,12 @@ PathColumn::CellData cellDataWrapper( PathColumn &pathColumn, const Path &path,
return pathColumn.cellData( path, canceller );
}

PathColumn::CellData headerDataWrapper( PathColumn &pathColumn, const Canceller *canceller )
{
IECorePython::ScopedGILRelease gilRelease;
return pathColumn.headerData( canceller );
}

struct ChangedSignalSlotCaller
{
void operator()( boost::python::object slot, PathColumnPtr c )
Expand Down Expand Up @@ -314,6 +320,12 @@ struct ButtonSignalSlotCaller
}
};

template<typename T>
const char *pathColumnProperty( const T &column )
{
return column.property().c_str();
}

} // namespace

void GafferUIModule::bindPathColumn()
Expand Down Expand Up @@ -363,6 +375,7 @@ void GafferUIModule::bindPathColumn()
pathColumnClass.def( init<PathColumn::SizeMode>( arg( "sizeMode" ) = PathColumn::SizeMode::Default ) )
.def( "changedSignal", &PathColumn::changedSignal, return_internal_reference<1>() )
.def( "cellData", &cellDataWrapper, ( arg( "path" ), arg( "canceller" ) = object() ) )
.def( "headerData", &headerDataWrapper, ( arg( "canceller" ) = object() ) )
.def( "buttonPressSignal", &PathColumn::buttonPressSignal, return_internal_reference<1>() )
.def( "buttonReleaseSignal", &PathColumn::buttonReleaseSignal, return_internal_reference<1>() )
.def( "buttonDoubleClickSignal", &PathColumn::buttonDoubleClickSignal, return_internal_reference<1>() )
Expand All @@ -372,10 +385,15 @@ void GafferUIModule::bindPathColumn()

IECorePython::RefCountedClass<StandardPathColumn, PathColumn>( "StandardPathColumn" )
.def( init<const std::string &, IECore::InternedString, PathColumn::SizeMode>( arg( "sizeMode" ) = PathColumn::Default ) )
.def( init<const PathColumn::CellData &, IECore::InternedString, PathColumn::SizeMode>( arg( "sizeMode" ) = PathColumn::Default ) )
.def( "property", &pathColumnProperty<StandardPathColumn> )
;

IECorePython::RefCountedClass<IconPathColumn, PathColumn>( "IconPathColumn" )
.def( init<const std::string &, const std::string &, IECore::InternedString, PathColumn::SizeMode>( arg( "sizeMode" ) = PathColumn::Default ) )
.def( init<const PathColumn::CellData &, const std::string &, IECore::InternedString, PathColumn::SizeMode>( arg( "sizeMode" ) = PathColumn::Default ) )
.def( "prefix", &IconPathColumn::prefix, return_value_policy<copy_const_reference>() )
.def( "property", &pathColumnProperty<IconPathColumn> )
;

IECorePython::RefCountedClass<FileIconPathColumn, PathColumn>( "FileIconPathColumn" )
Expand Down
Loading