Hello,
I'd like to get a simultaneous motion of two simple windows.
Here is a short sample.
Display All
Just two simple "circle windows" with buttons to give them a motion. And a button to stop motion and reset windows to initial position.
When clicking one of the "moving buttons" corresponded window starts moving.
But if we click another button when one window is moving then another window starts moving and first window immediately stops.
Is there a way to avoid stopping and give completely independent motion to windows precisely using motion (not e. g. animation objects)?
Thank you.
I'd like to get a simultaneous motion of two simple windows.
Here is a short sample.
C Source Code: Main.c
- #include "DIALOG.h"
- WM_HWIN hWin1, hWin2;
- BUTTON_Handle hButton1, hButton2, hButton3;
- void _cbBk(WM_MESSAGE * pMsg) {
- switch (pMsg->MsgId) {
- case WM_PAINT:
- GUI_SetBkColor(GUI_LIGHTGRAY);
- GUI_Clear();
- break;
- case WM_NOTIFY_PARENT:
- if (pMsg->Data.v == WM_NOTIFICATION_RELEASED) {
- if ((pMsg->hWinSrc == hButton1) || (pMsg->hWinSrc == hButton2))
- WM_MOTION_SetMovement(pMsg->hWinSrc == hButton1 ? hWin1 : hWin2, GUI_COORD_X, 100, 170);
- else {
- WM_MOTION_Enable(0);
- WM_SetWindowPos(hWin1, 100, 60, 40, 40);
- WM_SetWindowPos(hWin2, 100, 140, 40, 40);
- WM_MOTION_Enable(1);
- }
- }
- break;
- default:
- WM_DefaultProc(pMsg);
- break;
- }
- }
- void _cbWin(WM_MESSAGE * pMsg) {
- GUI_COLOR Col;
- switch (pMsg->MsgId) {
- case WM_PAINT:
- if (pMsg->hWin == hWin1)
- Col = GUI_RED;
- else
- Col = GUI_BLUE;
- GUI_SetColor(Col);
- GUI_AA_FillCircle(20, 20, 18);
- break;
- default:
- WM_DefaultProc(pMsg);
- break;
- }
- }
- void MainTask(void) {
- GUI_Init();
- WM_MULTIBUF_Enable(1);
- WM_SetSize(WM_HBKWIN, 320, 240);
- WM_SetCallback(WM_HBKWIN, _cbBk);
- hButton1 = BUTTON_CreateEx(10, 70, 80, 20, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_BUTTON0);
- BUTTON_SetText(hButton1, "Move ->");
- hButton2 = BUTTON_CreateEx(10, 150, 80, 20, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_BUTTON1);
- BUTTON_SetText(hButton2, "Move ->");
- hButton3 = BUTTON_CreateEx(10, 10, 80, 20, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_BUTTON2);
- BUTTON_SetText(hButton3, "Reset");
- hWin1 = WM_CreateWindow(100, 60, 40, 40, WM_CF_SHOW | WM_CF_HASTRANS, _cbWin, 0);
- hWin2 = WM_CreateWindow(100, 140, 40, 40, WM_CF_SHOW | WM_CF_HASTRANS, _cbWin, 0);
- WM_MOTION_Enable(1);
- while (1) {
- GUI_Delay(50);
- }
- }
When clicking one of the "moving buttons" corresponded window starts moving.
But if we click another button when one window is moving then another window starts moving and first window immediately stops.
Is there a way to avoid stopping and give completely independent motion to windows precisely using motion (not e. g. animation objects)?
Thank you.