Re: Setting graphics of a Labeled does not show the Label correctly

2022-12-17 Thread Nir Lisker
I tried to change the behavior of setting a graphic for Labeled to one that removes the graphics from its previous labeled (if exists). This resulted in test failures in a few places: * MenuButton: * MenuButtonTest::testSetContentDisplayGraphicOnly - deliberately sets the same graphic to two Men

Re: Setting graphics of a Labeled does not show the Label correctly

2022-12-12 Thread Nir Lisker
Another idea is to use a static map that maps a node to its "graphic parent". That will save on memory at the expense of a lookup. On Thu, Dec 1, 2022 at 11:53 PM Nir Lisker wrote: > Are we convinced that a node can't be both a graphic and a clip, or > something else? The docs for clip specify t

Re: Setting graphics of a Labeled does not show the Label correctly

2022-12-01 Thread Nir Lisker
Are we convinced that a node can't be both a graphic and a clip, or something else? The docs for clip specify that the node is not a child in the scenegraph. On Thu, Dec 1, 2022 at 11:41 PM John Hendrikx wrote: > Adding another field doesn't seem ideal, would it be possible to > generalize the c

Re: Setting graphics of a Labeled does not show the Label correctly

2022-12-01 Thread John Hendrikx
Adding another field doesn't seem ideal, would it be possible to generalize the clipParent field to function for both (the ownedBy or owner field that I suggested earlier)? --John On 01/12/2022 20:26, Nir Lisker wrote: Michael's idea could solve the problem if it's about more than just traver

Re: Setting graphics of a Labeled does not show the Label correctly

2022-12-01 Thread Nir Lisker
Michael's idea could solve the problem if it's about more than just traversing, it needs to set rules for allowing a node to serve only 1 logical role (or 1 role type, like clip and graphic?) at the same time. In any case, these rules need to be decided upon before starting to work on anything. I c

Re: Setting graphics of a Labeled does not show the Label correctly

2022-12-01 Thread John Hendrikx
Yes, I always felt something was off about how graphics and clips worked and that in some cases these are actually inaccessible children (you can still look them up) -- it feels like they should allow sharing (clips especially) but things then break. On 01/12/2022 18:42, Michael Strauß wrote:

Re: Setting graphics of a Labeled does not show the Label correctly

2022-12-01 Thread Nir Lisker
By the way, these issues are caused by this inconsistent behavior (they are probably duplicates): https://bugs.openjdk.org/browse/JDK-8209017 https://bugs.openjdk.org/browse/JDK-8190331 The graphic of the checkbox of a CheckBoxTreeItem is not set correctly on the new CheckBox that is provided wit

Re: Setting graphics of a Labeled does not show the Label correctly

2022-12-01 Thread Kevin Rushforth
This seems related, but somewhat tangential. A Control's "graphic" isn't a child node, just like a Shape's "clip" isn't a child node. Creating a separate "document graph" (or "logical graph") sounds like an interesting idea, but it would bring its own set of challenges. And it wouldn't directl

Re: Setting graphics of a Labeled does not show the Label correctly

2022-12-01 Thread Michael Strauß
There's a larger picture here: from a user perspective, there's a difference between the scene graph and the "document graph". The document graph is what users actually work with, for example by setting the `Labeled.graphic` property. In some cases, document nodes don't correspond to scene nodes at

Re: Setting graphics of a Labeled does not show the Label correctly

2022-12-01 Thread Kevin Rushforth
g the action code in runLater() help? b1.setOnAction((ev) -> { Platform.runLater(() -> {   if (b1.getParent() == cb1) { ... -andy *From: *openjfx-dev on behalf of John Hendrikx *Date: *Thursday, 2022/12/01 at 09:14 *To: *Nir Lisker *Cc: *openjfx-dev@openjdk.org *Subject: *Re: Setting

Re: Setting graphics of a Labeled does not show the Label correctly

2022-12-01 Thread Andy Goryachev
etting graphics of a Labeled does not show the Label correctly The mechanism does seem like it is a bit poorly designed, as it is easy to create inconsistencies. Luckily it seems that you can't remove a graphic yourself from a Control (getChildren is protected). I don't think there is

Re: Setting graphics of a Labeled does not show the Label correctly

2022-12-01 Thread John Hendrikx
The mechanism does seem like it is a bit poorly designed, as it is easy to create inconsistencies. Luckily it seems that you can't remove a graphic yourself from a Control (getChildren is protected). I don't think there is an easy solution though... I think that once you set a graphic on a L

Re: Setting graphics of a Labeled does not show the Label correctly

2022-12-01 Thread Nir Lisker
Technically it doesn't appear elsewhere in the scenegraph, it is the child of only one label. It's set as the graphics property of 2 labels though. The mismatch is that being set as a graphics property isn't a 1-to-1 relationship with being a child of the label. Something has to be fixed along thi

Re: Setting graphics of a Labeled does not show the Label correctly

2022-12-01 Thread John Hendrikx
Sorry, I meant on the first click already. --John On 01/12/2022 14:46, John Hendrikx wrote: Setting the same Node for multiple graphics is not allowed. Your program should IMHO throw "IllegalArgumentException" on the 2nd click. * An optional icon for the Labeled. This can be positioned

Re: Setting graphics of a Labeled does not show the Label correctly

2022-12-01 Thread John Hendrikx
Setting the same Node for multiple graphics is not allowed.  Your program should IMHO throw "IllegalArgumentException" on the 2nd click. * An optional icon for the Labeled. This can be positioned relative to the * text by using {@link #setContentDisplay}.  The node specified for this

Re: Setting graphics of a Labeled does not show the Label correctly

2022-12-01 Thread Nir Lisker
That's my point. Currently, a node can serve as the graphics property for multiple Labels, but will appear only in 1 because it can only have a single parent in the scenegraph. While this is technically fine, it causes issues like the one I showed above. I'm not sure if a node is supposed to be abl

Re: Setting graphics of a Labeled does not show the Label correctly

2022-12-01 Thread John Hendrikx
Internally the graphics is just a child node, and nodes can't be part of the scene graph twice (this is done in LabeledSkinBase). It showing up only once is probably because it is getting removed from the other labels. I think things are probably getting out of sync, where the graphics prope

Setting graphics of a Labeled does not show the Label correctly

2022-12-01 Thread Nir Lisker
Hi, Given the following code var cb1 = new Label("1"); var cb2 = new Label ("2"); var b1 = new Button("A"); cb1.setGraphic(b1); b1.setOnAction(e -> { if (b1.getParent() == cb1) { // cb1.setGraphic(null); cb2.set