Tuesday, November 21st 2017, 7:17am UTC+1

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

system32

Beginner

Date of registration: Jul 13th 2017

Posts: 6

1

Friday, October 13th 2017, 10:15am

Proper way of fading in/out dialogs

Hello,

Let's say that I have a couple of windows created manually and couple of dialogs (which are basically windows as well) with GUI builder.

I have some intro as well:

C/C++ Source code

1
2
3
    hIntro = WM_CreateWindow(40, 60, 240, 120, WM_CF_HASTRANS, _cbIntro, 0);

    GUI_MEMDEV_FadeInWindow(hIntro, 1000);    osDelay(3000);    GUI_MEMDEV_FadeOutWindow(hIntro, 1000);    osDelay(1000);



Then I call to create the window dialog

C/C++ Source code

1
  winSuwak = CreateSuwak();



where:

C/C++ Source code

1
2
3
WM_HWIN CreateSuwak(void);WM_HWIN CreateSuwak(void) {

	hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, winSuwak, 0, 0);  GUI_MEMDEV_FadeInWindow(hWin, 1000);  return hWin;}



and once I close (fade out) the dialog with a button:

C/C++ Source code

1
    	  GUI_MEMDEV_FadeOutWindow(hWin, 1000);    	  GUI_EndDialog(hWin, 0);



I am not able to create that dialog again.

Please advice me what is a proper way for switching - fading between couple of dialogs and a manually created windows.

Update:

Using WM_ShowWindow() and WM_HideWindow() works fine though. After using fade in/out twice I get artifacts on the screen and MCU freeze. My screen is 320x240 and my memory is #define GUI_NUMBYTES ((1024) * 2500)



Thanks ;)

This post has been edited 1 times, last edit by "system32" (Oct 13th 2017, 11:02am)


SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 410

2

Friday, October 13th 2017, 2:32pm

Hi,

Attached is an example which use GUI_MEMDEV_FadeInWindow() and GUI_MEMDEV_FadeOutWindow() in combination with a dialog.

On button press a dialog gets created, hidden by default, and gets faded in.

This dialog has a button and fades out if the button gets pressed. After the fade out function comes back the dialog deletes itself.

Regards
Sven
SEGGER - Schoenen has attached the following file:

system32

Beginner

Date of registration: Jul 13th 2017

Posts: 6

3

Friday, October 13th 2017, 2:46pm

Thank you Sven, you are extremely helpful on this forum.


If I may ask another thing:


I want to make a Lockscreen with a swipe function, I thought that maybe it would be best to create a transparent slider with a value 0-100 and once it reaches 100 it goes to another screen, from that I would take


C/C++ Source code

1
Lockscreen_sliderVal = SLIDER_GetValue(hSliderLock);



and draw a filled rectange on top of it (with x transition val taken from the slider). If someone reeases the button during dragging I should decrement it, I can do this with

C/C++ Source code

1
		if(WM_IsVisible(winScreenLock)){		WM_InvalidateWindow(winScreenLock);		}



to call the case WM_PAINT: in the dialog.

Am I thinking right? Will creating a mem_dev inside case WM_INIT_DIALOG: and then painting a memdev in WM_PAINT: work?

BR,
Simon

SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 410

4

Friday, October 13th 2017, 3:51pm

Hi,

what exactly do you mean with a lockscreen?

Something like on a mobile where you swipe on the screen to unlock the device?

I like the idea to do it with a slider, but this would mean you have to 'swipe' on a specific position.

Regards,
Sven

system32

Beginner

Date of registration: Jul 13th 2017

Posts: 6

5

Friday, October 13th 2017, 3:53pm

Exactly. Just like on some phones, swipe horizontaly right, using transparent slider, and drawing a graphical rectangle on top of the invisible slider. Once you reach >90 on the slider -> you go to other screen.

SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 410

6

Friday, October 13th 2017, 5:05pm

Hi,

how about this (attached).

After 15 seconds or after pressing the lock button the screen gets locked and can be unlocked by sliding the lock up :)

Unfortunately this requires pretty much memory I suggest to have ~4MB assigned to emWin in GUIConf.c. The high amount of memory is caused by the excessive use of memory device operations with windows covering the whole screen.

Using the animation functions of emWin (search for GUI_ANIM_Create() in the manual) offer other solution which do not require so much memory.

Anyway, using the function GUI_MEMDEV_CreateBlurredDevice32() creates a nice effect for the lock screen.

Have a nice weekend.

Regards,
Sven
SEGGER - Schoenen has attached the following file:

Similar threads