Proper way of fading in/out dialogs

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • 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 Source Code

    1. hIntro = WM_CreateWindow(40, 60, 240, 120, WM_CF_HASTRANS, _cbIntro, 0);
    2. GUI_MEMDEV_FadeInWindow(hIntro, 1000); osDelay(3000); GUI_MEMDEV_FadeOutWindow(hIntro, 1000); osDelay(1000);



    Then I call to create the window dialog

    C Source Code

    1. winSuwak = CreateSuwak();



    where:

    C Source Code

    1. WM_HWIN CreateSuwak(void);WM_HWIN CreateSuwak(void) {
    2. 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 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 ;)

    The post was edited 1 time, last by system32 ().

  • 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
    Files
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • 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 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 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
  • 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
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • 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.
  • 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
    Files
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.