Date:2014-01-16 15:49:51 (7 months 11 days ago)
Author:Paul Cercueil
Commit:408a991a9dc4a096572814afd2d5eb9a2a790805
Message:Remove hardcoded sizes and positions in WallpaperDialog

Files: src/wallpaperdialog.cpp (3 diffs)

Change Details

src/wallpaperdialog.cpp
8181    buttonbox.add(new IconButton(gmenu2x, ts, "skin:imgs/buttons/accept.png", gmenu2x->tr["Select wallpaper"]));
8282    buttonbox.add(new IconButton(gmenu2x, ts, "skin:imgs/buttons/cancel.png", gmenu2x->tr["Exit"]));
8383
84    unsigned int top, height;
85    tie(top, height) = gmenu2x->getContentArea();
86
87    int fontheight = gmenu2x->font->getHeight();
88    unsigned int nb_elements = height / fontheight;
89
8490    while (!close) {
85        if (selected>firstElement+9) firstElement=selected-9;
86        if (selected<firstElement) firstElement=selected;
91        if (selected > firstElement + nb_elements - 1)
92            firstElement = selected - nb_elements + 1;
93        if (selected < firstElement)
94            firstElement = selected;
8795
8896        //Wallpaper
8997        gmenu2x->sc[((string)"skin:wallpapers/" + wallpapers[selected]).c_str()]->blit(gmenu2x->s, 0, 0);
...... 
98106        buttonbox.paint(gmenu2x->s, 5);
99107
100108        //Selection
101        iY = selected-firstElement;
102        iY = 44+(iY*17);
103        gmenu2x->s->box(2, iY, 308, 16, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
109        iY = selected - firstElement;
110        iY = top + (iY * fontheight);
111        gmenu2x->s->box(2, iY, 308, fontheight, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
104112
105113        //Files & Directories
106        gmenu2x->s->setClipRect(0,41,311,179);
107        for (i=firstElement; i<wallpapers.size() && i<firstElement+10; i++) {
114        gmenu2x->s->setClipRect(0, top, 311, height);
115        for (i = firstElement; i < wallpapers.size()
116                    && i < firstElement + nb_elements; i++) {
108117            iY = i-firstElement;
109            gmenu2x->s->write(gmenu2x->font, wallpapers[i], 5, 52+(iY*17), Font::HAlignLeft, Font::VAlignMiddle);
118            gmenu2x->s->write(gmenu2x->font, wallpapers[i], 5,
119                        top + (iY * fontheight),
120                        Font::HAlignLeft, Font::VAlignTop);
110121        }
111122        gmenu2x->s->clearClipRect();
112123
113        gmenu2x->drawScrollBar(10, wallpapers.size(), firstElement);
124        gmenu2x->drawScrollBar(nb_elements, wallpapers.size(), firstElement);
114125        gmenu2x->s->flip();
115126
116127        switch(gmenu2x->input.waitForPressedButton()) {
...... 
123134                else selected -= 1;
124135                break;
125136            case InputManager::ALTLEFT:
126                if ((int)(selected-9) < 0) selected = 0;
127                else selected -= 9;
137                if ((int)(selected - nb_elements + 1) < 0)
138                    selected = 0;
139                else
140                    selected -= nb_elements - 1;
128141                break;
129142            case InputManager::DOWN:
130143                if (selected+1 >= wallpapers.size()) selected = 0;
131144                else selected += 1;
132145                break;
133146            case InputManager::ALTRIGHT:
134                if (selected+9 >= wallpapers.size()) selected = wallpapers.size()-1;
135                else selected += 9;
147                if (selected + nb_elements - 1 >= wallpapers.size())
148                    selected = wallpapers.size() - 1;
149                else
150                    selected += nb_elements - 1;
136151                break;
137152            case InputManager::ACCEPT:
138153                close = true;

Archive Download the corresponding diff file



interactive