-
Notifications
You must be signed in to change notification settings - Fork 202
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
MAYA-128473 - Move UFE to its own Project - Part11 (UIInfoHandler) #3252
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// | ||
// Copyright 2023 Autodesk | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
#include "MayaUsdUIInfoHandler.h" | ||
|
||
#include <maya/MDoubleArray.h> | ||
#include <maya/MGlobal.h> | ||
|
||
namespace MAYAUSD_NS_DEF { | ||
namespace ufe { | ||
|
||
MayaUsdUIInfoHandler::MayaUsdUIInfoHandler() | ||
: UsdUfe::UsdUIInfoHandler() | ||
{ | ||
// Register a callback to invalidate the invisible color. | ||
fColorChangedCallbackId = MEventMessage::addEventCallback( | ||
"DisplayRGBColorChanged", onColorChanged, reinterpret_cast<void*>(this)); | ||
|
||
// Immediately update the invisible color to get a starting current value. | ||
updateInvisibleColor(); | ||
} | ||
|
||
MayaUsdUIInfoHandler::~MayaUsdUIInfoHandler() | ||
{ | ||
// Unregister the callback used to invalidate the invisible color. | ||
if (fColorChangedCallbackId) | ||
MMessage::removeCallback(fColorChangedCallbackId); | ||
} | ||
|
||
/*static*/ | ||
MayaUsdUIInfoHandler::Ptr MayaUsdUIInfoHandler::create() | ||
{ | ||
return std::make_shared<MayaUsdUIInfoHandler>(); | ||
} | ||
|
||
void MayaUsdUIInfoHandler::updateInvisibleColor() | ||
{ | ||
// Retrieve the invisible color of the Maya Outliner. | ||
// | ||
// We *cannot* intialize it in treeViewCellInfo() because | ||
// that function gets called in a paint event and calling | ||
// a command in a painting event can cause a recursive paint | ||
// event if commands echoing is on, which can corrupt the | ||
// Qt paint internal which lead to a crash. Typical symptom | ||
// is that the state variable of the Qt paint engine becomes | ||
// null midway through the repaint. | ||
|
||
MDoubleArray color; | ||
MGlobal::executeCommand("displayRGBColor -q \"outlinerInvisibleColor\"", color); | ||
|
||
if (color.length() == 3) { | ||
color.get(fInvisibleColor.data()); | ||
} | ||
} | ||
|
||
/*static*/ | ||
void MayaUsdUIInfoHandler::onColorChanged(void* data) | ||
{ | ||
MayaUsdUIInfoHandler* infoHandler = reinterpret_cast<MayaUsdUIInfoHandler*>(data); | ||
if (!infoHandler) | ||
return; | ||
|
||
infoHandler->updateInvisibleColor(); | ||
} | ||
|
||
UsdUfe::UsdUIInfoHandler::SupportedTypesMap MayaUsdUIInfoHandler::getSupportedIconTypes() const | ||
{ | ||
auto supportedTypes = Parent::getSupportedIconTypes(); | ||
|
||
// We support these node types directly. | ||
static const UsdUfe::UsdUIInfoHandler::SupportedTypesMap mayaSupportedTypes { | ||
{ "MayaReference", "out_USD_MayaReference.png" }, | ||
{ "ALMayaReference", "out_USD_MayaReference.png" }, // Same as mayaRef | ||
}; | ||
supportedTypes.insert(mayaSupportedTypes.begin(), mayaSupportedTypes.end()); | ||
return supportedTypes; | ||
} | ||
Comment on lines
+78
to
+89
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Overridden method to add the two Maya reference icon types. |
||
|
||
} // namespace ufe | ||
} // namespace MAYAUSD_NS_DEF |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#ifndef MAYAUSDUIINFOHANDLER_H | ||
#define MAYAUSDUIINFOHANDLER_H | ||
|
||
// | ||
// Copyright 2023 Autodesk | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
#include <mayaUsd/base/api.h> | ||
|
||
#include <usdUfe/ufe/UsdUIInfoHandler.h> | ||
|
||
#include <maya/MEventMessage.h> | ||
|
||
namespace MAYAUSD_NS_DEF { | ||
namespace ufe { | ||
|
||
//! \brief Implementation of Ufe::UIInfoHandler interface for USD objects. | ||
class MAYAUSD_CORE_PUBLIC MayaUsdUIInfoHandler : public UsdUfe::UsdUIInfoHandler | ||
{ | ||
public: | ||
typedef UsdUfe::UsdUIInfoHandler Parent; | ||
typedef std::shared_ptr<MayaUsdUIInfoHandler> Ptr; | ||
|
||
MayaUsdUIInfoHandler(); | ||
~MayaUsdUIInfoHandler() override; | ||
|
||
// Delete the copy/move constructors assignment operators. | ||
MayaUsdUIInfoHandler(const MayaUsdUIInfoHandler&) = delete; | ||
MayaUsdUIInfoHandler& operator=(const MayaUsdUIInfoHandler&) = delete; | ||
MayaUsdUIInfoHandler(MayaUsdUIInfoHandler&&) = delete; | ||
MayaUsdUIInfoHandler& operator=(MayaUsdUIInfoHandler&&) = delete; | ||
|
||
//! Create a MayaUsdUIInfoHandler. | ||
static MayaUsdUIInfoHandler::Ptr create(); | ||
|
||
UsdUfe::UsdUIInfoHandler::SupportedTypesMap getSupportedIconTypes() const override; | ||
|
||
private: | ||
void updateInvisibleColor(); | ||
|
||
// Note: the on-color-changed callback function is declared taking a void pointer | ||
// to be compatible with MMessage callback API. | ||
static void onColorChanged(void*); | ||
|
||
MCallbackId fColorChangedCallbackId = 0; | ||
}; // MayaUsdUIInfoHandler | ||
|
||
} // namespace ufe | ||
} // namespace MAYAUSD_NS_DEF | ||
|
||
#endif // MAYAUSDUIINFOHANDLER_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_subdirectory(icons) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# --------------------------------------------------------------------------------------------- | ||
# install | ||
# --------------------------------------------------------------------------------------------- | ||
|
||
# TreeView icons | ||
set(TREEVIEW_ICONS | ||
BlendShape | ||
Camera | ||
Capsule | ||
CompArcBadge | ||
CompArcBadgeV | ||
Cone | ||
Cube | ||
Cylinder | ||
Def | ||
GeomSubset | ||
LightFilter | ||
LightPortal | ||
Material | ||
Mesh | ||
NurbsPatch | ||
PluginLight | ||
PointInstancer | ||
Points | ||
Scope | ||
Shader | ||
SkelAnimation | ||
Skeleton | ||
SkelRoot | ||
Sphere | ||
UsdGeomCurves | ||
UsdGeomXformable | ||
UsdLuxBoundableLightBase | ||
UsdLuxNonboundableLightBase | ||
UsdTyped | ||
Volume | ||
) | ||
foreach(ICON_BASE ${TREEVIEW_ICONS}) | ||
# The _100.png files need to be installed without the _100. This is the | ||
# base icon name that is used. A DCC (such as Maya) will automatically | ||
# choose the _150/_200 image if neeeded. | ||
install(FILES "out_USD_${ICON_BASE}_100.png" | ||
DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/icons" | ||
RENAME "out_USD_${ICON_BASE}.png" | ||
) | ||
install(FILES "out_USD_${ICON_BASE}_150.png" "out_USD_${ICON_BASE}_200.png" | ||
DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/icons" | ||
Comment on lines
+46
to
+47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Install most of the TreeView (Outliner) icons from UsdUfe. After discussing with Julien I kept the original naming "out_USD_XXX.png" (with the 150/200 versions). |
||
) | ||
endforeach() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Split off Maya stuff into this derived class. Mostly to handle this Maya callback when the color prefs changed.