RUSwitchBtn.h 924 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //
  2. // MySwitchBtn.h
  3. // CandyCpp
  4. //
  5. // Created by 杜家兑macbook on 16/8/23.
  6. //
  7. //
  8. #ifndef RUSwitchBtn_h
  9. #define RUSwitchBtn_h
  10. #include "RUQCoreBtn.h"
  11. NS_RU_BEGIN
  12. class SwitchBtn: public redutils::QCoreBtn
  13. {
  14. public:
  15. RED_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(SwitchBtn, create);
  16. SwitchBtn();
  17. ~SwitchBtn();
  18. void setQueryFunc(std::function<bool()>);
  19. void setCallbackWhileSwitched(std::function<void(bool)>);
  20. virtual void onEnter() override;
  21. protected:
  22. void onClicked(redutils::QCoreBtn* cl, int tag);
  23. std::function<bool(void)> _query = nullptr;
  24. std::function<void(bool)> _cbWhileSwitched = nullptr;
  25. };
  26. class SwitchBtnLoader : public redream::LayerLoader {
  27. public:
  28. RED_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(SwitchBtnLoader, loader);
  29. protected:
  30. RED_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(SwitchBtn);
  31. };
  32. NS_RU_END
  33. #endif /* defined(RUSwitchBtn_h) */