Subversion Repositories tpanel

Rev

Rev 446 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
446 andreas 1
/*
486 andreas 2
 * Copyright (C) 2021 to 2025 by Andreas Theofilu <andreas@theosys.at>
446 andreas 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
 
486 andreas 22
#include <include/core/SkBitmap.h>
23
 
446 andreas 24
#include "tbutton.h"
25
 
26
class TDrawImage
27
{
28
    public:
29
        TDrawImage();
30
        ~TDrawImage();
31
 
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.
486 andreas 36
         * If it is a TP5 panel, it has a bitmap stack to hold all images. In
37
         * this case the images of the stack are crunched together to one. Then,
38
         * if \b imageMi is set, a cameleon can be made.
446 andreas 39
         *
40
         * @param bm    A pointer to the target image. The new image will be
41
         * drawn on top of \p bm.
42
         *
43
         * @return If everything went well TRUE is returned. Otherwise FALSE.
44
         * If there was an error it is documented into the logfile if the
45
         * loglevel ERROR and WARNING was set.
46
         */
47
        bool drawImage(SkBitmap* bm);
48
 
49
        void setInstance(int instance) { mInstance = instance; }    // Set the instance to use (always 0 for background images)
50
        int getInstance() { return mInstance; }                     // Get the instance in use
51
        void setSr(std::vector<Button::SR_T>& sr) { mSr = sr; }     // Set the page resource
52
        std::vector<Button::SR_T>& getSr() { return mSr; }          // Get the page resource
53
        void setImageMi(SkBitmap& mi) { imageMi = mi; }             // Set the optional image mask for a cameleon image
54
        SkBitmap& getImageMi() { return imageMi; }                  // Get the image mask
486 andreas 55
        void setImageBm(SkBitmap& bm);                              // Set the optional bitmap
56
        SkBitmap& getImageBm(size_t index=0);                       // Get the bitmap
446 andreas 57
        void setBorderSize(int bs) { mBorderSize = bs; }            // Set the optional border size, if there is one
58
        int getBorderSize() { return mBorderSize; }                 // Get the border size
59
        void setWidth(int wt) { mWidth = wt; }                      // Set the total width (width of page or subpage)
60
        int getWidth() { return mWidth; }                           // Get the total width
61
        void setHeight(int ht) { mHeight = ht; }                    // Set the total height (height of page or subpage)
62
        int getHeight() { return mHeight; }                         // Get the total height
63
 
64
    private:
65
        SkBitmap drawImageButton(SkBitmap& imgRed, SkBitmap& imgMask, int width, int height, SkColor col1, SkColor col2);
66
        SkColor baseColor(SkColor basePix, SkColor maskPix, SkColor col1, SkColor col2);
486 andreas 67
        Button::POSITION_t calcImagePosition(int width, int height, int number, size_t index=0);
446 andreas 68
 
69
        int mInstance{0};               // The instance
70
        int mBorderSize{0};             // Border size
71
        int mWidth{0};                  // Total width of page / subpage
72
        int mHeight{0};                 // Total height of page / subpage
73
        std::vector<Button::SR_T> mSr;  // Array with background definations
74
        SkBitmap imageMi;               // The mask image
75
        SkBitmap imageBm;               // The bitmap image
486 andreas 76
        std::vector<SkBitmap> mBitmapStack; // TP5: A bitmap stack.
446 andreas 77
};
78
 
79
#endif