Class: Gdk::Cursor
- Inherits:
-
Object
- Object
- Gdk::Cursor
- Extended by:
- GLib::Deprecatable
- Defined in:
- lib/gdk4/cursor.rb,
lib/gdk4/deprecated.rb
Overview
GdkCursor is used to create and destroy cursors.
Cursors are immutable objects, so once you created them, there is no way to modify them later. You should create a new cursor when you want to change something about it.
Cursors by themselves are not very interesting: they must be bound to a window for users to see them. This is done with [methodGdk.Surface.set_cursor] or [methodGdk.Surface.set_device_cursor]. Applications will typically use higher-level GTK functions such as gtk_widget_set_cursor() instead.
Cursors are not bound to a given [classGdk.Display], so they can be shared. However, the appearance of cursors may vary when used on different platforms.
Named and texture cursors
There are multiple ways to create cursors. The platform's own cursors can be created with [ctorGdk.Cursor.new_from_name]. That function lists the commonly available names that are shared with the CSS specification. Other names may be available, depending on the platform in use. On some platforms, what images are used for named cursors may be influenced by the cursor theme.
Another option to create a cursor is to use [ctorGdk.Cursor.new_from_texture] and provide an image to use for the cursor.
To ease work with unsupported cursors, a fallback cursor can be provided. If a [classGdk.Surface] cannot use a cursor because of the reasons mentioned above, it will try the fallback cursor. Fallback cursors can themselves have fallback cursors again, so it is possible to provide a chain of progressively easier to support cursors. If none of the provided cursors can be supported, the default cursor will be the ultimate fallback.
Class Method Summary collapse
Instance Method Summary collapse
-
#fallback ⇒ Gdk::Cursor
Cursor to fall back to if this cursor cannot be displayed.
-
#fallback=(fallback) ⇒ Gdk::Cursor
Cursor to fall back to if this cursor cannot be displayed.
-
#hotspot_x ⇒ Integer
X position of the cursor hotspot in the cursor image.
-
#hotspot_x=(hotspot_x) ⇒ Integer
X position of the cursor hotspot in the cursor image.
-
#hotspot_y ⇒ Integer
Y position of the cursor hotspot in the cursor image.
-
#hotspot_y=(hotspot_y) ⇒ Integer
Y position of the cursor hotspot in the cursor image.
-
#initialize(texture, hotspot_x, hotspot_y, fallback) ⇒ Gdk::Cursor
constructor
Creates a new cursor from a
GdkTexture. -
#name ⇒ String
Name of this this cursor.
-
#name=(name) ⇒ String
Name of this this cursor.
-
#texture ⇒ Gdk::Texture
The texture displayed by this cursor.
-
#texture=(texture) ⇒ Gdk::Texture
The texture displayed by this cursor.
Constructor Details
#initialize(texture, hotspot_x, hotspot_y, fallback) ⇒ Gdk::Cursor
Creates a new cursor from a GdkTexture.
Class Method Details
.new(*args) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/gdk4/cursor.rb', line 21 def new(*args) first_arg = args.first case first_arg when String, Symbol @caches[first_arg] ||= super else super end end |
Instance Method Details
#fallback ⇒ Gdk::Cursor
Cursor to fall back to if this cursor cannot be displayed.
#fallback=(fallback) ⇒ Gdk::Cursor
Cursor to fall back to if this cursor cannot be displayed.
#hotspot_x ⇒ Integer
X position of the cursor hotspot in the cursor image.
#hotspot_x=(hotspot_x) ⇒ Integer
X position of the cursor hotspot in the cursor image.
#hotspot_y ⇒ Integer
Y position of the cursor hotspot in the cursor image.
#hotspot_y=(hotspot_y) ⇒ Integer
Y position of the cursor hotspot in the cursor image.
#name ⇒ String
Name of this this cursor.
The name will be nil if the cursor was created from a texture.
#name=(name) ⇒ String
Name of this this cursor.
The name will be nil if the cursor was created from a texture.
#texture ⇒ Gdk::Texture
The texture displayed by this cursor.
The texture will be nil if the cursor was created from a name.
#texture=(texture) ⇒ Gdk::Texture
The texture displayed by this cursor.
The texture will be nil if the cursor was created from a name.