Date: | 2013-08-14 10:49:09 (10 years 7 months ago) |
---|---|
Author: | Maarten ter Huurne |
Commit: | b18e3fa6a81f3f5be141b84f8b1f67d180477d48 |
Message: | Don't pass screen coordinates to drawScrollBar() The scroll bar always spans the content area of the screen: the position and height depend only on the theme and not on who is drawing it. Note that the coordinates passed were wrong in most cases, so this commit fixes the scroll bar positioning for several dialogs. |
Files: |
src/browsedialog.cpp (1 diff) src/gmenu2x.cpp (1 diff) src/gmenu2x.h (1 diff) src/menu.cpp (1 diff) src/selector.cpp (1 diff) src/settingsdialog.cpp (1 diff) src/textdialog.cpp (1 diff) src/wallpaperdialog.cpp (1 diff) |
Change Details
src/browsedialog.cpp | ||
---|---|---|
282 | 282 | } |
283 | 283 | gmenu2x->s->clearClipRect(); |
284 | 284 | |
285 | gmenu2x->drawScrollBar( | |
286 | numRows,fl->size(), firstElement, clipRect.y, clipRect.h); | |
285 | gmenu2x->drawScrollBar(numRows,fl->size(), firstElement); | |
287 | 286 | gmenu2x->s->flip(); |
288 | 287 | } |
src/gmenu2x.cpp | ||
---|---|---|
1188 | 1188 | return x-6; |
1189 | 1189 | } |
1190 | 1190 | |
1191 | void GMenu2X::drawScrollBar(uint pagesize, uint totalsize, uint pagepos, uint top, uint height) { | |
1192 | if (totalsize<=pagesize) return; | |
1191 | void GMenu2X::drawScrollBar(uint pageSize, uint totalSize, uint pagePos) { | |
1192 | if (totalSize <= pageSize) { | |
1193 | // Everything fits on one screen, no scroll bar needed. | |
1194 | return; | |
1195 | } | |
1193 | 1196 | |
1194 | s->rectangle(resX-8, top, 7, height, skinConfColors[COLOR_SELECTION_BG]); | |
1197 | const uint top = skinConfInt["topBarHeight"] + 1; | |
1198 | const uint bottomBarHeight = 21; | |
1199 | const uint height = resY - top - (bottomBarHeight + 1); | |
1195 | 1200 | |
1196 | //internal bar total height = height-2 | |
1197 | //bar size | |
1198 | uint bs = (height-2) * pagesize / totalsize; | |
1199 | //bar y position | |
1200 | uint by = (height-2) * pagepos / totalsize; | |
1201 | by = top+2+by; | |
1202 | if (by+bs>top+height-2) by = top+height-2-bs; | |
1201 | s->rectangle(resX - 8, top, 7, height, skinConfColors[COLOR_SELECTION_BG]); | |
1203 | 1202 | |
1203 | const uint barSize = (height - 4) * pageSize / totalSize; | |
1204 | const uint barPos = (height - 4 - barSize) * pagePos / (totalSize - pageSize); | |
1204 | 1205 | |
1205 | s->box(resX-6, by, 3, bs, skinConfColors[COLOR_SELECTION_BG]); | |
1206 | s->box(resX - 6, top + 2 + barPos, 3, barSize, | |
1207 | skinConfColors[COLOR_SELECTION_BG]); | |
1206 | 1208 | } |
1207 | 1209 | |
1208 | 1210 | void GMenu2X::drawTopBar(Surface *s) { |
src/gmenu2x.h | ||
---|---|---|
190 | 190 | int drawButton(IconButton *btn, int x=5, int y=-10); |
191 | 191 | int drawButton(Surface *s, const std::string &btn, const std::string &text, int x=5, int y=-10); |
192 | 192 | int drawButtonRight(Surface *s, const std::string &btn, const std::string &text, int x=5, int y=-10); |
193 | void drawScrollBar(uint pagesize, uint totalsize, uint pagepos, uint top, uint height); | |
193 | void drawScrollBar(uint pageSize, uint totalSize, uint pagePos); | |
194 | 194 | |
195 | 195 | void drawTopBar(Surface *s=NULL); |
196 | 196 | void drawBottomBar(Surface *s=NULL); |
src/menu.cpp | ||
---|---|---|
231 | 231 | vector<Link*> §ionLinks = links[iSection]; |
232 | 232 | const uint numLinks = sectionLinks.size(); |
233 | 233 | gmenu2x->drawScrollBar( |
234 | linkRows, (numLinks + linkColumns - 1) / linkColumns, iFirstDispRow, | |
235 | topBarHeight + 1, height - topBarHeight - bottomBarHeight - 2); | |
234 | linkRows, (numLinks + linkColumns - 1) / linkColumns, iFirstDispRow); | |
236 | 235 | |
237 | 236 | //Links |
238 | 237 | const uint linksPerPage = linkColumns * linkRows; |
src/selector.cpp | ||
---|---|---|
124 | 124 | } |
125 | 125 | gmenu2x->s->clearClipRect(); |
126 | 126 | |
127 | gmenu2x->drawScrollBar(SELECTOR_ELEMENTS,fl.size(),firstElement,42,175); | |
127 | gmenu2x->drawScrollBar(SELECTOR_ELEMENTS, fl.size(), firstElement); | |
128 | 128 | gmenu2x->s->flip(); |
129 | 129 | |
130 | 130 | switch (gmenu2x->input.waitForPressedButton()) { |
src/settingsdialog.cpp | ||
---|---|---|
122 | 122 | } |
123 | 123 | gmenu2x->s->clearClipRect(); |
124 | 124 | |
125 | gmenu2x->drawScrollBar( | |
126 | numRows, voices.size(), firstElement, clipRect.y + 1, clipRect.h | |
127 | ); | |
125 | gmenu2x->drawScrollBar(numRows, voices.size(), firstElement); | |
128 | 126 | |
129 | 127 | //description |
130 | 128 | writeSubTitle(voices[sel]->getDescription()); |
src/textdialog.cpp | ||
---|---|---|
94 | 94 | } |
95 | 95 | |
96 | 96 | gmenu2x->s->clearClipRect(); |
97 | gmenu2x->drawScrollBar(rowsPerPage,text->size(),firstRow,42,gmenu2x->resY-65); | |
97 | gmenu2x->drawScrollBar(rowsPerPage, text->size(), firstRow); | |
98 | 98 | } |
99 | 99 | |
100 | 100 | void TextDialog::exec() { |
src/wallpaperdialog.cpp | ||
---|---|---|
110 | 110 | } |
111 | 111 | gmenu2x->s->clearClipRect(); |
112 | 112 | |
113 | gmenu2x->drawScrollBar(10,wallpapers.size(),firstElement,44,170); | |
113 | gmenu2x->drawScrollBar(10, wallpapers.size(), firstElement); | |
114 | 114 | gmenu2x->s->flip(); |
115 | 115 | |
116 | 116 | switch(gmenu2x->input.waitForPressedButton()) { |
Branches:
install_locations
master
opkrun
packages