Changeset 8333

Show
Ignore:
Timestamp:
19/01/12 17:26:19 (4 months ago)
Author:
westram
Message:
  • when moving cursor vertically, scroll display if target terminal is only partly visible
  • fixed scroll_into_view (was confused about upper/lower bounding box of terminal; compensated part of confusion by doing wrong calculations)
  • moved visibility checks from ED4_base to ED4_window
    • removed ED4_D_VERTICAL_ALL (unused hack using size of ED4_base)
    • unique names
  • renamed ED4_remap::is_visible -> is_shown
Location:
branches/e4fix/EDIT4
Files:
5 modified

Legend:

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

    r8331 r8333  
    212212// ----------------- 
    213213 
    214 bool ED4_base::is_visible(ED4_window *in_ed4w, AW_pos x, AW_pos y, ED4_direction direction) { 
    215     // return true if position (world coordinates) is visible in_ed4w 
    216     // (tests only into direction) 
    217     bool        visible = true; 
    218     ED4_coords& coords  = in_ed4w->coords; 
    219  
    220     switch (direction) 
    221     { 
    222         case ED4_D_HORIZONTAL: 
    223             if ((long(x)<coords.window_left_clip_point) || 
    224                 (long(x)>coords.window_right_clip_point)) { 
    225                 visible = false; 
    226             } 
    227             break; 
    228         case ED4_D_VERTICAL: 
    229             if ((long(y)<coords.window_upper_clip_point) || 
    230                 (long(y)>coords.window_lower_clip_point)) { 
    231                 visible = false; 
    232             } 
    233             break; 
    234         case ED4_D_VERTICAL_ALL: // special case for scrolling (whole object visible) 
    235             if ((long(y) < coords.window_upper_clip_point) || 
    236                 (long(y) + extension.size[HEIGHT] > coords.window_lower_clip_point)) { 
    237                 visible = false; 
    238             } 
    239             break; 
    240         case ED4_D_ALL_DIRECTION: 
    241             if ((long(x) < coords.window_left_clip_point)  || 
    242                 (long(x) > coords.window_right_clip_point) || 
    243                 (long(y) < coords.window_upper_clip_point) || 
    244                 (long(y) > coords.window_lower_clip_point)) { 
    245                 visible = false; 
    246             } 
    247             break; 
    248         default: 
    249             visible = false; 
    250             e4_assert(0); 
    251             break; 
    252     } 
    253  
    254     return visible; 
    255 } 
    256  
    257 inline bool ranges_overlap(AW_pos p1, AW_pos p2, int r1, int r2) { 
     214inline bool ranges_overlap(int p1, int p2, int r1, int r2) { 
    258215    // return true if ranges p1..p2 and r1..r2 overlap 
    259216    e4_assert(p1 <= p2); 
     
    263220} 
    264221 
    265 bool ED4_base::is_visible(ED4_window *in_ed4w, AW_pos x1, AW_pos y1, AW_pos x2, AW_pos y2, ED4_direction IF_ASSERTION_USED(direction)) { 
     222inline bool range_contained_in(int p1, int p2, int r1, int r2) { 
     223    // return true if range p1..p2 is contained in range r1..r2 
     224    e4_assert(p1 <= p2); 
     225    e4_assert(r1 <= r2); 
     226 
     227    return p1 >= r1 && p2 <= r2; 
     228} 
     229 
     230bool ED4_window::partly_shows(int x1, int y1, int x2, int y2) const { 
    266231    // return true if rectangle x1/y1/x2/y2 overlaps with clipped screen 
    267     e4_assert(direction == ED4_D_ALL_DIRECTION); 
    268232    e4_assert(x1 <= x2); 
    269233    e4_assert(y1 <= y2); 
    270234 
    271     ED4_coords& coords  = in_ed4w->coords; 
    272  
    273235    bool visible = (ranges_overlap(x1, x2, coords.window_left_clip_point, coords.window_right_clip_point) && 
    274236                    ranges_overlap(y1, y2, coords.window_upper_clip_point, coords.window_lower_clip_point)); 
     
    277239} 
    278240 
     241bool ED4_window::completely_shows(int x1, int y1, int x2, int y2) const { 
     242    // return true if rectangle x1/y1/x2/y2 is contained in clipped screen 
     243    e4_assert(x1 <= x2); 
     244    e4_assert(y1 <= y2); 
     245 
     246    bool visible = (range_contained_in(x1, x2, coords.window_left_clip_point, coords.window_right_clip_point) && 
     247                    range_contained_in(y1, y2, coords.window_upper_clip_point, coords.window_lower_clip_point)); 
     248 
     249    return visible; 
     250} 
    279251 
    280252char *ED4_base::resolve_pointer_to_string_copy(int *) const { return NULL; } 
  • branches/e4fix/EDIT4/ED4_cursor.cxx

    r8332 r8333  
    955955    } 
    956956 
     957    // @@@ move parts of the following section into function is_hidden_by_parent() 
    957958    ED4_base *temp_parent = owner_of_cursor; 
    958959    while (temp_parent->parent) { 
     
    12821283 
    12831284    switch (owner_of_cursor->get_area_level(0)) { 
    1284         case ED4_A_TOP_AREA: { 
    1285             visible =  
    1286                 owner_of_cursor->is_visible(win, x1, 0, ED4_D_HORIZONTAL) || 
    1287                 owner_of_cursor->is_visible(win, x2, 0, ED4_D_HORIZONTAL); 
    1288             break; 
    1289         } 
    1290         case ED4_A_MIDDLE_AREA: 
    1291             visible = owner_of_cursor->is_visible(window(), x1, y1, x2, y2, ED4_D_ALL_DIRECTION); 
    1292             break; 
    1293         default: 
    1294             break; 
     1285        case ED4_A_TOP_AREA:    visible = win->shows_xpos(x1) || win->shows_xpos(x2); break; 
     1286        case ED4_A_MIDDLE_AREA: visible = win->partly_shows(x1, y1, x2, y2); break; 
     1287        default: break; 
    12951288    } 
    12961289 
    12971290    return visible; 
    12981291} 
     1292 
     1293bool ED4_cursor::is_completely_visible() const { 
     1294    e4_assert(owner_of_cursor); 
     1295    e4_assert(cursor_shape); // cursor is not drawn, cannot test visibility 
     1296 
     1297    AW_pos x, y; 
     1298    owner_of_cursor->calc_world_coords(&x, &y); 
     1299 
     1300    int x1, y1, x2, y2; 
     1301    cursor_shape->get_bounding_box(cursor_abs_x, int(y), x1, y1, x2, y2); 
     1302 
     1303    bool visible = false; 
     1304 
     1305    switch (owner_of_cursor->get_area_level(0)) { 
     1306        case ED4_A_TOP_AREA:    visible = win->shows_xpos(x1) && win->shows_xpos(x2); break; 
     1307        case ED4_A_MIDDLE_AREA: visible = win->completely_shows(x1, y1, x2, y2); break; 
     1308        default: break; 
     1309    } 
     1310 
     1311    return visible; 
     1312} 
     1313 
     1314#if defined(DEBUG) && 0 
     1315#define DUMP_SCROLL_INTO_VIEW 
     1316#endif 
    12991317 
    13001318void ED4_terminal::scroll_into_view(ED4_window *ed4w) { // scroll y-position only 
     
    13121330    int slider_pos_y; 
    13131331 
    1314     AW_pos termw_y_upper = termw_y - term_height; // upper border of terminal 
     1332    AW_pos termw_y_upper = termw_y; // upper border of terminal 
     1333    AW_pos termw_y_lower = termw_y + term_height; // lower border of terminal 
    13151334 
    13161335    if (termw_y_upper > coords->top_area_height) { // don't scroll if terminal is in top area (always visible) 
    13171336        if (termw_y_upper < coords->window_upper_clip_point) { 
    1318 #if defined(DEBUG) && 0 
    1319             printf("termw_y(%i)-term_height(%i) < window_upper_clip_point(%i)\n", 
    1320                    int(termw_y), term_height, int(coords->window_upper_clip_point)); 
     1337#ifdef DUMP_SCROLL_INTO_VIEW 
     1338            printf("termw_y_upper(%i) < window_upper_clip_point(%i)\n", 
     1339                   int(termw_y_upper), int(coords->window_upper_clip_point)); 
    13211340#endif // DEBUG 
    1322             slider_pos_y = int(termw_y - coords->top_area_height - term_height); 
     1341            slider_pos_y = int(termw_y_upper - coords->top_area_height - term_height); 
    13231342            scroll       = true; 
    13241343        } 
    1325         else if (termw_y > coords->window_lower_clip_point) { 
    1326 #if defined(DEBUG) && 0 
    1327             printf("termw_y(%i) > window_lower_clip_point(%i)\n", 
    1328                    int(termw_y), int(coords->window_lower_clip_point)); 
     1344        else if (termw_y_lower > coords->window_lower_clip_point) { 
     1345#ifdef DUMP_SCROLL_INTO_VIEW 
     1346            printf("termw_y_lower(%i) > window_lower_clip_point(%i)\n", 
     1347                   int(termw_y_lower), int(coords->window_lower_clip_point)); 
    13291348#endif // DEBUG 
    1330             slider_pos_y = int(termw_y - coords->top_area_height - win_ysize); 
     1349            slider_pos_y = int(termw_y_upper - coords->top_area_height - win_ysize); 
    13311350            scroll       = true; 
    13321351        } 
    13331352    } 
    13341353 
    1335 #if defined(DEBUG) && 0 
     1354#ifdef DUMP_SCROLL_INTO_VIEW 
    13361355    if (!scroll) { 
    1337         printf("No scroll needed (termw_y=%i termw_y_upper=%i term_height=%i window_upper_clip_point=%i window_lower_clip_point=%i)\n", 
    1338                int(termw_y), int(termw_y_upper), term_height, 
     1356        printf("No scroll needed (termw_y_upper=%i termw_y_lower=%i term_height=%i window_upper_clip_point=%i window_lower_clip_point=%i)\n", 
     1357               int(termw_y_upper), int(termw_y_lower), term_height, 
    13391358               int(coords->window_upper_clip_point), int(coords->window_lower_clip_point)); 
    13401359    } 
     
    13711390        show_cursor_at(terminal, scr_pos); 
    13721391 
    1373         if (!is_partly_visible()) { 
     1392        if (!is_completely_visible()) { 
    13741393            jump_sequence_pos(seq_pos, jump_type); 
    13751394        } 
  • branches/e4fix/EDIT4/ED4_edit_string.cxx

    r8277 r8333  
    294294    if (direction < 0) position--; 
    295295    for (pos = position; pos>=0 && pos < seq_len; pos += direction) { 
    296         if (!ADPP_IS_ALIGN_CHARACTER(seq[pos]) && remap->is_visible(pos)) { 
     296        if (!ADPP_IS_ALIGN_CHARACTER(seq[pos]) && remap->is_shown(pos)) { 
    297297            break; 
    298298        } 
     
    305305    if (direction < 0) position--; 
    306306    for (pos = position; pos >= 0 && pos < seq_len; pos += direction) { 
    307         if (ADPP_IS_ALIGN_CHARACTER(seq[pos]) && remap->is_visible(pos)) { 
     307        if (ADPP_IS_ALIGN_CHARACTER(seq[pos]) && remap->is_shown(pos)) { 
    308308            break; 
    309309        } 
     
    317317    if (direction < 0) position--; 
    318318    for (pos = position; pos >= 0 && pos < seq_len; pos += direction) { 
    319         if (remap->is_visible(pos)) { 
     319        if (remap->is_shown(pos)) { 
    320320            break; 
    321321        } 
     
    414414                                seq_pos += direction; 
    415415                            } 
    416                             while (legal_curpos(seq_pos) && !remap->is_visible(seq_pos)); 
     416                            while (legal_curpos(seq_pos) && !remap->is_shown(seq_pos)); 
    417417                        } 
    418418                        break; 
  • branches/e4fix/EDIT4/ed4_class.hxx

    r8331 r8333  
    647647 
    648648    bool is_partly_visible() const; 
     649    bool is_completely_visible() const; 
    649650 
    650651    void changeType(ED4_CursorType typ); 
     
    731732    ED4_returncode      set_scrolled_rectangle(ED4_base *x_link, ED4_base *y_link, ED4_base *width_link, ED4_base *height_link); 
    732733 
     734    bool shows_xpos(int x) const { return x >= coords.window_left_clip_point && x <= coords.window_right_clip_point; } 
     735    bool partly_shows(int x1, int y1, int x2, int y2) const; 
     736    bool completely_shows(int x1, int y1, int x2, int y2) const; 
     737     
    733738    void update_window_coords(); 
    734739 
     
    10621067 
    10631068    ED4_returncode  clear_background(int color=0); 
    1064  
    1065     bool is_visible(ED4_window *in_ed4w, AW_pos x, AW_pos y, ED4_direction direction); 
    1066     bool is_visible(ED4_window *in_ed4w, AW_pos x1, AW_pos y1, AW_pos x2, AW_pos y2, ED4_direction direction); 
    10671069 
    10681070    // functions concerned with links in the hierarchy 
     
    17531755    int was_changed() const { return changed; }     // mapping changed by last compile ? 
    17541756 
    1755     int is_visible(int position) const { return sequence_to_screen(position)>=0; } 
     1757    int is_shown(int position) const { return sequence_to_screen(position)>=0; } 
    17561758 
    17571759    ExplicitRange clip_screen_range(PosRange screen_range) const { return ExplicitRange(screen_range, screen_len-1); } 
  • branches/e4fix/EDIT4/ed4_defs.hxx

    r8192 r8333  
    236236    ED4_D_HORIZONTAL, 
    237237    ED4_D_ALL_DIRECTION, 
    238     ED4_D_VERTICAL_ALL 
    239238}; 
    240239