/************************************************************************** Put the popup on a smart position, after the real size of the widget is known: left of the cursor if within the right half of the map, and vice versa; displace the popup so as not to obscure it by the mouse cursor; stay always within the map if possible. **************************************************************************/ static void popupinfo_positioning_callback(GtkWidget *w, GtkAllocation *alloc, gpointer data) { struct tmousepos *mousepos = data; gint x, y; struct tile *ptile; ptile = canvas_pos_to_tile(mousepos->x, mousepos->y); if (tile_to_canvas_pos(&x, &y, ptile)) { gint minx, miny, maxy; gdk_window_get_origin(gtk_widget_get_window(map_canvas), &minx, &miny); maxy = miny + gtk_widget_get_allocated_height(map_canvas); if (x > mapview.width/2) { /* right part of the map */ x += minx; y += miny + (tileset_tile_height(tileset) - alloc->height)/2; y = CLIP(miny, y, maxy - alloc->height); gtk_window_move(GTK_WINDOW(w), x - alloc->width, y); } else { /* left part of the map */ x += minx + tileset_tile_width(tileset); y += miny + (tileset_tile_height(tileset) - alloc->height)/2; y = CLIP(miny, y, maxy - alloc->height); gtk_window_move(GTK_WINDOW(w), x, y); } } }
/************************************************************************** Draws a cross-hair overlay on a tile **************************************************************************/ void put_cross_overlay_tile(struct tile *ptile) { int canvas_x, canvas_y; if (tile_to_canvas_pos(&canvas_x, &canvas_y, ptile)) { pixmap_put_overlay_tile(XtWindow(map_canvas), canvas_x, canvas_y, get_attention_crosshair_sprite(tileset)); } }