SkinFlex Buttons

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

    • SkinFlex Buttons

      I have 4 buttons in a window. I used the following code to set a new color to one button.

      C Source Code

      1. BUTTON_SetSkinFlexProps(&Props, BUTTON_SKINFLEX_PI_ENABLED);

      C Source Code

      1. hB0 = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);

      C Source Code

      1. WM_Invalidate(hB0);


      My problem is that if I touch another button, also the other button is colored with the new colors.
      Why is that? Is there a way to keep the other buttons the same even if they are pressed?
      Thanks
    • SkinFlex Buttons

      Hi,
      As far as I understood, setting skinflex properties for a button is a global property. Even though, we pass the specific button handle to WM_Invalidate(hB0);,
      it will change the global skinning properties of the buttons.

      If you are in same window having different buttons, you can use the BUTTON_SetSkin() function passing the handle of the item and pointer to custom draw function.


      BUTTON_SetSkin(hB0, _ButtonCustomSkin);



      int _ButtonCustomSkin(const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo)

      {

      switch (pDrawItemInfo->Cmd)
      {
      case WIDGET_ITEM_DRAW_BACKGROUND:
      switch (WM_GetId(pDrawItemInfo->hWin))
      {
      case ID_BUTTON_B0:
      /* Set button color here using GUI_SetColor() */
      break;
      default:
      BUTTON_DrawSkinFlex(pDrawItemInfo);
      break;
      }
      }

      }


      Hope this helps.


      Thank you,
      Lullaby.
    • Button skinflex

      int _ButtonCustomSkin(const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo)

      {
      int Id;

      switch (pDrawItemInfo->Cmd)
      {
      case WIDGET_ITEM_DRAW_BACKGROUND:
      Id = WM_GetId(pDrawItemInfo->hWin);
      switch (Id)
      {
      case ID_BUTTON_B0:
      /* Set button color here using GUI_SetColor() */ break;
      }
      default:
      BUTTON_DrawSkinFlex(pDrawItemInfo);
      break;
      }
      return 0;
      }

      Try this code snippet..
    • Hi All,

      Just wanted to update this, as I had to go down this road to setup some background colors for buttons, as my setup has many of them, and I did NOT want to deal with global skinning properties..

      So this is what actually works to change the button background color, without affecting buttons globally... you can use the 'GUI_FillRect()' or 'GUI_FillRoundedRect()' as shown below, to fill the button background color. (RoundedRect being more like what the default buttons look like, with rounded corners)

      Source Code

      1. ** in your 'WM_INIT_DIALOG' for you window, set the skin callback **
      2. BUTTON_SetSkin(hButton, _ButtonCustomSkin);
      3. int _ButtonCustomSkin(const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo)
      4. {
      5. int Id;
      6. switch (pDrawItemInfo->Cmd)
      7. {
      8. case WIDGET_ITEM_DRAW_BACKGROUND:
      9. Id = WM_GetId(pDrawItemInfo->hWin);
      10. switch (Id)
      11. {
      12. case ID_BUTTON_B0:
      13. /* Set button color here using GUI_SetColor() */
      14. GUI_SetColor(GUI_LIGHTGREEN);
      15. GUI_FillRect(pDrawItemInfo->x0, pDrawItemInfo->y0, pDrawItemInfo->x1, pDrawItemInfo->y1);
      16. // GUI_FillRoundedRect(pDrawItemInfo->x0, pDrawItemInfo->y0, pDrawItemInfo->x1, pDrawItemInfo->y1, 5);
      17. break;
      18. }
      19. default:
      20. BUTTON_DrawSkinFlex(pDrawItemInfo);
      21. break;
      22. }
      23. return 0;
      24. }
      Display All

      The post was edited 2 times, last by MikeFlyersFan ().