Skin.cpp 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. GWEN
  3. Copyright (c) 2010 Facepunch Studios
  4. See license in Gwen.h
  5. */
  6. #include "Gwen/Gwen.h"
  7. #include <math.h>
  8. namespace Gwen
  9. {
  10. namespace Skin
  11. {
  12. /*
  13. Here we're drawing a few symbols such as the directional arrows and the checkbox check
  14. Texture'd skins don't generally use these - but the Simple skin does. We did originally
  15. use the marlett font to draw these.. but since that's a Windows font it wasn't a very
  16. good cross platform solution.
  17. */
  18. void Base::DrawArrowDown( Gwen::Rect rect )
  19. {
  20. float x = (rect.w / 5.0f);
  21. float y = (rect.h / 5.0f);
  22. m_Render->DrawFilledRect( Gwen::Rect( rect.x + x*0.0f, rect.y + y*1.0f, x, y*1.0f ) );
  23. m_Render->DrawFilledRect( Gwen::Rect( rect.x + x*1.0f, rect.y + y*1.0f, x, y*2.0f ) );
  24. m_Render->DrawFilledRect( Gwen::Rect( rect.x + x*2.0f, rect.y + y*1.0f, x, y*3.0f ) );
  25. m_Render->DrawFilledRect( Gwen::Rect( rect.x + x*3.0f, rect.y + y*1.0f, x, y*2.0f ) );
  26. m_Render->DrawFilledRect( Gwen::Rect( rect.x + x*4.0f, rect.y + y*1.0f, x, y*1.0f ) );
  27. }
  28. void Base::DrawArrowUp( Gwen::Rect rect )
  29. {
  30. float x = (rect.w / 5.0f);
  31. float y = (rect.h / 5.0f);
  32. m_Render->DrawFilledRect( Gwen::Rect( rect.x + x*0.0f, rect.y + y*3.0f, x, y*1.0f ) );
  33. m_Render->DrawFilledRect( Gwen::Rect( rect.x + x*1.0f, rect.y + y*2.0f, x, y*2.0f ) );
  34. m_Render->DrawFilledRect( Gwen::Rect( rect.x + x*2.0f, rect.y + y*1.0f, x, y*3.0f ) );
  35. m_Render->DrawFilledRect( Gwen::Rect( rect.x + x*3.0f, rect.y + y*2.0f, x, y*2.0f ) );
  36. m_Render->DrawFilledRect( Gwen::Rect( rect.x + x*4.0f, rect.y + y*3.0f, x, y*1.0f ) );
  37. }
  38. void Base::DrawArrowLeft( Gwen::Rect rect )
  39. {
  40. float x = (rect.w / 5.0f);
  41. float y = (rect.h / 5.0f);
  42. m_Render->DrawFilledRect( Gwen::Rect( rect.x + x*3.0f, rect.y + y*0.0f, x*1.0f, y ) );
  43. m_Render->DrawFilledRect( Gwen::Rect( rect.x + x*2.0f, rect.y + y*1.0f, x*2.0f, y ) );
  44. m_Render->DrawFilledRect( Gwen::Rect( rect.x + x*1.0f, rect.y + y*2.0f, x*3.0f, y ) );
  45. m_Render->DrawFilledRect( Gwen::Rect( rect.x + x*2.0f, rect.y + y*3.0f, x*2.0f, y ) );
  46. m_Render->DrawFilledRect( Gwen::Rect( rect.x + x*3.0f, rect.y + y*4.0f, x*1.0f, y ) );
  47. }
  48. void Base::DrawArrowRight( Gwen::Rect rect )
  49. {
  50. float x = (rect.w / 5.0f);
  51. float y = (rect.h / 5.0f);
  52. m_Render->DrawFilledRect( Gwen::Rect( rect.x + x*1.0f, rect.y + y*0.0f, x*1.0f, y ) );
  53. m_Render->DrawFilledRect( Gwen::Rect( rect.x + x*1.0f, rect.y + y*1.0f, x*2.0f, y ) );
  54. m_Render->DrawFilledRect( Gwen::Rect( rect.x + x*1.0f, rect.y + y*2.0f, x*3.0f, y ) );
  55. m_Render->DrawFilledRect( Gwen::Rect( rect.x + x*1.0f, rect.y + y*3.0f, x*2.0f, y ) );
  56. m_Render->DrawFilledRect( Gwen::Rect( rect.x + x*1.0f, rect.y + y*4.0f, x*1.0f, y ) );
  57. }
  58. void Base::DrawCheck( Gwen::Rect rect )
  59. {
  60. float x = (rect.w / 5.0f);
  61. float y = (rect.h / 5.0f);
  62. m_Render->DrawFilledRect( Gwen::Rect( rect.x + x*0.0f, rect.y + y*3.0f, x*2, y*2 ) );
  63. m_Render->DrawFilledRect( Gwen::Rect( rect.x + x*1.0f, rect.y + y*4.0f, x*2, y*2 ) );
  64. m_Render->DrawFilledRect( Gwen::Rect( rect.x + x*2.0f, rect.y + y*3.0f, x*2, y*2 ) );
  65. m_Render->DrawFilledRect( Gwen::Rect( rect.x + x*3.0f, rect.y + y*1.0f, x*2, y*2 ) );
  66. m_Render->DrawFilledRect( Gwen::Rect( rect.x + x*4.0f, rect.y + y*0.0f, x*2, y*2 ) );
  67. }
  68. }
  69. }