Subversion Repositories tpanel

Rev

Rev 446 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 446 Rev 486
Line 1... Line 1...
1
/*
1
/*
2
 * Copyright (C) 2021 by Andreas Theofilu <andreas@theosys.at>
2
 * Copyright (C) 2021 to 2025 by Andreas Theofilu <andreas@theosys.at>
3
 *
3
 *
4
 * This program is free software; you can redistribute it and/or modify
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
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
6
 * the Free Software Foundation; either version 3 of the License, or
7
 * (at your option) any later version.
7
 * (at your option) any later version.
Line 17... Line 17...
17
 */
17
 */
18
 
18
 
19
#ifndef __TDRAWIMAGE__
19
#ifndef __TDRAWIMAGE__
20
#define __TDRAWIMAGE__
20
#define __TDRAWIMAGE__
21
 
21
 
22
#include "tbutton.h"
22
#include <include/core/SkBitmap.h>
23
 
23
 
24
class SkBitmap;
24
#include "tbutton.h"
25
 
25
 
26
class TDrawImage
26
class TDrawImage
27
{
27
{
28
    public:
28
    public:
29
        TDrawImage();
29
        TDrawImage();
Line 31... Line 31...
31
 
31
 
32
        /**
32
        /**
33
         * \brief Draws an image used as the background of a page or subpage.
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
34
         * This method can draw a normal or a cameleon image. It is able to
35
         * detect which kind of image to draw.
35
         * detect which kind of image to draw.
-
 
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.
36
         *
39
         *
37
         * @param bm    A pointer to the target image. The new image will be
40
         * @param bm    A pointer to the target image. The new image will be
38
         * drawn on top of \p bm.
41
         * drawn on top of \p bm.
39
         *
42
         *
40
         * @return If everything went well TRUE is returned. Otherwise FALSE.
43
         * @return If everything went well TRUE is returned. Otherwise FALSE.
Line 47... Line 50...
47
        int getInstance() { return mInstance; }                     // Get the instance in use
50
        int getInstance() { return mInstance; }                     // Get the instance in use
48
        void setSr(std::vector<Button::SR_T>& sr) { mSr = sr; }     // Set the page resource
51
        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
52
        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
53
        void setImageMi(SkBitmap& mi) { imageMi = mi; }             // Set the optional image mask for a cameleon image
51
        SkBitmap& getImageMi() { return imageMi; }                  // Get the image mask
54
        SkBitmap& getImageMi() { return imageMi; }                  // Get the image mask
52
        void setImageBm(SkBitmap& bm) { imageBm = bm; }             // Set the optional bitmap
55
        void setImageBm(SkBitmap& bm);                              // Set the optional bitmap
53
        SkBitmap& getImageBm() { return imageBm; }                  // Get the bitmap
56
        SkBitmap& getImageBm(size_t index=0);                       // Get the bitmap
54
        void setBorderSize(int bs) { mBorderSize = bs; }            // Set the optional border size, if there is one
57
        void setBorderSize(int bs) { mBorderSize = bs; }            // Set the optional border size, if there is one
55
        int getBorderSize() { return mBorderSize; }                 // Get the border size
58
        int getBorderSize() { return mBorderSize; }                 // Get the border size
56
        void setWidth(int wt) { mWidth = wt; }                      // Set the total width (width of page or subpage)
59
        void setWidth(int wt) { mWidth = wt; }                      // Set the total width (width of page or subpage)
57
        int getWidth() { return mWidth; }                           // Get the total width
60
        int getWidth() { return mWidth; }                           // Get the total width
58
        void setHeight(int ht) { mHeight = ht; }                    // Set the total height (height of page or subpage)
61
        void setHeight(int ht) { mHeight = ht; }                    // Set the total height (height of page or subpage)
59
        int getHeight() { return mHeight; }                         // Get the total height
62
        int getHeight() { return mHeight; }                         // Get the total height
60
 
63
 
61
    private:
64
    private:
62
        SkBitmap drawImageButton(SkBitmap& imgRed, SkBitmap& imgMask, int width, int height, SkColor col1, SkColor col2);
65
        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
        SkColor baseColor(SkColor basePix, SkColor maskPix, SkColor col1, SkColor col2);
64
        Button::POSITION_t calcImagePosition(int width, int height, int number);
67
        Button::POSITION_t calcImagePosition(int width, int height, int number, size_t index=0);
65
 
68
 
66
        int mInstance{0};               // The instance
69
        int mInstance{0};               // The instance
67
        int mBorderSize{0};             // Border size
70
        int mBorderSize{0};             // Border size
68
        int mWidth{0};                  // Total width of page / subpage
71
        int mWidth{0};                  // Total width of page / subpage
69
        int mHeight{0};                 // Total height of page / subpage
72
        int mHeight{0};                 // Total height of page / subpage
70
        std::vector<Button::SR_T> mSr;  // Array with background definations
73
        std::vector<Button::SR_T> mSr;  // Array with background definations
71
        SkBitmap imageMi;               // The mask image
74
        SkBitmap imageMi;               // The mask image
72
        SkBitmap imageBm;               // The bitmap image
75
        SkBitmap imageBm;               // The bitmap image
-
 
76
        std::vector<SkBitmap> mBitmapStack; // TP5: A bitmap stack.
73
};
77
};
74
 
78
 
75
#endif
79
#endif