Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
65 andreas 1
/*
2
 * Copyright (C) 2021 by Andreas Theofilu <andreas@theosys.at>
3
 *
4
 * This program is free software; you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program; if not, write to the Free Software Foundation,
16
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
17
 */
18
 
19
#ifndef __TDRAWIMAGE__
20
#define __TDRAWIMAGE__
21
 
22
#include "tbutton.h"
23
 
24
class SkBitmap;
25
 
26
class TDrawImage
27
{
28
    public:
29
        TDrawImage();
30
        ~TDrawImage();
31
 
66 andreas 32
        /**
33
         * \brief Draws an image used as the background of a page or subpage.
34
         * This method can draw a normal or a cameleon image. It is able to
35
         * detect which kind of image to draw.
36
         *
37
         * @param bm    A pointer to the target image. The new image will be
38
         * drawn on top of \p bm.
39
         *
40
         * @return If everything went well TRUE is returned. Otherwise FALSE.
41
         * If there was an error it is documented into the logfile if the
42
         * loglevel ERROR and WARNING was set.
43
         */
65 andreas 44
        bool drawImage(SkBitmap* bm);
45
 
66 andreas 46
        void setInstance(int instance) { mInstance = instance; }    // Set the instance to use (always 0 for background images)
47
        int getInstance() { return mInstance; }                     // Get the instance in use
48
        void setSr(std::vector<Button::SR_T>& sr) { mSr = sr; }     // Set the page resource
49
        std::vector<Button::SR_T>& getSr() { return mSr; }          // Get the page resource
50
        void setImageMi(SkBitmap& mi) { imageMi = mi; }             // Set the optional image mask for a cameleon image
51
        SkBitmap& getImageMi() { return imageMi; }                  // Get the image mask
52
        void setImageBm(SkBitmap& bm) { imageBm = bm; }             // Set the optional bitmap
53
        SkBitmap& getImageBm() { return imageBm; }                  // Get the bitmap
54
        void setBorderSize(int bs) { mBorderSize = bs; }            // Set the optional border size, if there is one
55
        int getBorderSize() { return mBorderSize; }                 // Get the border size
56
        void setWidth(int wt) { mWidth = wt; }                      // Set the total width (width of page or subpage)
57
        int getWidth() { return mWidth; }                           // Get the total width
58
        void setHeight(int ht) { mHeight = ht; }                    // Set the total height (height of page or subpage)
59
        int getHeight() { return mHeight; }                         // Get the total height
65 andreas 60
 
61
    private:
62
        SkBitmap drawImageButton(SkBitmap& imgRed, SkBitmap& imgMask, int width, int height, SkColor col1, SkColor col2);
63
        SkColor baseColor(SkColor basePix, SkColor maskPix, SkColor col1, SkColor col2);
66 andreas 64
        Button::POSITION_t calcImagePosition(int width, int height, int number);
65 andreas 65
 
66 andreas 66
        int mInstance{0};               // The instance
67
        int mBorderSize{0};             // Border size
68
        int mWidth{0};                  // Total width of page / subpage
69
        int mHeight{0};                 // Total height of page / subpage
70
        std::vector<Button::SR_T> mSr;  // Array with background definations
71
        SkBitmap imageMi;               // The mask image
72
        SkBitmap imageBm;               // The bitmap image
65 andreas 73
};
74
 
75
#endif