summaryrefslogtreecommitdiff
path: root/geometrymanager.c
blob: 9f2e9fbdd92adf1046a81ceb4e7554f79b708972 (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
#include "geometrymanager.h"

cGeometryManager::cGeometryManager() {
    SetOSDSize();
}

cGeometryManager::~cGeometryManager() {
}

void cGeometryManager::SetOSDSize(void) {
    osdWidth = cOsd::OsdWidth();
    osdHeight = cOsd::OsdHeight();
    osdLeft = cOsd::OsdLeft();
    osdTop = cOsd::OsdTop();
}

void cGeometryManager::SetGeometry(void) {
    SetDisplayMenuSizes();
    SetDisplayChannelSizes();
    SetDisplayReplaySizes();
    SetDisplayMessageSizes();
    SetDisplayTrackSizes();
    SetDisplayVolumeSizes();
}

bool cGeometryManager::GeometryChanged(void) {
    if ((osdWidth != cOsd::OsdWidth()) || 
        (osdHeight != cOsd::OsdHeight()) ||
        (osdLeft != cOsd::OsdLeft()) ||
        (osdTop != cOsd::OsdTop())) {
        dsyslog("nopacity: osd Size changed");
        dsyslog("nopacity: old osd size: top %d left %d size %d * %d", osdLeft, osdTop, osdWidth, osdHeight);
        SetOSDSize();
        dsyslog("nopacity: new osd size: top %d left %d size %d * %d", osdLeft, osdTop, osdWidth, osdHeight);
        return true;
    }
    return false;
}

void cGeometryManager::SetDisplayMenuSizes() {
    menuSpace = config.spaceMenu;
    
    menuWidthScrollbar = config.widthScrollbar;
    menuDateWidth = osdWidth * 0.3;
    
    menuHeaderHeight = osdHeight * config.headerHeight / 100;
    menuFooterHeight = osdHeight * config.footerHeight / 100;
    menuRssFeedHeight = (config.displayRSSFeed)?(osdHeight * config.rssFeedHeight / 100):0;
    menuContentHeight = osdHeight - menuHeaderHeight - menuFooterHeight - menuRssFeedHeight;

    menuContentWidthMain = osdWidth * config.menuWidthMain / 100;
    menuContentWidthSchedules = osdWidth * config.menuWidthSchedules / 100;
    menuContentWidthChannels = osdWidth * config.menuWidthChannels / 100;
    menuContentWidthTimers = osdWidth * config.menuWidthTimers / 100;
    menuContentWidthRecordings = osdWidth * config.menuWidthRecordings / 100;
    menuContentWidthSetup = osdWidth * config.menuWidthSetup / 100;
    menuContentWidthFull = osdWidth - config.widthScrollbar - config.spaceMenu;
    menuContentWidthMinimum = Minimum(menuContentWidthMain, 
                                  menuContentWidthSchedules, 
                                  menuContentWidthChannels,
                                  menuContentWidthTimers,
                                  menuContentWidthRecordings,
                                  menuContentWidthSetup);

    menuItemWidthDefault = menuContentWidthFull - 4 * config.spaceMenu;
    menuItemWidthMain = menuContentWidthMain - 4 * config.spaceMenu;
    menuItemWidthSchedule = menuContentWidthSchedules - 4 * config.spaceMenu;
    menuItemWidthChannel = menuContentWidthChannels - 4 * config.spaceMenu;
    menuItemWidthTimer = menuContentWidthTimers - 4 * config.spaceMenu;
    menuItemWidthRecording = menuContentWidthRecordings - 4 * config.spaceMenu;
    menuItemWidthSetup = menuContentWidthSetup - 4 * config.spaceMenu;
    menuItemWidthTracks = osdWidth * config.tracksWidth / 100 - 4;
    menuItemHeightMain = config.iconHeight + 2;
    menuItemHeightSchedule = config.menuItemLogoHeight + 2;
    menuItemHeightDefault = menuContentHeight / config.numDefaultMenuItems - config.spaceMenu;
    menuItemHeightRecordings = config.menuRecFolderSize + 2;
    menuItemHeightTracks = config.tracksItemHeight;

    menuButtonsBorder = menuFooterHeight / 6;
    menuButtonWidth = (osdWidth / 4) - 2 * menuButtonsBorder;
    menuButtonHeight = menuFooterHeight - 3 * menuButtonsBorder;
    
    menuDiskUsageWidth = menuDiskUsageHeight = osdWidth  * config.menuSizeDiskUsage / 100;
    menuTimersWidth = osdWidth  * config.menuWidthRightItems / 100;
    menuMessageWidth = 0.8 * osdWidth;
    menuMessageHeight = 0.1 * osdHeight;
}

void cGeometryManager::SetDisplayChannelSizes(void) {
    channelHeight = osdHeight * config.channelHeight / 100;
    channelTop = osdTop + osdHeight - channelHeight - config.channelBorderBottom;
    switch (config.logoPosition) {
        case lpLeft:
            channelWidth = osdWidth - (config.logoWidth + 2 * config.channelBorderVertical + config.logoBorder);
            channelX = config.logoWidth + config.channelBorderVertical + config.logoBorder;
            break;
        case lpRight:
            channelWidth = osdWidth - (config.logoWidth + 2 * config.channelBorderVertical + config.logoBorder);
            channelX = config.channelBorderVertical;
            break;
        case lpNone:
            channelWidth = osdWidth - 2 * config.channelBorderVertical;
            channelX = config.channelBorderVertical;
            break;
    }
    channelInfoWidth = channelWidth * 0.7;
    channelDateWidth = channelWidth - channelInfoWidth;   
    channelInfoHeight = channelHeight * 0.2;
    if (channelInfoHeight%2 != 0)
        channelInfoHeight++;
    channelProgressBarHeight = channelHeight * 0.1;
    channelStreamInfoHeight = channelHeight * 0.2;
    if (channelStreamInfoHeight%2 != 0)
        channelStreamInfoHeight++;
    channelEpgInfoHeight = channelHeight - channelInfoHeight - channelStreamInfoHeight - channelProgressBarHeight;
    channelEpgInfoLineHeight = channelEpgInfoHeight / 4;
    channelStreamInfoY = channelInfoHeight + channelProgressBarHeight + channelEpgInfoHeight;
    channelIconSize = config.statusIconSize;
    channelIconsWidth = 5*channelIconSize;
}

void cGeometryManager::SetDisplayReplaySizes(void) {
    replayHeight = osdHeight * config.replayHeight / 100;
    replayWidth = osdWidth - 2 * config.replayBorderVertical;
    replayHeaderHeight = replayHeight * 0.2;
    if (replayHeaderHeight%2 != 0)
        replayHeaderHeight++;
    replayFooterHeight = replayHeaderHeight;
    replayResolutionX = 10;
    replayResolutionY = 5;
    replayInfo2Height = max(replayHeaderHeight,config.resolutionIconSize+replayResolutionY*2-replayHeaderHeight);
    replayProgressBarHeight = 0.1 * replayHeight;
    if (replayProgressBarHeight%2 != 0)
        replayProgressBarHeight++;
    replayCurrentHeight = replayProgressBarHeight + config.fontReplay;
    replayControlsHeight = replayHeight - replayHeaderHeight - replayInfo2Height - replayFooterHeight - replayProgressBarHeight;
    if (replayControlsHeight < 11)
        replayControlsHeight = 11;
    replayInfoWidth = 0.75 * replayWidth - config.resolutionIconSize - 10;
    replayDateWidth = replayWidth - replayInfoWidth;

    replayJumpX = (replayWidth - 4 * replayControlsHeight)/2 + 5*replayControlsHeight;
    replayJumpY = replayHeaderHeight + replayInfo2Height + replayProgressBarHeight;
    replayJumpWidth = replayWidth - replayJumpX;
    replayJumpHeight = replayControlsHeight;

    replayIconBorder = 5;
    replayIconSize = min(replayControlsHeight - 2*replayIconBorder, 128);    
}

void cGeometryManager::SetDisplayMessageSizes(void) {
    messageWidth = osdWidth * config.messageWidth / 100;
    messageHeight = osdHeight * config.messageHeight / 100;
}

void cGeometryManager::SetDisplayTrackSizes(void) {
    trackWidth = osdWidth * config.tracksWidth / 100;
}

void cGeometryManager::SetDisplayVolumeSizes(void) {
    volumeWidth = osdWidth * config.volumeWidth / 100;
    volumeHeight = osdHeight * config.volumeHeight / 100;
    volumeLabelHeight = volumeHeight/3;
    volumeProgressBarWidth = 0.9 * volumeWidth;
    volumeProgressBarHeight = 0.3 * volumeHeight;
    if (volumeProgressBarHeight%2 != 0)
        volumeProgressBarHeight++;
}