Changeset 8353

Show
Ignore:
Timestamp:
02/02/12 11:45:41 (4 months ago)
Author:
westram
Message:
  • EDIT4 scrolling
    • EDIT4 uses two interleaved mechanisms to control scrolling. both perform similar calculations.
      • global canvas scrolling (like other ARB apps) in AW_window::calculate_scrollbars
      • local folding line calculation
    • EDIT4 is the only client which uses scrollbar indentation (affects the global slider pos calculation)
      • the scrollbar is indented by the height of top-area resp. the width of the name/group area
      • an additional offset (SLIDER_OFFSET) is added to that indentation
      • this offset was missing in calculation of lower/right folding lines (fixed)
    • other fixes
      • picture size announced by ED4_window::update_scrolled_rectangle was off by 1
  • behavioral fixes:
    • scrolling down completely, then increasing window height, then scrolling up completely and decreasing window height again, leaded to negative dimension of top-folding line.
      • Afterwards there was an empty area above the first entry in the scrollable area and EDIT4 refused to scroll down completely.
      • did not disappear, regardless what action was taken.
      • introduced by [8230]. partly fixed by [8347].
    • a similar effect could be reached by scrolling down completely and then folding the last group (introduced by [8347])
    • unfolding alignment, then setting cursor far enough right (beyond folded size), then folding alignment, leaded to completely empty display.
      • did not disappear, regardless what action was taken afterwards
      • introduced by [8347]
  • added debug code
    • print backtrace on negative folding line dimension
    • print mismatch if slider postions and folding line dimensions are out of sync
Location:
branches/e4fix/EDIT4
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/e4fix/EDIT4/ED4_root.cxx

    r8346 r8353  
    4646 
    4747ED4_WinContext ED4_WinContext::current_context; 
     48 
     49void ED4_folding_line::warn_illegal_dimension() { 
     50#if defined(DEBUG) 
     51    if (dimension<0.0) { 
     52        // e4_assert(0); // crashes gdb when called from scrollbar callback - so instead only dump backtrace 
     53        const char *msg = GBS_global_string("illegal dimension %f\n", dimension); 
     54        GBK_dump_backtrace(stderr, msg); 
     55    } 
     56#endif 
     57} 
    4858 
    4959void ED4_WinContext::warn_missing_context() const { 
  • branches/e4fix/EDIT4/ED4_window.cxx

    r8306 r8353  
    142142} 
    143143 
    144 ED4_returncode ED4_window::update_scrolled_rectangle() { 
    145     if (!scrolled_rect.exists()) 
    146         return ED4_R_IMPOSSIBLE; 
    147  
    148     AW::Rectangle srect = scrolled_rect.get_world_rect(); 
    149     scrolled_rect.set_rect_and_update_folding_line_positions(srect); 
    150  
    151     { 
    152         // update dimension and window position of folding lines at the borders of scrolled rectangle 
    153  
    154         int dx = aww->slider_pos_horizontal - slider_pos_horizontal; 
    155         int dy = aww->slider_pos_vertical - slider_pos_vertical; 
    156  
    157         scrolled_rect.add_to_top_left_dimension(dx, dy); 
    158     } 
    159  
    160     if (scrolled_rect.is_linked()) { 
    161         slider_pos_vertical   = aww->slider_pos_vertical; 
    162         slider_pos_horizontal = aww->slider_pos_horizontal; 
    163     } 
    164  
    165     const AW_screen_area& area_size = get_device()->get_area_size(); 
    166     scrolled_rect.calc_bottomRight_folding_dimensions(area_size.r, area_size.b); 
    167  
    168     update_window_coords(); 
    169  
    170     // update window scrollbars 
    171     AW_world rect = { 0, srect.height()-1, 0, srect.width()-1 }; 
    172     set_scrollbar_indents(); 
    173     aww->tell_scrolled_picture_size(rect); 
    174     aww->calculate_scrollbars(); 
    175  
    176     return ED4_R_OK; 
     144void ED4_window::update_scrolled_rectangle() { 
     145    if (scrolled_rect.exists()) { 
     146        e4_assert(scrolled_rect.is_linked()); 
     147 
     148        AW::Rectangle srect = scrolled_rect.get_world_rect(); 
     149        scrolled_rect.set_rect_and_update_folding_line_positions(srect); 
     150 
     151        // if slider positions stored in AW_window and ED4_window differ, 
     152        // we correct folding line dimensions: 
     153         
     154        { 
     155            // update dimension and window position of folding lines at the borders of scrolled rectangle 
     156            int dx = aww->slider_pos_horizontal - slider_pos_horizontal; 
     157            int dy = aww->slider_pos_vertical - slider_pos_vertical; 
     158 
     159            scrolled_rect.add_to_top_left_dimension(dx, dy); 
     160        } 
     161 
     162        const AW_screen_area& area_size = get_device()->get_area_size(); 
     163        scrolled_rect.calc_bottomRight_folding_dimensions(area_size.r, area_size.b); 
     164 
     165        update_window_coords(); // @@@ do at end of this function? (since it uses aww-slider_pos_horizontal, 
     166                                // which might get modified by calculate_scrollbars below); 
     167 
     168        // update window scrollbars 
     169        AW_world rect = { 0, srect.height(), 0, srect.width() }; 
     170        set_scrollbar_indents(); 
     171        aww->tell_scrolled_picture_size(rect); 
     172        aww->calculate_scrollbars(); 
     173 
     174        check_valid_scrollbar_values(); // test that AW_window slider positions and folding line dimensions are in sync 
     175    } 
     176 
     177    // store synced slider positions in ED4_window 
     178    slider_pos_vertical   = aww->slider_pos_vertical; 
     179    slider_pos_horizontal = aww->slider_pos_horizontal; 
    177180} 
    178181 
     
    336339} 
    337340 
    338 ED4_returncode ED4_window::set_scrollbar_indents() { 
    339     if (!scrolled_rect.exists()) return ED4_R_IMPOSSIBLE; 
    340      
    341     AW::Rectangle rect = scrolled_rect.get_window_rect(); 
    342     aww->set_vertical_scrollbar_top_indent(rect.top() + SLIDER_OFFSET); 
    343     aww->set_horizontal_scrollbar_left_indent(rect.left() + SLIDER_OFFSET); 
    344  
    345     return ED4_R_OK; 
     341void ED4_window::set_scrollbar_indents() { 
     342    if (scrolled_rect.exists()) { 
     343        AW::Rectangle rect = scrolled_rect.get_window_rect(); 
     344        aww->set_vertical_scrollbar_top_indent(rect.top() + SLIDER_OFFSET); 
     345        aww->set_horizontal_scrollbar_left_indent(rect.left() + SLIDER_OFFSET); 
     346    } 
    346347} 
    347348 
  • branches/e4fix/EDIT4/ed4_class.hxx

    r8347 r8353  
    319319    const ED4_folding_line *get_next() const { return next; } 
    320320 
    321     void set_dimension(AW_pos dim) { dimension = dim; } 
    322     void add_to_dimension(AW_pos offset) { dimension += offset; } 
     321    void warn_illegal_dimension(); 
     322 
     323    void set_dimension(AW_pos dim) { dimension = dim; warn_illegal_dimension(); } 
     324    void add_to_dimension(AW_pos offset) { dimension += offset; warn_illegal_dimension(); } 
    323325 
    324326    void set_pos(AW_pos p) { pos = p; } 
     
    426428    } 
    427429 
     430    AW_pos top_dim() const { return scroll_top->get_dimension(); } 
     431    AW_pos left_dim() const { return scroll_left->get_dimension(); } 
    428432 
    429433    bool exists() const { return scroll_top && scroll_bottom && scroll_left && scroll_right; } 
     
    481485 
    482486    void calc_bottomRight_folding_dimensions(int area_width, int area_height) { 
     487        area_width  -= SLIDER_OFFSET; 
     488        area_height -= SLIDER_OFFSET; 
     489 
    483490        AW_pos dim; 
    484491        if (bottom() > area_height) {   // our world doesn't fit vertically in our window 
     
    493500        } 
    494501 
    495         // e4_assert(scroll_top->dimension >= 0); // @@@ reactivate when refresh is fixed (or better move into set_dimension) 
    496         // e4_assert(scroll_bottom->dimension >= 0); 
    497502        e4_assert(dim == (scroll_top->get_dimension()+scroll_bottom->get_dimension())); 
    498         scroll_bottom->set_pos(world.bottom()-dim); 
     503        scroll_bottom->set_pos(world.bottom()-dim+SLIDER_OFFSET); 
    499504 
    500505        if (right()>area_width) {     // our world doesn't fit horizontally in our window 
     
    509514        } 
    510515 
    511         // e4_assert(scroll_left->dimension >= 0); // @@@ reactivate when refresh is fixed (or better move into set_dimension) 
    512         // e4_assert(scroll_right->dimension >= 0); 
    513516        e4_assert(dim == (scroll_left->get_dimension()+scroll_right->get_dimension())); 
    514         scroll_right->set_pos(world.right()-dim); 
     517        scroll_right->set_pos(world.right()-dim+SLIDER_OFFSET); 
    515518 
    516519        folding_dimensions_calculated = true; 
     
    538541        init_folding_lines(); 
    539542    } 
    540  
    541543}; 
    542544 
     
    705707class ED4_window : public ED4_foldable, virtual ED4_WinContextFree { // derived from Noncopyable 
    706708    ED4_window(const ED4_window&); // copy-constructor not allowed 
     709 
     710    void set_scrollbar_indents(); 
     711 
    707712public: 
    708713    AW_window              *aww;   // Points to Window 
     
    735740     
    736741    // functions concerned the scrolled area 
    737     ED4_returncode      update_scrolled_rectangle(); 
    738     ED4_returncode      set_scrollbar_indents(); 
    739     ED4_returncode      scroll_rectangle(int dx, int dy); 
    740     ED4_returncode      set_scrolled_rectangle(ED4_base *x_link, ED4_base *y_link, ED4_base *width_link, ED4_base *height_link); 
     742    void update_scrolled_rectangle(); 
     743    ED4_returncode scroll_rectangle(int dx, int dy); 
     744    ED4_returncode set_scrolled_rectangle(ED4_base *x_link, ED4_base *y_link, ED4_base *width_link, ED4_base *height_link); 
     745 
     746    bool scrollbars_and_scrolledRect_inSync() const { 
     747        // Scrolling in EDIT4 window uses redundant data 
     748        // - dimension of folding lines 
     749        // - slider positions in AW_window and ED4_window 
     750        // This function checks whether they are in sync. 
     751         
     752        bool inSync                    =  
     753            (scrolled_rect.top_dim()  == aww->slider_pos_vertical) && 
     754            (scrolled_rect.left_dim() == aww->slider_pos_horizontal); 
     755 
     756#if defined(DEBUG) 
     757        if (!inSync) { 
     758            fputs("scrollbars not in sync with scrolled_rect:\n", stderr); 
     759            fprintf(stderr, "    aww->slider_pos_vertical  =%i scrolled_rect->top_dim() =%f\n", aww->slider_pos_vertical, scrolled_rect.top_dim()); 
     760            fprintf(stderr, "    aww->slider_pos_horizontal=%i scrolled_rect->left_dim()=%f\n", aww->slider_pos_horizontal, scrolled_rect.left_dim()); 
     761        } 
     762#endif 
     763 
     764        return inSync; 
     765    } 
     766 
     767    void check_valid_scrollbar_values() { e4_assert(scrollbars_and_scrolledRect_inSync()); } 
    741768 
    742769    bool shows_xpos(int x) const { return x >= coords.window_left_clip_point && x <= coords.window_right_clip_point; }