| 36 | |
| 37 | |
| 38 | class ButtonSprite : public ax::Sprite |
| 39 | { |
| 40 | ax::ui::Scale9Sprite* _buttonTexture; |
| 41 | Sprite* _subSprite; |
| 42 | Sprite* _subBGSprite; |
| 43 | |
| 44 | float _minWidth; |
| 45 | ax::Point _spriteOffset; |
| 46 | |
| 47 | ax::Label* _label; |
| 48 | |
| 49 | float _scale; |
| 50 | float _width; |
| 51 | float _height; |
| 52 | |
| 53 | bool _absoluteWidth; |
| 54 | bool _hasTextProvided; |
| 55 | |
| 56 | public: |
| 57 | /** |
| 58 | * Creates a text button. |
| 59 | * |
| 60 | * @param caption Text to display. |
| 61 | * @param width The maximum width the label can have before it shrinks. |
| 62 | * @param minWidth The minimum width of the button. |
| 63 | * @param scale The maximum scale of the label. |
| 64 | * @param absoluteWidth Whether or not the width of the button is locked. |
| 65 | * @param font The font to be used for the label. |
| 66 | * @param texture The name of the button texture to be used. |
| 67 | * @param height The height for the button. |
| 68 | * |
| 69 | * @return A ButtonSprite |
| 70 | */ |
| 71 | static ButtonSprite* create(std::string_view caption, |
| 72 | int width, int minWidth, float scale, bool absoluteWidth, |
| 73 | std::string_view font, std::string_view texture, float height |
| 74 | ); |
| 75 | |
| 76 | /** |
| 77 | * Creates a sprite button. |
| 78 | * |
| 79 | * @param iconSprite The icon sprite for the button. |
| 80 | * @param width The maximum width the icon sprite can have before it shrinks. |
| 81 | * @param minWidth The minimum width of the button. |
| 82 | * @param height The height for the button. |
| 83 | * @param scale The maximum scale of the label. |
| 84 | * @param absoluteWidth Whether or not the width of the button is locked. |
| 85 | * @param texture The name of the button texture to be used (Note: Must be from a sprite frame). |
| 86 | * @param dontUseScale9 Uses Sprite if set to true, uses Scale9Sprite otherwise. |
| 87 | * |
| 88 | * @return A ButtonSprite |
| 89 | */ |
| 90 | static ButtonSprite* create(Sprite* iconSprite, |
| 91 | int width, int minWidth, float height, float scale, |
| 92 | bool absoluteWidth, std::string_view texture, bool dontUseScale9 |
| 93 | ); |
| 94 | |
| 95 | static ButtonSprite* create(std::string_view caption, int width, float minWidth, float scale); |
nothing calls this directly
no outgoing calls
no test coverage detected