Wrong screenshot during animation

#1

Hi,

I my main, I have 2 panels : a content panel (with no background) and an overlay StyledPanel (which is visible when I trigger it)

StyledDesktop desktop = new StyledDesktop();
	final Panel contentPanel = new Panel();
	MyContainer container= new MyContainer ();

	contentPanel.setWidget(container);
	contentPanel.setFocus(container);
	contentPanel.showFullScreen(desktop);

	desktop.setActivePanel(contentPanel);

	final StyledPanel overlayPanel = new StyledPanel() {
		@Override
		public boolean handleEvent(int event) {
			final Widget focus = contentPanel.getFocus();
			if (focus != null) {
				focus.handleEvent(event);
				return focus.handleEvent(event);
			}
			return super.handleEvent(event);
		}
	};

	overlayPanel.setEventHandler(contentPanel.getEventHandler());
	overlayPanel.addClassSelector(PocClassSelectors.OVERLAY_PANEL);

	myIndicator = new FloatingIndicator();

	overlayPanel.setWidget(myIndicator);
	overlayPanel.showFullScreen(desktop);

	desktop.setActivePanel(contentPanel);
	desktop.show();

During animation, the screenshot contains my overlay panel even if it is still hidden.
This problem is solved when the content panel is a StyledPanel instead of Panel, because of the colored plainBackground.

Is there a solution to create a screenshot without this hidden panel (keeping my no background panel) ?

Regards,
Elias

#2

Hello Elias,

rather than using the method setActivePanel to toggle between the two panels, I suggest that you use the methods showFullScreen() and hide() of the overlayPanel to respectively show/hide it. Hiding the overlayPanel will avoid such graphical issues and showing it will make it the active one by default.

In practice, when you want to show the overlayPanel, replace your call to desktop.setActivePanel(overlayPanel) with overlayPanel.showFullscreen(desktop). When you want to hide the overlayPanel, replace your call to desktop.setActivePanel(contentPanel) with overlayPanel.hide().

Best is to show/hide your panel in a callSerially block to ensure it is executed asynchronously in the UI thread to avoid any graphical issues. For example:

Display.getDefaultDisplay().callSerially(new Runnable() {

	@Override
	public void run() {
		overlayPanel.showFullScreen(desktop);
	}
});

Best regards,

Thomas

1 Like
#3

Hello Thomas,

It’s working even better with asynchronous :slight_smile:
Thanks for your time !!

Best regards,

Elias