summaryrefslogtreecommitdiff
path: root/baserender.h
blob: 82e552c805dcfae7a1f41311e1fdfdd6c4b3595a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#pragma once

#include "flat.h"
#include "imageloader.h"
#include <list>

enum eBorder {
    BorderMenuItem,
    BorderRecordJump,
    BorderMenuRecord,
    BorderMessage,
    BorderButton,
    BorderContent
};

struct sDecorBorder {
    int Left, Top, Width, Height, Size, Type;
    tColor ColorFg, ColorBg;
    int From;
};

class cFlatBaseRender
{
    protected:
        cOsd *osd;

        int osdLeft, osdTop, osdWidth, osdHeight;
        int marginItem;
    
        // Standard fonts
        cFont *font;
        cFont *fontSml;
        cFont *fontFixed;
        int fontHeight;
        int fontSmlHeight;
        int fontFixedHeight;

        // TopBar
        cPixmap *topBarPixmap;
        cPixmap *topBarIconPixmap;
        cPixmap *topBarIconBGPixmap;
        cFont *topBarFont, *topBarFontSml;
        int topBarFontHeight, topBarFontSmlHeight;
    
        cString topBarTitle;
        cString tobBarTitleExtra1, tobBarTitleExtra2;
        cString topBarExtraIcon;
        bool topBarExtraIconSet;
        cString topBarMenuIcon;
        bool topBarMenuIconSet;
        cString topBarMenuLogo;
        bool topBarMenuLogoSet;
        
        bool topBarUpdateTitle;
        cString topBarLastDate;
        int topBarHeight;

        // Progressbar
        cPixmap *progressBarPixmap;
        cPixmap *progressBarPixmapBg;
        int progressBarHeight, progressBarTop, progressBarWidth, progressBarMarginHor, progressBarMarginVer;
        int ProgressType;
        bool progressBarSetBackground;
        tColor progressBarColorFg, progressBarColorBarFg, progressBarColorBarCurFg, progressBarColorBg;
        tColor progressBarColorMark, progressBarColorMarkCurrent;
        
        // Scrollbar
        int scrollBarWidth;
        
        // Buttons rot, grün, gelb, blau
        cPixmap *buttonsPixmap;
        int buttonsWidth, buttonsHeight, buttonsTop;
        int marginButtonColor, buttonColorHeight;
        bool buttonsDrawn;
        
        // Nachricht
        cPixmap *messagePixmap;
        int messageWidth, messageHeight;

        // Mehrzeiliger Content mit Scrollbalken
        cPixmap *contentPixmap;
        int contentLeft, contentTop, contentHeight, contentWidth;
        int contentDrawPortHeight; // gesamthöhe des Textes
        int contentTextHeight;
        bool contentHasScrollbar;
        bool contentShown;
        int contentFontType;
        
        tColor contentColorFg, contentColorBg;
        cTextWrapper contentWrapper;

        cPixmap *decorPixmap;
        std::list<sDecorBorder> Borders; // for clear specific Borders (clear only MenuItems and not TopBar)

        void contentDraw(void);
        double ScrollbarSize(void);

        void ProgressBarDrawMark(int posMark, int posMarkLast, int posCurrent, bool Start, bool isCurrent);
        int ProgressBarMarkPos(int P, int Total);

        void DecorDrawGlowRectHor(cPixmap *pixmap, int Left, int Top, int Width, int Height, tColor ColorBg);
        void DecorDrawGlowRectVer(cPixmap *pixmap, int Left, int Top, int Width, int Height, tColor ColorBg);
        
        void DecorDrawGlowRectTL(cPixmap *pixmap, int Left, int Top, int Width, int Height, tColor ColorBg);
        void DecorDrawGlowRectTR(cPixmap *pixmap, int Left, int Top, int Width, int Height, tColor ColorBg);
        void DecorDrawGlowRectBL(cPixmap *pixmap, int Left, int Top, int Width, int Height, tColor ColorBg);
        void DecorDrawGlowRectBR(cPixmap *pixmap, int Left, int Top, int Width, int Height, tColor ColorBg);
        
        void DecorDrawGlowEllipseTL(cPixmap *pixmap, int Left, int Top, int Width, int Height, tColor ColorBg, int type);
        void DecorDrawGlowEllipseTR(cPixmap *pixmap, int Left, int Top, int Width, int Height, tColor ColorBg, int type);
        void DecorDrawGlowEllipseBL(cPixmap *pixmap, int Left, int Top, int Width, int Height, tColor ColorBg, int type);
        void DecorDrawGlowEllipseBR(cPixmap *pixmap, int Left, int Top, int Width, int Height, tColor ColorBg, int type);

        //tColor Multiply(tColor Color, uint8_t Alpha);
        tColor SetAlpha(tColor Color, double am);
    public:
        cImageLoader imgLoader;

        cFlatBaseRender(void);
        ~cFlatBaseRender(void);

        void CreateFullOsd(void);
        void CreateOsd(int Left, int Top, int Width, int Height);

        void TopBarCreate(void);
        void TopBarSetTitle(cString title);
        void TopBarSetTitleExtra(cString extra1, cString extra2);
        void TopBarSetMenuIcon(cString icon);
        void TopBarSetMenuLogo(cString icon);
        void TopBarSetExtraIcon(cString icon);
        void TopBarUpdate(void);

        void ButtonsCreate(void);
        void ButtonsSet(const char *Red, const char *Green = NULL, const char *Yellow = NULL, const char *Blue = NULL);
        bool ButtonsDrawn(void);
        
        void MessageCreate(void);
        void MessageSet(eMessageType Type, const char *Text);
        void MessageClear(void);

        void ProgressBarDrawRaw(cPixmap *Pixmap, cPixmap *PixmapBg, cRect rec, cRect recBg, int Current, int Total, tColor ColorFg, tColor ColorBarFg, tColor ColorBg, int Type, bool SetBackground);
        void ProgressBarCreate(int Left, int Top, int Width, int Height, int MarginHor, int MarginVer, tColor ColorFg, tColor ColorBarFg, tColor ColorBg, int Type, bool SetBackground = false);
        void ProgressBarDrawBgColor(void);
        void ProgressBarDraw(int Current, int Total);
        void ProgressBarDrawMarks(int Current, int Total, const cMarks *Marks, tColor Color, tColor ColorCurrent);

        void ScrollbarDraw(cPixmap *Pixmap, int Left, int Top, int Height, int Total, int Offset, int Shown, bool CanScrollUp, bool CanScrollDown);
        int ScrollBarWidth(void);
        
        /* int FontType
         * 0 = NormalFont
         * 1 = FixedFont
         * 2 = SmallFont
         */
        
        void ContentCreate(int Left, int Top, int Width, int Height, int FontType);
        void ContentSet(const char *Text, tColor ColorFg, tColor ColorBg);
        bool ContentIsShown(void);
        bool ContentScrollable(void);
        bool ContentWillItBeScrollable(int Width, int Height, const char *Text, int FontType);
        int ContentScrollTotal(void);
        int ContentScrollOffset(void);
        int ContentVisibleLines(void);
        int ContentGetHeight(void);
        int ContentGetTextHeight(void);
        bool ContentScroll(bool Up, bool Page);
        void ContentClear(void);
        
        void DecorBorderDraw(int Left, int Top, int Width, int Height, int Size, int Type, tColor ColorFg, tColor ColorBg, int From = 0, bool Store = true);
        void DecorBorderClear(int Left, int Top, int Width, int Height, int Size);
        void DecorBorderClearAll(void);
        void DecorBorderRedrawAll(void);
        void DecorBorderClearByFrom(int From);
};