GComparments not extending the width of parent container with hGrab #810
Replies: 3 comments 5 replies
-
Hi, If both the title and the button are placed in the same parent, hGrab won't affect them (Their parent will grow bigger, but they're still centered in their parent, so it doesn't actually change anything for them. They'll be "properly centered" rather than "left-aligned" in the parent node, but they'll still be stuck together). What you want is 2 compartments (One left, one right), and to set the hGrab=true value on the left compartment (so it takes extra horizontal space, and pushes the right one further to the right). It might be possible to also apply hGrab on your left-side element (the title label) directly, although I haven't really tested this. More verbose option that should work, with intermediate compartments:
More compact option, that may or may not work, without intermediate compartments:
|
Beta Was this translation helpful? Give feedback.
-
Hey, I quickly checked with a handcrafted model, based on the Workflow example. I think this layout is similar to what you're trying to get: I used the compact approach (1 header compartment with 2 labels, the left one using hGrab=true) Here's the relevant part for the parent node and header (Everything below the header is truncated): {
"name": "Test Node",
"id": "cb8de617-853f-4d5f-aa80-c500941b4554",
"cssClasses": [
"category"
],
"children": [
{
"id": "cb8de617-853f-4d5f-aa80-c500941b4554_header",
"children": [
{
"id": "cb8de617-853f-4d5f-aa80-c500941b4554_classname_left",
"type": "label:heading",
"text": "Left Label",
"layoutOptions": {
"hGrab": true
}
},
{
"id": "cb8de617-853f-4d5f-aa80-c500941b4554_classname_right",
"type": "label:heading",
"text": "Right Label"
}
],
"type": "comp:header",
"layout": "hbox",
"layoutOptions": {
"hGrab": true
}
},
{
"id": "cb8de617-853f-4d5f-aa80-c500941b4554_struct",
... I also attached the complete model I used for testing (It contains a *.wf model, that can be used with the Workflow Example editor): |
Beta Was this translation helpful? Give feedback.
-
Hi, Compartments and Nodes may behave slightly differently, because their view may (or may not) actually support the "size" attributes (Width/Height), and modify the way they render it. But this isn't necessarily the case for Labels (The size of a label is defined by the size of the text, unless your label view does something more, e.g. to support alignment or some kind of label decoration). In your last example above, you set hGrab=true on the right label: this means that anything that comes after it will be pushed further to the right; but nothing comes after it. So, this won't have any effect (Again: unless you apply this to a node that actually supports size attributes). This would work if your Right-label view supported the width attribute, and using a right-aligned text. But since the default Label View doesn't support width attribute, you need to apply hGrab to the left label (which will be left-aligned by default). The layout is driven by the parent (In your case: root node and top header). hGrab distributes the remaining horizontal space between the nodes that request hGrab, and does two things:
Since the default Label View ignores the Width attribute, only the position will be affected (Unless you're using a custom Label View). For the layout to work properly, you need to ensure the following:
In the workflow example, the views for the header are mapped as follows:
(These are the default SLabelView and SCompartmentView) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I'm having trouble getting compartments to match the width of a parent node using hGrab. I want the title to hAlign left, and the button to hAlign right. I’ve added hGrab=true to the parent node and the header compartment, but it doesn’t seem to be working. Are there any changes I can make to achieve this?
I'm using a node server with the vscode client. Here is my code and here is what it creates:
Beta Was this translation helpful? Give feedback.
All reactions