Acknowledged
CIQQA-3221

Clipping in CustomMenu.drawTitle unexpectedly affects rendering in subsequently displayed View

I’m working with a CustomMenu where I override the drawTitle() function to set a custom background color and draw a Text drawable. Since the background shouldn’t cover the entire title area, I apply a clip region before calling Dc.clear(), and then reset the clipping using Dc.clearClip().

However, applying the clip causes an unexpected side effect: when switching to a different view that is not a CustomMenu - either via WatchUi.pushView() or WatchUi.switchToView() - the Dc in the new view appears to be clipped. But the clipping is not to my custom region; instead, it matches the full bounds of the title Dc from the previous menu.

Oddly, calling Dc.clearClip() inside CustomMenu.drawTitle() has no effect.

What does work is calling Dc.clearClip() in the new view’s onUpdate() or onLayout() method. Another workaround is to avoid setting a clip region altogether. Instead, you can either fill the entire title Dc, or use Dc.fillRectangle() to draw only the desired area manually - neither approach leads to this issue.

To illustrate the issue, I set the background color of the new view to blue. In the first screenshot, you can see my intended clipped area rendered in grey. In the second screenshot—after switching views - you’ll notice that only the title region is filled with blue, while the rest of the screen remains untouched, as if still clipped.

This is not a simulator issue - I’ve confirmed the same behavior occurs on a real device (Epix 2 Pro 47mm).

You can find the project here:
https://github.com/TheNinth7/ohg/issues

The relevant CustomMenu implementation is located at:
https://github.com/TheNinth7/ohg/blob/main/source/ui/commons/BaseMenu.mc

  • I’d also say that setClip generally works as expected. The issue I’m seeing only affects a very specific use case: calling setClip within the CustomMenu.drawTitle method, and then transitioning to - or popping - a View that is not a CustomMenu.

  • All my apps use setClip() (mips, amoleds) and I assume it runs as it should: only the drawing in clipping region is update and drawing outside of the region no update the screen.

  • clip regions in general. only work on most MIP displays (not some of the oldest ones) that have the HW to use them.  Not on AMOLED, that don't have the row addressable display HW.

    Even if that were true:

    1) it's not documented

    2) clearly there is some sort of concept/implementation of clipping that goes beyond row-addressable MIP hardware, since:

    2a) it partially works for OP

    2b) setClip() doesn't just constrain the rows you can write to, it also constrains the columns

    If it's the case that devs shouldn't use setClip() except for MIP devices which have row-addressable hardware (i.e. those that support onPartialUpdate()), then:

    - I would expect it to be documented

    - I would expect setClip() to fail with a runtime error for other devices

    In particular, onPartialUpdate() has a list of supported devices which includes the MIP devices you mentioned, but setClip() does not.

    To be clear, the fact that setClip() is necessary to support onPartialUpdate() does not imply that onPartialUpdate() support is necessary for setClip() to work.

    A -> B does not imply B -> A.

  • clip regions in general. only work on most MIP displays (not some of the oldest ones) that have the HW to use them.  Not on AMOLED, that don't have the row addressable display HW.

  • It's the comment to Jim's post to use clip only in onPartialUpdate... but the name setClip suggest that clipping should run well also outside of onPartialUpdate.

    I had also problem with clipping, probably connected with conflict between system and dev clips.