Commit 296284fe authored by Michael Natterer's avatar Michael Natterer 😴

app: rotate cursors that indicate a direction with the view

- reorder enum GimpCursorType to be in angular order
- add gimp_cursor_rotate(cursor_type, angle)
- rotate the shell's cursors automatically in the setter
parent 3a75ec32
......@@ -243,8 +243,8 @@ gimp_display_shell_real_set_cursor (GimpDisplayShell *shell,
break;
case GIMP_CURSOR_MODE_TOOL_CROSSHAIR:
if (cursor_type < GIMP_CURSOR_CORNER_TOP_LEFT ||
cursor_type > GIMP_CURSOR_SIDE_BOTTOM_RIGHT)
if (cursor_type < GIMP_CURSOR_CORNER_TOP ||
cursor_type > GIMP_CURSOR_SIDE_TOP_LEFT)
{
/* the corner and side cursors count as crosshair, so leave
* them and override everything else
......@@ -266,6 +266,8 @@ gimp_display_shell_real_set_cursor (GimpDisplayShell *shell,
}
}
cursor_type = gimp_cursor_rotate (cursor_type, shell->rotate_angle);
cursor_handedness = GIMP_GUI_CONFIG (shell->display->config)->cursor_handedness;
if (shell->cursor_handedness != cursor_handedness ||
......
......@@ -86,10 +86,6 @@ static GimpCursor gimp_cursors[] =
cursor_color_picker,
cursor_color_picker_x_hot, cursor_color_picker_y_hot
},
{
cursor_corner_top_left,
cursor_default_x_hot, cursor_default_y_hot
},
{
cursor_corner_top,
cursor_default_x_hot, cursor_default_y_hot
......@@ -99,27 +95,27 @@ static GimpCursor gimp_cursors[] =
cursor_default_x_hot, cursor_default_y_hot
},
{
cursor_corner_left,
cursor_corner_right,
cursor_default_x_hot, cursor_default_y_hot
},
{
cursor_corner_right,
cursor_corner_bottom_right,
cursor_default_x_hot, cursor_default_y_hot
},
{
cursor_corner_bottom_left,
cursor_corner_bottom,
cursor_default_x_hot, cursor_default_y_hot
},
{
cursor_corner_bottom,
cursor_corner_bottom_left,
cursor_default_x_hot, cursor_default_y_hot
},
{
cursor_corner_bottom_right,
cursor_corner_left,
cursor_default_x_hot, cursor_default_y_hot
},
{
cursor_side_top_left,
cursor_corner_top_left,
cursor_default_x_hot, cursor_default_y_hot
},
{
......@@ -131,11 +127,15 @@ static GimpCursor gimp_cursors[] =
cursor_default_x_hot, cursor_default_y_hot
},
{
cursor_side_left,
cursor_side_right,
cursor_default_x_hot, cursor_default_y_hot
},
{
cursor_side_right,
cursor_side_bottom_right,
cursor_default_x_hot, cursor_default_y_hot
},
{
cursor_side_bottom,
cursor_default_x_hot, cursor_default_y_hot
},
{
......@@ -143,11 +143,11 @@ static GimpCursor gimp_cursors[] =
cursor_default_x_hot, cursor_default_y_hot
},
{
cursor_side_bottom,
cursor_side_left,
cursor_default_x_hot, cursor_default_y_hot
},
{
cursor_side_bottom_right,
cursor_side_top_left,
cursor_default_x_hot, cursor_default_y_hot
}
};
......@@ -410,3 +410,31 @@ gimp_cursor_set (GtkWidget *widget,
gdk_window_set_cursor (gtk_widget_get_window (widget), cursor);
gdk_cursor_unref (cursor);
}
GimpCursorType
gimp_cursor_rotate (GimpCursorType cursor,
gdouble angle)
{
if (cursor >= GIMP_CURSOR_CORNER_TOP &&
cursor <= GIMP_CURSOR_SIDE_TOP_LEFT)
{
gint offset = (gint) (angle / 45 + 0.5);
if (cursor < GIMP_CURSOR_SIDE_TOP)
{
cursor += offset;
if (cursor > GIMP_CURSOR_CORNER_TOP_LEFT)
cursor -= 8;
}
else
{
cursor += offset;
if (cursor > GIMP_CURSOR_SIDE_TOP_LEFT)
cursor -= 8;
}
}
return cursor;
}
......@@ -19,16 +19,19 @@
#define __GIMP_CURSOR_H__
GdkCursor * gimp_cursor_new (GdkDisplay *display,
GimpHandedness cursor_handedness,
GimpCursorType cursor_type,
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier);
void gimp_cursor_set (GtkWidget *widget,
GimpHandedness cursor_handedness,
GimpCursorType cursor_type,
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier);
GdkCursor * gimp_cursor_new (GdkDisplay *display,
GimpHandedness cursor_handedness,
GimpCursorType cursor_type,
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier);
void gimp_cursor_set (GtkWidget *widget,
GimpHandedness cursor_handedness,
GimpCursorType cursor_type,
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier);
GimpCursorType gimp_cursor_rotate (GimpCursorType cursor,
gdouble angle);
#endif /* __GIMP_CURSOR_H__ */
......@@ -190,22 +190,22 @@ typedef enum /*< skip >*/
GIMP_CURSOR_MOVE,
GIMP_CURSOR_ZOOM,
GIMP_CURSOR_COLOR_PICKER,
GIMP_CURSOR_CORNER_TOP_LEFT,
GIMP_CURSOR_CORNER_TOP,
GIMP_CURSOR_CORNER_TOP_RIGHT,
GIMP_CURSOR_CORNER_LEFT,
GIMP_CURSOR_CORNER_RIGHT,
GIMP_CURSOR_CORNER_BOTTOM_LEFT,
GIMP_CURSOR_CORNER_BOTTOM,
GIMP_CURSOR_CORNER_BOTTOM_RIGHT,
GIMP_CURSOR_SIDE_TOP_LEFT,
GIMP_CURSOR_CORNER_BOTTOM,
GIMP_CURSOR_CORNER_BOTTOM_LEFT,
GIMP_CURSOR_CORNER_LEFT,
GIMP_CURSOR_CORNER_TOP_LEFT,
GIMP_CURSOR_SIDE_TOP,
GIMP_CURSOR_SIDE_TOP_RIGHT,
GIMP_CURSOR_SIDE_LEFT,
GIMP_CURSOR_SIDE_RIGHT,
GIMP_CURSOR_SIDE_BOTTOM_LEFT,
GIMP_CURSOR_SIDE_BOTTOM,
GIMP_CURSOR_SIDE_BOTTOM_RIGHT,
GIMP_CURSOR_SIDE_BOTTOM,
GIMP_CURSOR_SIDE_BOTTOM_LEFT,
GIMP_CURSOR_SIDE_LEFT,
GIMP_CURSOR_SIDE_TOP_LEFT,
GIMP_CURSOR_LAST
} GimpCursorType;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment