1 /* 2 * Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/> 3 * (C) 2020 Vladimir Sadovnikov <sadko4u@gmail.com> 4 * 5 * This file is part of lsp-plugins 6 * Created on: 2 июл. 2019 г. 7 * 8 * lsp-plugins is free software: you can redistribute it and/or modify 9 * it under the terms of the GNU Lesser General Public License as published by 10 * the Free Software Foundation, either version 3 of the License, or 11 * any later version. 12 * 13 * lsp-plugins is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public License 19 * along with lsp-plugins. If not, see <https://www.gnu.org/licenses/>. 20 */ 21 22 #ifndef UI_TK_WIDGETS_LSPPROGRESSBAR_H_ 23 #define UI_TK_WIDGETS_LSPPROGRESSBAR_H_ 24 25 namespace lsp 26 { 27 namespace tk 28 { 29 30 class LSPProgressBar: public LSPWidget 31 { 32 public: 33 static const w_class_t metadata; 34 35 protected: 36 float fMin; 37 float fMax; 38 float fValue; 39 ssize_t nMinWidth; 40 ssize_t nMinHeight; 41 LSPString sText; 42 LSPFont sFont; 43 LSPColor sColor; 44 LSPColor sSelColor; 45 46 public: 47 explicit LSPProgressBar(LSPDisplay *dpy); 48 virtual ~LSPProgressBar(); 49 50 virtual status_t init(); 51 52 public: 53 /** Get font 54 * 55 * @return font 56 */ font()57 LSPFont *font() { return &sFont; } 58 59 /** Get current label text 60 * 61 * @return current label text 62 */ text()63 inline const char *text() const { return sText.get_utf8(); } get_text(LSPString * dst)64 inline status_t get_text(LSPString *dst) const { return (dst->set(&sText)) ? STATUS_OK : STATUS_NO_MEM; }; 65 66 /** Get background color 67 * 68 * @return background color 69 */ color()70 inline LSPColor *color() { return &sColor; } sel_color()71 inline LSPColor *sel_color() { return &sSelColor; } 72 get_min_value()73 inline float get_min_value() const { return fMin; } get_max_value()74 inline float get_max_value() const { return fMax; } get_value()75 inline float get_value() const { return fValue; } 76 77 public: 78 status_t set_text(const char *text); 79 80 status_t set_text(const LSPString *text); 81 82 bool set_min_value(const float v); 83 bool set_max_value(const float v); 84 bool set_value(const float v); 85 86 void set_min_width(ssize_t value); 87 void set_min_height(ssize_t value); 88 89 public: 90 virtual void draw(ISurface *s); 91 92 virtual void size_request(size_request_t *r); 93 94 }; 95 96 } /* namespace tk */ 97 } /* namespace lsp */ 98 99 #endif /* UI_TK_WIDGETS_LSPPROGRESSBAR_H_ */ 100