JMRI icon indicating copy to clipboard operation
JMRI copied to clipboard

Rotated BlockContentsIcon do require a predefined size

Open arthkl opened this issue 2 years ago • 3 comments

This is related to #11208

The current implementation requires the size to be specified for BlockContentsIcon that are displayed with a rotation. #11208 does create an icon for BlockContentsIcon that are not displayed horizontally (rotation deg=0)

However, the order in which the individual attributes (such as text, icon, ..) are set in the MemoryIcon.displayState(Object key) destroys the icon almost immediately and cause the size to collapse to its minimum values. Consequently not displaying the label. A small change

original:

                } else if (val instanceof jmri.IdTag){
                    // most IdTags are Reportable objects, so
                    // this needs to be before Reportable
                    _icon = false;
                    _text = true;
                    setText(((jmri.IdTag)val).getDisplayName());
                    setIcon(null);

new:

                } else if (val instanceof jmri.IdTag){
                    // most IdTags are Reportable objects, so
                    // this needs to be before Reportable
                    _icon = false;
                    _text = true;
                    setIcon(null);
                    setText(((jmri.IdTag)val).getDisplayName());

did resolve the issue.

arthkl avatar Aug 08 '22 15:08 arthkl

@arthkl Do you have a panel file demonstrating this issue? I have created PR #11305 with your fix, but I'm not sure on how to test it.

danielb987 avatar Aug 11 '22 10:08 danielb987

Hi @danielb987,

Screen Shot 2022-08-08 at 10 30 28 AM

The BlockContentsIcons on the left (270 deg angle) and on the right (90 deg angle) were not visible prior to that change.

I've attached the panel file. (as txt) Moorbach.xml.txt

arthkl avatar Aug 11 '22 11:08 arthkl

@danielb987 Just wanted to point out that the fix only addresses cases where the key passed into displayState(Object key) is an instance of IdTag. I haven't had time to test other cases like Sting, Reportable but would imagine that the order needs to be changed for those instances too.

arthkl avatar Aug 11 '22 14:08 arthkl

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. JMRI is governed by a small group of maintainers which means not all opened issues may receive direct feedback.

stale[bot] avatar Sep 25 '22 21:09 stale[bot]

This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the maintainers may elect to reopen this issue at a later date if deemed necessary.

stale[bot] avatar Oct 11 '22 03:10 stale[bot]