Changeset 8342

Show
Ignore:
Timestamp:
26/01/12 17:18:07 (4 months ago)
Author:
westram
Message:
  • replaced ED4_refresh_window by ED4_request_full_refresh
    • some callers now request fewer refreshes
    • all callers now cause refresh of ALL windows
  • ED4_cursor::ShowCursor no longer updates global AWARs when used for display only
    • conflicted with refresh of all windows (impossible to move cursor)
  • ED4_update_global_cursor_awars_allowed -> bool
  • refresh_window does not handle updates (it is only used to quickly draw the cursor)
    • refresh_window_simple cant no longer expect delete/update/resize requests have been handled (instead handle_update_requests() expects that)
    • renamed into special_window_refresh() to disencourage usage
  • removed implicit clearing of refresh flags previously done when refresh propagated down through windows, areas and hierarchy. Instead refresh_all_windows explicitely calls clear_refresh when done.
Location:
branches/e4fix/EDIT4
Files:
10 modified

Legend:

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

    r8341 r8342  
    361361#define EXPAND_SIZE 0 
    362362    if (window()->get_device()->reduceClipBorders(ymin-EXPAND_SIZE, ymax+1+EXPAND_SIZE, xmin-EXPAND_SIZE, xmax+1+EXPAND_SIZE)) { 
    363         // refresh terminal 
    364         int old_allowed_to_draw = allowed_to_draw; 
    365         allowed_to_draw = 0; 
    366         ED4_ROOT->refresh_window(1); 
    367         allowed_to_draw = old_allowed_to_draw; 
     363        // refresh terminal to hide cursor 
     364        bool previous = allowed_to_draw; 
     365        allowed_to_draw = false; 
     366        ED4_ROOT->special_window_refresh(); 
     367        allowed_to_draw = previous; 
    368368    } 
    369369    dev->pop_clip_scale(); 
     
    375375ED4_cursor::ED4_cursor(ED4_window *win_) : win(win_) { 
    376376    init(); 
    377     allowed_to_draw = 1; 
     377    allowed_to_draw = true; 
    378378    cursor_shape    = 0; 
    379379 
     
    801801} 
    802802 
    803 int ED4_update_global_cursor_awars_allowed = true; 
     803bool ED4_update_global_cursor_awars_allowed = true; 
    804804 
    805805void ED4_cursor::updateAwars() 
     
    10131013    delete_cursor(cursor_abs_x, owner_of_cursor); 
    10141014 
    1015     int old_allowed_to_draw = allowed_to_draw; 
     1015    bool previous = allowed_to_draw; 
    10161016    if (scroll_new_to >= 0) {   // scroll 
    10171017        int rel_x_new     = abs_x_new-coords->window_left_clip_point; 
     
    10281028            printf("jump_screen_pos auto-scrolls %i\n", scroll_amount); 
    10291029#endif 
    1030             allowed_to_draw = 0; 
     1030            allowed_to_draw = false; 
    10311031            ED4_horizontal_change_cb(aww, 0, 0); 
    10321032        } 
    10331033    } 
    10341034 
    1035     allowed_to_draw = 1; 
     1035    allowed_to_draw = true; 
    10361036    if (cursor_diff >= 0) { 
    10371037        ShowCursor(cursor_diff*length_of_char, ED4_C_RIGHT, ABS(cursor_diff)); 
     
    10401040        ShowCursor(cursor_diff*length_of_char, ED4_C_LEFT, ABS(cursor_diff)); 
    10411041    } 
    1042     allowed_to_draw = old_allowed_to_draw; 
     1042    allowed_to_draw = previous; 
    10431043} 
    10441044 
     
    12141214 
    12151215 
    1216 ED4_returncode ED4_cursor::ShowCursor(ED4_index offset_x, ED4_cursor_move move, int move_pos) 
    1217 { 
     1216ED4_returncode ED4_cursor::ShowCursor(ED4_index offset_x, ED4_cursor_move move, int move_pos) { 
    12181217    AW_pos x=0, y=0, x_help = 0, y_help; 
    12191218 
    12201219    owner_of_cursor->calc_world_coords(&x, &y); 
    12211220 
    1222     switch (move) 
    1223     { 
    1224         case ED4_C_RIGHT: 
    1225             screen_position += move_pos; 
    1226             break; 
    1227         case ED4_C_LEFT: 
    1228             screen_position -= move_pos; 
    1229             break; 
    1230         case ED4_C_NONE: 
     1221    int old_allow = ED4_update_global_cursor_awars_allowed; 
     1222    ED4_update_global_cursor_awars_allowed = true; 
     1223 
     1224    switch (move) { 
     1225        case ED4_C_RIGHT: screen_position += move_pos; break; 
     1226        case ED4_C_LEFT:  screen_position -= move_pos; break; 
     1227 
     1228        case ED4_C_NONE: // no move - only redisplay 
     1229            ED4_update_global_cursor_awars_allowed = false; // dont update here, otherwise refresh will disable cursor movement! 
    12311230            break; 
    12321231        default: 
     
    12361235 
    12371236    updateAwars(); 
     1237    ED4_update_global_cursor_awars_allowed = old_allow; 
    12381238 
    12391239    x_help = cursor_abs_x + offset_x; 
     
    13911391        owner_of_cursor->request_refresh(); // we have to refresh old owner of cursor 
    13921392        owner_of_cursor = NULL; 
    1393         ED4_ROOT->refresh_window(0); 
    13941393        DRAW = 1; 
    13951394    } 
  • branches/e4fix/EDIT4/ED4_dump.cxx

    r8155 r8342  
    261261    print_indented(NEXT_INDENT, GBS_global_string("refresh_horizontal_scrolling   = %u", refresh_horizontal_scrolling)); 
    262262    print_indented(NEXT_INDENT, GBS_global_string("delete_requested               = %u", delete_requested)); 
     263    print_indented(NEXT_INDENT, GBS_global_string("update_requested               = %u", update_requested)); 
    263264    closeDump(indent); 
    264265} 
  • branches/e4fix/EDIT4/ED4_edit_string.cxx

    r8333 r8342  
    772772                        } 
    773773                        case 'L': {  // CTRL-L = Refresh 
    774                             ED4_refresh_window(current_aww()); 
     774                            ED4_request_full_refresh(); 
    775775                            cursor_jump = ED4_JUMP_CENTERED; 
    776776                            break; 
  • branches/e4fix/EDIT4/ED4_main.cxx

    r8304 r8342  
    6666bool         move_cursor;                           // only needed for editing in consensus 
    6767bool         DRAW; 
    68 bool         last_window_reached;                   // needed for refreshing all windows (if TRUE refresh/...-flags will be cleared) 
    6968 
    7069void ED4_config_change_cb(AW_root *) 
     
    499498    ED4_ROOT->announce_useraction_in(aww); 
    500499} 
     500static void seq_colors_changed_cb(AW_window *) { 
     501    ED4_ROOT->request_refresh_for_sequence_terminals(); 
     502} 
    501503 
    502504int ARB_main(int argc, const char *argv[]) { 
     
    562564 
    563565    ED4_ROOT->st_ml = STAT_create_ST_ML(GLOBAL_gb_main); 
    564     ED4_ROOT->sequence_colors = new AWT_seq_colors(AW_ROOT_DEFAULT, ED4_G_SEQUENCES, (AW_CB)ED4_refresh_window, 0, 0); 
     566    ED4_ROOT->sequence_colors = new AWT_seq_colors(AW_ROOT_DEFAULT, ED4_G_SEQUENCES, (AW_CB)seq_colors_changed_cb, 0, 0); 
    565567 
    566568    ED4_ROOT->edk = new ed_key; 
  • branches/e4fix/EDIT4/ED4_manager.cxx

    r8341 r8342  
    936936    AW_device *device = current_device(); 
    937937 
    938     if (flag.hidden) { 
    939         if (last_window_reached && update_info.refresh) { 
    940             clear_refresh(); 
    941         } 
    942     } 
    943     else if (refresh_all || update_info.refresh) { 
     938    if (!flag.hidden && (refresh_all || update_info.refresh)) { 
    944939        const AW_screen_area& area_rect = device->get_area_size(); 
    945940 
     
    959954        int x1, y1, x2, y2; 
    960955        ED4_window& win = *current_ed4w(); 
    961         int old_last_window_reached = last_window_reached; 
    962  
    963         last_window_reached = 0; 
    964956        x1 = area_rect.l; 
    965957        for (const ED4_folding_line *flv = win.get_vertical_folding(); ; flv = flv->get_next()) { 
    966             int lastColumn = 0; 
    967  
    968958            if (flv) { 
    969959                x2 = int(flv->get_pos()); // @@@ use AW_INT ?  
    970                 if (!flv->get_next() && x2==area_rect.r) { 
    971                     lastColumn = 1; 
    972                 } 
    973960            } 
    974961            else { 
    975962                x2 = area_rect.r; 
    976                 lastColumn = 1; 
    977                 if (x1==x2) { 
    978                     break; // do not draw last range, if it's only 1 pixel width 
    979                 } 
     963                if (x1==x2) break; // do not draw last range, if it's only 1 pixel width 
    980964            } 
    981965 
    982966            y1 = area_rect.t; 
    983967            for (const ED4_folding_line *flh = win.get_horizontal_folding(); ; flh = flh->get_next()) { 
    984                 int lastRow = 0; 
    985  
    986968                if (flh) { 
    987969                    y2 = int(flh->get_pos()); // @@@ use AW_INT ?  
    988                     if (!flh->get_next() && y2==area_rect.b) { 
    989                         lastRow = 1; 
    990                     } 
    991970                } 
    992971                else { 
    993972                    y2 = area_rect.b; 
    994                     lastRow = 1; 
    995                     if (y1==y2) { 
    996                         break; // do not draw last range, if it's only 1 pixel high 
    997                     } 
    998                 } 
    999  
    1000                 if (lastRow && lastColumn) { 
    1001                     last_window_reached = old_last_window_reached; 
     973                    if (y1==y2) break; // do not draw last range, if it's only 1 pixel high 
    1002974                } 
    1003975 
     
    1007979                } 
    1008980                device->pop_clip_scale(); 
    1009  
    1010                 if (last_window_reached) { 
    1011                     update_info.set_refresh(0); 
    1012                     update_info.set_clear_at_refresh(0); 
    1013                 } 
    1014981 
    1015982                if (!flh) break; // break out after drawing lowest range 
     
    10591026#endif 
    10601027 
    1061     if (flag.hidden) { 
    1062         if (last_window_reached && update_info.refresh) { 
    1063             clear_refresh(); 
    1064         } 
    1065     } 
    10661028    if (!flag.hidden && (refresh_all || update_info.refresh)) { 
    10671029        if (update_info.clear_at_refresh && !is_cleared) { 
     
    11831145                } 
    11841146            } 
    1185  
    1186             if (last_window_reached) { 
    1187                 if (!flags_cleared && child->is_manager() && child->update_info.refresh) { 
    1188                     // if we didn't show a manager we must clear its children's refresh flags 
    1189                     child->to_manager()->clear_refresh(); 
    1190                 } 
    1191                 else { 
    1192                     child->update_info.set_refresh(0); 
    1193                     child->update_info.set_clear_at_refresh(0); 
    1194                 } 
    1195             } 
    11961147        } 
    11971148    } 
     
    12221173 
    12231174    update_info.set_refresh(0); 
     1175    update_info.set_clear_at_refresh(0); 
    12241176 
    12251177    return ED4_R_OK; 
  • branches/e4fix/EDIT4/ED4_no_class.cxx

    r8341 r8342  
    144144 
    145145    current_device()->reset(); 
    146     ED4_ROOT->refresh_window(1); 
     146    ED4_ROOT->special_window_refresh(); 
    147147 
    148148    GB_pop_transaction(GLOBAL_gb_main); 
     
    851851} 
    852852 
    853 void ED4_refresh_window(AW_window *aww) { 
    854     ED4_main_manager *mainman = ED4_ROOT->main_manager; 
    855     if (mainman) { // during startup we have no mainman 
    856         GB_transaction      ta(GLOBAL_gb_main); 
    857         ED4_LocalWinContext uses(aww); 
    858  
    859         if (mainman->update_info.delete_requested) { 
    860             mainman->delete_requested_children(); 
    861         } 
    862  
    863         mainman->update_info.set_clear_at_refresh(1); 
    864         mainman->Show(1); 
    865     } 
    866 } 
     853void ED4_request_full_refresh() { ED4_ROOT->main_manager->request_refresh(); } 
    867854 
    868855void ED4_set_reference_species(AW_window *aww, AW_CL disable, AW_CL ) { 
     
    908895    } 
    909896 
    910     ED4_refresh_window(aww); 
     897    ED4_ROOT->request_refresh_for_sequence_terminals(); 
    911898} 
    912899 
  • branches/e4fix/EDIT4/ED4_root.cxx

    r8341 r8342  
    9090 
    9191ED4_returncode ED4_root::refresh_window_simple(bool redraw) { 
    92     e4_assert(!main_manager->update_info.delete_requested); 
    93     e4_assert(!main_manager->update_info.update_requested); 
    94     e4_assert(!main_manager->update_info.resize); 
    95  
     92    // if 'redraw' -> update everything (ignoring refresh flag) 
    9693    int refresh_all = 0; 
    9794    if (redraw) { 
     
    10097    } 
    10198    main_manager->Show(refresh_all, 0); 
     99    if (redraw) { 
     100        main_manager->update_info.set_clear_at_refresh(0); 
     101    } 
    102102    return (ED4_R_OK); 
    103103} 
     
    118118        redraw = true; 
    119119    } 
    120 } 
    121  
    122 ED4_returncode ED4_root::refresh_window(bool redraw) { 
     120 
     121    // make sure all update request have been handled: 
     122    e4_assert(!main_manager->update_info.delete_requested); 
     123    e4_assert(!main_manager->update_info.update_requested); 
     124    e4_assert(!main_manager->update_info.resize); 
     125} 
     126 
     127ED4_returncode ED4_root::special_window_refresh() { 
    123128    // this function should only be used for window specific updates (i.e. cursor placement) 
    124     handle_update_requests(redraw); // @@@ problematic (causes refresh w/o win-context, clears flags w/o handling all windows) 
     129    bool redraw = true;  
     130    handle_update_requests(redraw); // @@@ problematic (causes refresh w/o win-context) 
    125131    return refresh_window_simple(redraw); 
     132    // do NOT clear_refresh_requests here!! this is no full refresh! 
    126133} 
    127134 
    128135ED4_returncode ED4_root::refresh_all_windows(bool redraw) { 
     136    // if 'redraw' -> update everything (ignoring refresh flag) 
    129137    GB_transaction dummy(GLOBAL_gb_main); 
    130     last_window_reached = 0; 
    131138 
    132139    handle_update_requests(redraw); 
     
    134141    ED4_window *window = first_window; 
    135142    while (window) { 
    136         if (!window->next) last_window_reached = 1; 
    137143        ED4_LocalWinContext uses(window); 
    138144        refresh_window_simple(redraw); 
     
    140146    } 
    141147 
     148    if (main_manager->update_info.refresh) main_manager->clear_refresh(); 
     149 
    142150    return (ED4_R_OK); 
    143151} 
    144  
    145152 
    146153void ED4_foldable::win_to_world_coords(AW_pos *xPtr, AW_pos *yPtr) { 
     
    827834 
    828835 
    829 void ED4_reload_helix_cb(AW_window *aww) { 
     836static void reload_helix_cb() {  
    830837    const char *err = ED4_ROOT->helix->init(GLOBAL_gb_main); 
    831838    if (err) aw_message(err); 
    832     ED4_refresh_window(aww); 
    833 } 
    834  
    835  
    836 void ED4_reload_ecoli_cb(AW_window *aww) { 
     839    ED4_request_full_refresh(); 
     840} 
     841 
     842 
     843static void reload_ecoli_cb() { 
    837844    const char *err = ED4_ROOT->ecoli_ref->init(GLOBAL_gb_main); 
    838845    if (err) aw_message(err); 
    839     ED4_refresh_window(aww); 
     846    ED4_request_full_refresh(); 
    840847} 
    841848 
     
    12841291    } 
    12851292 
    1286     ED4_refresh_window(aww); 
     1293    ED4_request_full_refresh(); 
    12871294} 
    12881295 
     
    14761483 
    14771484    awmm->create_menu("Edit", "E", AWM_ALL); 
    1478     awmm->insert_menu_topic("refresh",      "Refresh [Ctrl-L]",           "f", 0, AWM_ALL, (AW_CB)ED4_refresh_window,            0, 0); 
     1485    awmm->insert_menu_topic("refresh",      "Refresh [Ctrl-L]",           "f", 0, AWM_ALL, (AW_CB)ED4_request_full_refresh,       0, 0); 
    14791486    awmm->insert_menu_topic("load_current", "Load current species [GET]", "G", 0, AWM_ALL, ED4_get_and_jump_to_current_from_menu, 0, 0); 
    1480     awmm->insert_menu_topic("load_marked",  "Load marked species",        "m", 0, AWM_ALL, ED4_get_marked_from_menu,             0, 0); 
    1481     SEP________________________SEP; 
    1482     awmm->insert_menu_topic("refresh_ecoli",       "Reload Ecoli sequence",        "E", "ecoliref.hlp", AWM_ALL, (AW_CB)ED4_reload_ecoli_cb, 0, 0); 
    1483     awmm->insert_menu_topic("refresh_helix",       "Reload Helix",                 "H", "helix.hlp",    AWM_ALL, (AW_CB)ED4_reload_helix_cb, 0, 0); 
     1487    awmm->insert_menu_topic("load_marked",  "Load marked species",        "m", 0, AWM_ALL, ED4_get_marked_from_menu,              0, 0); 
     1488    SEP________________________SEP; 
     1489    awmm->insert_menu_topic("refresh_ecoli",       "Reload Ecoli sequence",        "E", "ecoliref.hlp", AWM_ALL, (AW_CB)reload_ecoli_cb, 0, 0); 
     1490    awmm->insert_menu_topic("refresh_helix",       "Reload Helix",                 "H", "helix.hlp",    AWM_ALL, (AW_CB)reload_helix_cb, 0, 0); 
    14841491    awmm->insert_menu_topic("helix_jump_opposite", "Jump helix opposite [Ctrl-J]", "J", 0,              AWM_ALL, ED4_helix_jump_opposite,    0, 0); 
    14851492    SEP________________________SEP; 
     
    19351942} 
    19361943 
    1937 AW_window *ED4_root::create_new_window()                            // only the first time, other cases: generate_window 
    1938 { 
     1944AW_window *ED4_root::create_new_window() { 
     1945    // only the first window, other windows are generated by generate_window 
    19391946    AW_device  *device     = NULL; 
    19401947    ED4_window *new_window = NULL; 
     
    19461953    ED4_calc_terminal_extentions(); 
    19471954 
    1948     last_window_reached     = 1; 
    19491955    DRAW                    = 1; 
    19501956    move_cursor             = 0; 
     
    19531959    ED4_init_notFoundMessage(); 
    19541960 
    1955     return (new_window->aww); 
     1961    return new_window->aww; 
    19561962} 
    19571963 
  • branches/e4fix/EDIT4/ED4_text_terminals.cxx

    r8290 r8342  
    611611    current_device()->pop_clip_scale(); 
    612612 
     613    // @@@ only request refresh of cursor and draw it at end of window-refresh ? might fix missing parts of cursor 
     614    // maybe do this check at top-level  
    613615    ED4_cursor *cursor = &current_cursor(); 
    614616    if (this == cursor->owner_of_cursor) { 
  • branches/e4fix/EDIT4/ed4_class.hxx

    r8341 r8342  
    610610}; 
    611611 
    612 extern int ED4_update_global_cursor_awars_allowed; 
     612extern bool ED4_update_global_cursor_awars_allowed; // update selected species/SAI/cursor position 
    613613 
    614614struct ED4_TerminalPredicate { 
     
    15231523    ED4_returncode resize_all(); 
    15241524 
    1525     ED4_returncode refresh_window(bool redraw); 
     1525    ED4_returncode special_window_refresh(); 
    15261526    ED4_returncode refresh_all_windows(bool redraw); 
    15271527 
     
    22232223 
    22242224void        ED4_quit_editor         (AW_window *aww, AW_CL cd1, AW_CL cd2);                 // Be Careful: Is this the last window? 
    2225 void        ED4_refresh_window      (AW_window *aww); 
     2225void        ED4_request_full_refresh(); 
    22262226 
    22272227void        ED4_store_curpos        (AW_window *aww, AW_CL cd1, AW_CL cd2); 
  • branches/e4fix/EDIT4/ed4_defs.hxx

    r8338 r8342  
    5252extern bool         move_cursor;                    // only needed for editing in consensus 
    5353extern bool         DRAW; 
    54 extern bool         last_window_reached;            // only needed for refreshing all windows 
    5554 
    5655// globally used defines and flags