Page MenuHome

Geometry Nodes: Show used named attributes in modifier.
ClosedPublic

Authored by Jacques Lucke (JacquesLucke) on Apr 20 2022, 12:08 PM.

Details

Summary

This adds a new subpanel to the geometry nodes modifier which is just used to display information about used attributes.

  • A new panel is used because adding this information anywhere else clutters the ui too much imo.
  • The general layout is similar to that in the tooltip. I found it to be more trouble than it's worth to share this code.

I wonder if the new panel should have a poll function so that it only shows when named attributes are used.

Also see rBc71013082d096968d33ba977a0fdbcfbfb0690d1.


Diff Detail

Repository
rB Blender
Branch
used-attributes-panel (branched from master)
Build Status
Buildable 21712
Build 21712: arc lint + arc unit

Event Timeline

Jacques Lucke (JacquesLucke) requested review of this revision.Apr 20 2022, 12:08 PM
Jacques Lucke (JacquesLucke) created this revision.

Accepting with a bit of rambling thoughts and some UI tweaks below.


I agree with putting this in a separate panel. I thought it might make sense to make it a subpanel of the existing attribute panel, but since those are "outputs" it doesn't really make sense.
Another option is renaming "Output Attributes" to "Attributes" and adding two subpanels to it: "Outputs" and "Used Named Attributes" or something.
That doesn't feel any better to me though.

I wonder if the new panel should have a poll function so that it only shows when named attributes are used.

It would be nice, actually the best solution to the UI here IMO, but unfortunately I don't think it's possible currently, the panel poll function takes the panel type rather than the panel, so it doesn't know which modifier it's from.
Maybe there is some way to add the panel's modifier to the context used by the poll function, but that didn't seem doable when I looked at it.


I tried to make the panel look a bit more consistent:

I don't think that's perfect, but I think it fits better.
The contrast is low on the "Read"/"Write"/"Remove" words, but I think separating them visually is really helpful, not sure if there's a better way to do that.
Aligning to the property split 0.4 factor also helps when there are other buttons.

I put the attribute name on the right side to align with the output attributes panel. I also removed the quotes since I don't think they're necessary after the other changes and removing them makes it a bit cleaner.

/* #uiLayoutRowWithHeading doesn't seem to work in this case. */
uiLayout *split = uiLayoutSplit(layout, 0.4f, false);

std::stringstream ss;
Vector<std::string> usages;
if ((usage & NamedAttributeUsage::Read) != NamedAttributeUsage::None) {
  usages.append(TIP_("Read"));
}
if ((usage & NamedAttributeUsage::Write) != NamedAttributeUsage::None) {
  usages.append(TIP_("Write"));
}
if ((usage & NamedAttributeUsage::Remove) != NamedAttributeUsage::None) {
  usages.append(TIP_("Remove"));
}
for (const int i : usages.index_range()) {
  ss << usages[i];
  if (i < usages.size() - 1) {
    ss << ", ";
  }
}

uiLayout *row = uiLayoutRow(split, false);
uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_RIGHT);
uiLayoutSetActive(row, false);
uiItemL(row, ss.str().c_str(), ICON_NONE);

row = uiLayoutRow(split, false);
uiItemL(row, attribute_name.c_str(), ICON_NONE);
source/blender/modifiers/intern/MOD_nodes.cc
1643

IFACE_

This revision is now accepted and ready to land.Apr 20 2022, 3:42 PM