Ignore:
Timestamp:
2010-05-28 07:39:52 (2 years ago)
Author:
kpoole
Message:

Episode 5

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Classes/widgets/menu.cpp

    r19 r26  
    2626#include "video.hpp" 
    2727#include "wml_separators.hpp" 
     28 
     29#include "construct_dialog.hpp" 
    2830 
    2931#include <numeric> 
     
    288290void menu::update_scrollbar_grip_height() 
    289291{ 
    290     set_full_size(items_.size()); 
    291     set_shown_size(max_items_onscreen()); 
     292    //set_full_size(items_.size()); 
     293    int h = heading_height(); 
     294    for(int i = 0; i < items_.size(); i++) 
     295        h += get_item_height(i);     
     296    set_full_size(h); 
     297    size_t max_height = (max_height_ == -1 ? (video().gety()*88)/100 : max_height_) - heading_height(); 
     298    if (max_height > h) 
     299        max_height = h; 
     300    set_shown_size(max_height); 
    292301} 
    293302 
     
    315324    } 
    316325 
     326    //update_scrollbar_grip_height(); 
     327    //set_measurements(w, h); 
     328    size_t max_height = (max_height_ == -1 ? (video().gety()*88)/100 : max_height_) - heading_height(); 
     329    h = heading_height(); 
     330    for(int i = 0; i < items_.size(); i++) 
     331        h += get_item_height(i);     
     332 
     333    if (max_height > h) 
     334        max_height = h; 
     335    set_measurements(w, max_height); 
    317336    update_scrollbar_grip_height(); 
    318     set_measurements(w, h); 
    319337} 
    320338 
     
    442460    const size_t max_height = (max_height_ == -1 ? (video().gety()*88)/100 : max_height_) - heading_height(); 
    443461#else 
    444     const size_t max_height = (max_height_ == -1 ? (video().gety()*66)/100 : max_height_) - heading_height(); 
     462    const size_t max_height = (max_height_ == -1 ? (video().gety()*88)/100 : max_height_) - heading_height(); 
    445463#endif 
    446464 
     
    467485    if(click_selects_) 
    468486        return; 
    469     adjust_position(selected_); 
     487    //adjust_position(selected_); 
     488    adjust_position(selected_ * item_height_); 
    470489} 
    471490 
     
    603622    if (height()==0 || hidden()) 
    604623        return; 
     624     
     625 
     626    if (scrollarea::handle_drag_event(event) == true) 
     627        return; 
    605628 
    606629    if(event.type == SDL_KEYDOWN) { 
     
    609632            key_press(event.key.keysym.sym); 
    610633    } else if(!mouse_locked() && ((event.type == SDL_MOUSEBUTTONUP && 
    611              (event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT)) || 
    612              event.type == DOUBLE_CLICK_EVENT)) { 
     634             (event.button.button == SDL_BUTTON_LEFT || event.button.button == SDL_BUTTON_RIGHT))  
     635//                                || event.type == DOUBLE_CLICK_EVENT 
     636                                  )) { 
    613637 
    614638        int x = 0; 
     
    882906            xpos -= widths[i]; 
    883907        if(type == HEADING_ROW && highlight_heading_ == int(i)) { 
    884             draw_solid_tinted_rectangle(xpos,rect.y,widths[i],rect.h,255,255,255,0.3); //,video().getSurface()); 
     908            //draw_solid_tinted_rectangle(xpos,rect.y,widths[i],rect.h,255,255,255,0.3); //,video().getSurface()); 
    885909        } 
    886910 
     
    942966void menu::draw_contents() 
    943967{ 
     968     
     969    // KP: now draw a nice frame! 
     970    SDL_Rect frame_rect = inner_location(); 
     971    gui::dialog_frame f(video(), "", gui::dialog_frame::preview_style, false); 
     972    f.layout(frame_rect); 
     973//  f.draw_background(); 
     974    f.draw_border(); 
     975     
     976     
    944977    SDL_Rect heading_rect = inner_location(); 
    945978    heading_rect.h = heading_height(); 
    946979    style_->draw_row(*this,0,heading_rect,HEADING_ROW); 
     980     
     981    // KP: make sure to clip 
     982    SDL_Rect content_rect = inner_location(); 
     983    content_rect.y += heading_rect.h; 
     984    content_rect.h -= heading_rect.h; 
     985    clip_rect_setter clippy(content_rect); 
     986     
    947987 
    948988    for(size_t i = 0; i != item_pos_.size(); ++i) { 
     
    9851025 
    9861026    bg_restore(); 
     1027     
     1028     
     1029     
    9871030 
    9881031    util::scoped_ptr<clip_rect_setter> clipper(NULL); 
     
    10851128SDL_Rect menu::get_item_rect_internal(size_t item) const 
    10861129{ 
    1087     unsigned int first_item_on_screen = get_position(); 
     1130    //unsigned int first_item_on_screen = get_position(); 
     1131    unsigned int first_item_on_screen = get_position() / item_height_; 
     1132    unsigned int leftovers = get_position() - (first_item_on_screen * item_height_); 
    10881133    if (item < first_item_on_screen || 
    1089         size_t(item) >= first_item_on_screen + max_items_onscreen()) { 
     1134        size_t(item) >= first_item_on_screen + max_items_onscreen() + 2) { 
    10901135        return empty_rect; 
    10911136    } 
     
    11011146        const SDL_Rect& prev = get_item_rect_internal(item-1); 
    11021147        y = prev.y + prev.h; 
     1148    } 
     1149    else 
     1150    { 
     1151        // KP: sub-item scrolling 
     1152        y -= leftovers; 
    11031153    } 
    11041154 
Note: See TracChangeset for help on using the changeset viewer.