Index: trunk/src/layer_vis.c =================================================================== --- trunk/src/layer_vis.c (revision 29343) +++ trunk/src/layer_vis.c (revision 29344) @@ -71,6 +71,7 @@ pcb_layer_stack[i] = pcb_layer_stack[i - 1]; pcb_layer_stack[0] = NewTop; } + pcb_event(&PCB->hidlib, PCB_EVENT_LAYERVIS_CHANGED, NULL); } int pcb_layervis_change_group_vis(pcb_hidlib_t *hl, pcb_layer_id_t Layer, int On, pcb_bool ChangeStackOrder) Index: trunk/src/librnd/core/event.c =================================================================== --- trunk/src/librnd/core/event.c (revision 29343) +++ trunk/src/librnd/core/event.c (revision 29344) @@ -50,6 +50,7 @@ "pcbev_layers_changed", "pcbev_layer_changed_grp", "pcbev_layervis_changed", + "pcbev_layersel_changed", "pcbev_library_changed", "pcbev_font_changed", "pcbev_undo_post", Index: trunk/src/librnd/core/event.h =================================================================== --- trunk/src/librnd/core/event.h (revision 29343) +++ trunk/src/librnd/core/event.h (revision 29344) @@ -50,6 +50,7 @@ PCB_EVENT_LAYERS_CHANGED, /* called after layers or layer groups change (used to be the LayersChanged action) */ PCB_EVENT_LAYER_CHANGED_GRP, /* called after a layer changed its group; argument: layer pointer */ PCB_EVENT_LAYERVIS_CHANGED, /* called after the visibility of layers has changed */ + PCB_EVENT_LAYERSEL_CHANGED, /* called after the layer selection (which is the current layer) has changed */ PCB_EVENT_LIBRARY_CHANGED, /* called after a change in the footprint lib (used to be the LibraryChanged action) */ PCB_EVENT_FONT_CHANGED, /* called when a font has changed; argument is the font ID */ Index: trunk/src/tool_logic.c =================================================================== --- trunk/src/tool_logic.c (revision 29343) +++ trunk/src/tool_logic.c (revision 29344) @@ -41,6 +41,8 @@ #include "tool_logic.h" +static void tool_logic_chg_layer(conf_native_t *cfg, int arr_idx); + /*** Generic part, all rnd apps should do something like this ***/ static char tool_logic_cookie[] = "tool_logic"; @@ -76,6 +78,7 @@ } pcb_event_bind(PCB_EVENT_TOOL_SELECT_PRE, tool_logic_chg_mode, NULL, tool_logic_cookie); + pcb_event_bind(PCB_EVENT_LAYERVIS_CHANGED, tool_logic_chg_layer, NULL, tool_logic_cookie); } void pcb_tool_logic_uninit(void) @@ -87,6 +90,12 @@ /*** pcb-rnd-specific parts ***/ +static void tool_logic_chg_layer(conf_native_t *cfg, int arr_idx) +{ + if (PCB->RatDraw && !pcb_tool_get(pcbhl_conf.editor.mode)->allow_when_drawing_ratlines) + pcb_tool_select_by_name(&PCB->hidlib, "line"); +} + pcb_bool pcb_tool_is_saved = pcb_false; static void get_grid_lock_coordinates(int type, void *ptr1, void *ptr2, void *ptr3, pcb_coord_t * x, pcb_coord_t * y)