Change the color of an individual HUD value element?

Change the color of an individual HUD value element?

FirespriteNate
Advocate Advocate
544 Views
2 Replies
Message 1 of 3

Change the color of an individual HUD value element?

FirespriteNate
Advocate
Advocate

I know you can modify the color of the viewport HUD text, both for the label and the value(s) separately, but this changes the global prefs, for all HUD entries.

What I'd like to do is create a new HUD entry that displays the value readout in a custom variable color, to act as a kind of visual "heatmap". So, for example, if the value is 0-10 it's drawn in the standard global prefs white color, but if the value is 11-15 it's drawn in yellow, 16-20 drawn in orange and 21+ draws the text in red, something like this:

FirespriteNate_0-1720444607773.png

 

Does anyone know if this is even possible? There doesn't appear to be anything in the standard headsUpDisplay command flags to set a value colour (although I haven't tried anything funky like using HTML tags) and I'm guessing the HUD text items are viewport2.0 DrawManager elements rather than QT widgets, so there's no hacking widget stylesheets or anything..?

 
Anyone got any bright ideas on how I could set an individual HUD value to a custom color like shown?
0 Likes
545 Views
2 Replies
Replies (2)
Message 2 of 3

ZachGray
Enthusiast
Enthusiast

The HUD doesn't seem support html color tags.

 

 

 

label = 'Position'
label_htm = f'<span style="color:#4287f5;"> {label} </span>'

 

 

 


I bet you are right that there is not a first class way to style the HUD and play nice with it. From the code examples, it appears to be via UIDraw manager, not Qt.

The inViewMessage would be nice(which supports html) if it could be updated on the fly, but it's creation only.
Maybe there would be a way to query the existing HUD to find some positions and then draw your own around that. Take a look at the py2UiDrawManager. It has examples of how to draw to the screen. Unfortunately, it's via a DAG object/MPxLocator, but you can at least make it immune to xforms and draw on the screen. That plugin has geometry and line examples as well as tons of extra attributes you would need to strip out. 

`cmds.createNode('uiDrawManager_py')`

ZachGray_0-1720581315167.pngZachGray_1-1720581348768.png

 

Chris Zurbrigg has a course on making a shot mask that is also based on a MPxLocator node. I can't think of a way to do it without going super deep and making a `MRenderOverride`, which would still require switching to that custom renderer.

 

Message 3 of 3

FirespriteNate
Advocate
Advocate

Thanks for that confirmation, Zach, that's pretty much what I suspected. I've made a couple of tools before that use MUIDrawManager but, like you basically said, that approach seems to involve a lot of extra faff in this case, just for a single HUD element.

Maybe I'm over complicating it. A regular HUD would still work fine, and I could just print an additional HUD message if the "danger" threshold is reached. 

I could even just make this UI based instead of in the viewport. It may not be as clean and native looking, but at least the user can just drag/place it where they want on screen, even off-viewport, and then just close it when they are done using/seeing it. I can do more with it in terms of styling and click-functionality that way too.

0 Likes