NanoButton.hpp (1693B)
1 /* 2 * Copyright (C) 2018-2019 Rob van den Berg <rghvdberg at gmail dot org> 3 * Copyright (C) 2020-2021 Filipe Coelho <falktx@falktx.com> 4 * 5 * This file is part of CharacterCompressor 6 * 7 * Nnjas2 is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * CharacterCompressor is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with CharacterCompressor. If not, see <https://www.gnu.org/licenses/>. 19 */ 20 21 #ifndef NANO_BUTTON_HPP_INCLUDED 22 #define NANO_BUTTON_HPP_INCLUDED 23 24 #include "NanoVG.hpp" 25 #include "EventHandlers.hpp" 26 27 #include <string> 28 29 START_NAMESPACE_DGL 30 31 class Button : public NanoSubWidget, 32 public ButtonEventHandler 33 { 34 public: 35 explicit Button(Widget* parent, ButtonEventHandler::Callback* cb); 36 ~Button() override; 37 38 void setBackgroundColor(Color color); 39 void setFontScale(float scale); 40 void setLabel(const std::string& label); 41 void setLabelColor(Color color); 42 43 protected: 44 void onNanoDisplay() override; 45 bool onMouse(const MouseEvent& ev) override; 46 bool onMotion(const MotionEvent& ev) override; 47 48 private: 49 Color backgroundColor; 50 Color labelColor; 51 std::string label; 52 float fontScale; 53 54 DISTRHO_LEAK_DETECTOR(Button) 55 }; 56 57 END_NAMESPACE_DGL 58 59 #endif // NANO_BUTTON_HPP_INCLUDED