SLIDER - changing appearance

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

    • SLIDER - changing appearance

      New

      Hello,
      I am using the SLIDER widget for moving a graphical cursor line in a diagram (see picture).
      The bar and the scale are made invisible. The yellow thumb I made by skinning.
      Now I would like to add a second slider with a different color. How can I achieve this?
      I found API commands for the width but not for the color.
      Can I switch between two skinnings?

      Best regards
      Jan
      Images
      • slider.png

        14.47 kB, 800×480, viewed 65 times

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

    • New

      Hello,

      there is no need to switch to another skinning function. Just use an option to set user data as a color of the thumb.

      Something like this:

      C Source Code: Main.c

      1. #include "DIALOG.h"
      2. typedef struct {
      3. GUI_COLOR ThumbCol;
      4. } SLIDER_USER_DATA;
      5. int _SLIDER_CustomSkin(const WIDGET_ITEM_DRAW_INFO * pInfo) {
      6. SLIDER_USER_DATA Data;
      7. switch (pInfo->Cmd) {
      8. case WIDGET_ITEM_DRAW_SHAFT:
      9. SLIDER_GetUserData(pInfo->hWin, &Data, sizeof(SLIDER_USER_DATA));
      10. GUI_SetColor(Data.ThumbCol);
      11. GUI_DrawHLine(pInfo->y1 / 2, pInfo->x0, pInfo->x1);
      12. break;
      13. case WIDGET_ITEM_DRAW_THUMB:
      14. SLIDER_GetUserData(pInfo->hWin, &Data, sizeof(SLIDER_USER_DATA));
      15. GUI_SetColor(Data.ThumbCol);
      16. GUI_FillRect(pInfo->x0, pInfo->y0, pInfo->x1, pInfo->y1);
      17. break;
      18. default:
      19. return SLIDER_DrawSkinFlex(pInfo);
      20. break;
      21. }
      22. return 0;
      23. }
      24. void _CreateSlider(int x0, int y0, int xSize, int ySize, GUI_COLOR ThumbCol, int Id) {
      25. SLIDER_Handle hSlider;
      26. SLIDER_USER_DATA Data;
      27. Data.ThumbCol = ThumbCol;
      28. hSlider = SLIDER_CreateUser(x0, y0, xSize, ySize, WM_HBKWIN, WM_CF_SHOW, 0, Id, sizeof(SLIDER_USER_DATA));
      29. SLIDER_SetUserData(hSlider, &Data, sizeof(SLIDER_USER_DATA));
      30. SLIDER_SetSkin(hSlider, _SLIDER_CustomSkin);
      31. }
      32. void MainTask(void) {
      33. GUI_Init();
      34. WM_MULTIBUF_Enable(1);
      35. WM_SetDesktopColor(GUI_BLACK);
      36. _CreateSlider(100, 100, 500, 50, GUI_YELLOW, GUI_ID_SLIDER0);
      37. _CreateSlider(100, 200, 500, 50, GUI_RED, GUI_ID_SLIDER1);
      38. while (1) {
      39. GUI_Delay(50);
      40. }
      41. }
      Display All
      Regards,

      Anthony