Exemplo n.º 1
0
/**************************************************************************
  Main handler for mouse movement handling.
**************************************************************************/
static Uint16 main_mouse_motion_handler(SDL_MouseMotionEvent *pMotionEvent, void *pData)
{
    static struct widget *pWidget;
    struct tile *ptile;

    /* stop evaluating button hold time when moving to another tile in medium
     * hold state or above */
    if (button_behavior.counting && (button_behavior.hold_state >= MB_HOLD_MEDIUM)) {
        ptile = canvas_pos_to_tile(pMotionEvent->x, pMotionEvent->y);
        if (tile_index(ptile) != tile_index(button_behavior.ptile)) {
            button_behavior.counting = FALSE;
        }
    }

    if(draw_goto_patrol_lines) {
        update_line(pMotionEvent->x, pMotionEvent->y);
    }

#ifndef UNDER_CE
    if (gui_sdl_fullscreen) {
        check_scroll_area(pMotionEvent->x, pMotionEvent->y);
    }
#endif /* UNDER_CE */

    if ((pWidget = find_next_widget_at_pos(NULL,
                                           pMotionEvent->x,
                                           pMotionEvent->y)) != NULL) {
        update_mouse_cursor(CURSOR_DEFAULT);
        if (!(get_wstate(pWidget) == FC_WS_DISABLED)) {
            widget_sellected_action(pWidget);
        }
    } else {
        if (pSellected_Widget) {
            unsellect_widget_action();
        } else {
            control_mouse_cursor(canvas_pos_to_tile(pMotionEvent->x, pMotionEvent->y));
        }
    }

    draw_mouse_cursor();

    return ID_ERROR;
}
Exemplo n.º 2
0
/**************************************************************************
  Triggered by the mouse moving on the mapcanvas, this function will
  update the mouse cursor and goto lines. 
**************************************************************************/
gboolean move_mapcanvas(GtkWidget *w, GdkEventMotion *ev, gpointer data)
{
  if (gui_gtk3_mouse_over_map_focus && !gtk_widget_has_focus(map_canvas)) {
    gtk_widget_grab_focus(map_canvas);
  }

  if (editor_is_active()) {
    return handle_edit_mouse_move(ev);
  }

  cur_x = ev->x;
  cur_y = ev->y;
  update_line(ev->x, ev->y);
  update_rect_at_mouse_pos();
  if (keyboardless_goto_button_down && hover_state == HOVER_NONE) {
    maybe_activate_keyboardless_goto(ev->x, ev->y);
  }
  control_mouse_cursor(canvas_pos_to_tile(ev->x, ev->y));

  return TRUE;
}
Exemplo n.º 3
0
/**************************************************************************
  This function is used to animate the mouse cursor. 
**************************************************************************/
static gint anim_cursor_cb(gpointer data)
{
  if (!cursor_timer_id) {
    return FALSE;
  }

  cursor_frame++;
  if (cursor_frame == NUM_CURSOR_FRAMES) {
    cursor_frame = 0;
  }

  if (cursor_type == CURSOR_DEFAULT) {
    gdk_window_set_cursor(root_window, NULL);
    cursor_timer_id = 0;
    return FALSE; 
  }

  gdk_window_set_cursor(root_window,
                fc_cursors[cursor_type][cursor_frame]);
  control_mouse_cursor(NULL);
  return TRUE;
}
Exemplo n.º 4
0
/**************************************************************************
  This function will reset the mouse cursor if it leaves the map.
**************************************************************************/
gboolean leave_mapcanvas(GtkWidget *widget, GdkEventCrossing *event)
{
  if (gtk_notebook_get_current_page(GTK_NOTEBOOK(top_notebook))
      != gtk_notebook_page_num(GTK_NOTEBOOK(top_notebook), map_widget)) {
    /* Map is not currently topmost tab. Do not use tile specific cursors. */
    update_mouse_cursor(CURSOR_DEFAULT);
    return TRUE;
  }

  /* Bizarrely, this function can be called even when we don't "leave"
   * the map canvas, for instance, it gets called any time the mouse is
   * clicked. */
  if (map_exists()
      && event->x >= 0 && event->y >= 0
      && event->x < mapview.width && event->y < mapview.height) {
    control_mouse_cursor(canvas_pos_to_tile(event->x, event->y));
  } else {
    update_mouse_cursor(CURSOR_DEFAULT);
  }

  update_unit_info_label(get_units_in_focus());
  return TRUE;
}
Exemplo n.º 5
0
void control_mouse_cursor_pos(int x, int y) {
    control_mouse_cursor(canvas_pos_to_tile(x, y));
}