Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.1 KiB

  1. //============ Copyright (c) Valve Corporation, All rights reserved. ============
  2. #include "dme_controls/attributebooleanpanel.h"
  3. #include "dme_controls/AttributeTextEntry.h"
  4. #include "dme_controls/AttributeWidgetFactory.h"
  5. #include "tier1/KeyValues.h"
  6. #include "datamodel/dmelement.h"
  7. #include "movieobjects/dmeeditortypedictionary.h"
  8. #include "movieobjects/dmechannel.h"
  9. #include "dme_controls/inotifyui.h"
  10. #include "vgui_controls/CheckButton.h"
  11. // memdbgon must be the last include file in a .cpp file!!!
  12. #include "tier0/memdbgon.h"
  13. using namespace vgui;
  14. //-----------------------------------------------------------------------------
  15. CAttributeBooleanPanel::CAttributeBooleanPanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info ) :
  16. BaseClass( parent, info )
  17. {
  18. m_pValueButton = new vgui::CheckButton( this, "", "" );
  19. m_pValueButton->AddActionSignalTarget( this );
  20. }
  21. //-----------------------------------------------------------------------------
  22. void CAttributeBooleanPanel::ApplySchemeSettings(IScheme *pScheme)
  23. {
  24. // Need to override the scheme settings for this button
  25. BaseClass::ApplySchemeSettings( pScheme );
  26. m_pValueButton->SetBorder(NULL);
  27. m_pValueButton->SetPaintBorderEnabled( false );
  28. // Hack to get rid of the checkbox offset of &!^@#% 6
  29. // m_pValueButton->SetImage( vgui::scheme()->GetImage( "tools/ifm/icon_properties_linkarrow" , false), 0);
  30. m_pValueButton->SetImageAtIndex( 0, m_pValueButton->GetImageAtIndex( 0 ), 0 );
  31. }
  32. void CAttributeBooleanPanel::OnCheckButtonChecked( int state )
  33. {
  34. bool attributeValue = GetAttributeValue< bool>();
  35. bool buttonValue = (state == 1);
  36. if( buttonValue != attributeValue )
  37. {
  38. SetAttributeValue( state );
  39. Refresh();
  40. }
  41. }
  42. void CAttributeBooleanPanel::Refresh()
  43. {
  44. BaseClass::Refresh();
  45. bool myValue = GetAttributeValue< bool>();
  46. if( myValue != m_pValueButton->IsSelected() )
  47. {
  48. m_pValueButton->SetSelected( myValue );
  49. }
  50. }
  51. void CAttributeBooleanPanel::PerformLayout()
  52. {
  53. BaseClass::PerformLayout();
  54. int viewWidth, viewHeight;
  55. GetSize( viewWidth, viewHeight );
  56. m_pValueButton->SetBounds( (FirstColumnWidth - ColumnBorderWidth - 16) * 0.5 , ( viewHeight - 16 )* 0.5 , 16, 16 );
  57. }