kick
/Users/morten/Programmering/cpp/kick/src/kick/2d/toggle_button.h
00001 //
00002 // Created by morten on 19/07/14.
00003 //
00004 
00005 
00006 #pragma once
00007 #include "kick/2d/button.h"
00008 
00009 namespace kick {
00010 
00011     class ToggleButton;
00012 
00013     class ToggleButtonGroup {
00014         std::vector<ToggleButton*> buttons;
00015     public:
00016         ToggleButton *selectedButton = nullptr;
00017         int buttonCount();
00018         friend class ToggleButton;
00019     };
00020 
00021     class ToggleButton : public Button {
00022         std::shared_ptr<ToggleButtonGroup> mGroup;
00023         std::string mSelectedSprite;
00024     public:
00025         ToggleButton(GameObject *gameObject, std::shared_ptr<Canvas> canvas);
00026         virtual ~ToggleButton();
00027         std::shared_ptr<ToggleButtonGroup> group();
00028 
00029         void setGroup(std::shared_ptr<ToggleButtonGroup> group);
00030 
00031         bool selected();
00032 
00033         void setSelected(bool selectedState);
00034         void toggleSelected();
00035 
00036         std::string selectedSprite() const;
00037 
00038         void setSelectedSprite(std::string const &selectedSprite);
00039 
00040         std::function<void(ToggleButton*)> const &onChange() const;
00041         void setOnChange(std::function<void(ToggleButton*)> const &onChange);
00042     protected:
00043         virtual void updateTextureAndTxtColor();
00044 
00045         virtual void invokeClick() override;
00046         std::function<void(ToggleButton*)> mOnChange = [](Button*){};
00047     };
00048 }
 All Classes Functions Variables