Module: AMS::Cursor

Defined in:
cursor.rb

Class Method Summary (collapse)

Class Method Details

+ (Boolean) clear_clip

Unclip cursor.

Returns:

  • (Boolean)

    success

Since:

  • 2.0.0



109
110
111
# File 'cursor.rb', line 109

def clear_clip
  AMS::C.clear_clip_cursor()
end

+ (Boolean) clip_to_main_window

Clip cursor to main window.

Returns:

  • (Boolean)

    success

Since:

  • 2.0.0



95
96
97
# File 'cursor.rb', line 95

def clip_to_main_window
  AMS::C.set_cursor_clip_rect(*AMS::C.get_window_rect(AMS::C.get_main_window()))
end

+ (Boolean) clip_to_viewport

Clip cursor to view window.

Returns:

  • (Boolean)

    success

Since:

  • 2.0.0



102
103
104
# File 'cursor.rb', line 102

def clip_to_viewport
  AMS::C.set_cursor_clip_rect(*AMS::C.get_viewport_rect())
end

+ (Array<Fixnum>) get_clip_rect(mode = 1)

Get upper-left and lower-right coordinates of the cursor clip rectangle.

Parameters:

  • mode (Fixnum) (defaults to: 1)

    1 : Retrieve coordinates relative to screen origin. 2 : Retrieve coordinates relative to the viewport origin.

Returns:

  • (Array<Fixnum>)

    [x1,y1, x2,y2]

Since:

  • 2.0.0



58
59
60
61
62
63
64
65
66
67
68
# File 'cursor.rb', line 58

def get_clip_rect(mode = 1)
  rect = AMS::C.get_cursor_clip_rect()
  if mode == 2
    srect = AMS::C.get_viewport_rect()
    rect[0] -= srect[0]
    rect[1] -= srect[1]
    rect[2] -= srect[0]
    rect[3] -= srect[1]
  end
  rect
end

+ (Array<Fixnum>) get_pos(mode = 1)

Get cursor position.

Parameters:

  • mode (Fixnum) (defaults to: 1)

    1 : Retrieve coordinates relative to screen origin. 2 : Retrieve coordinates relative to the viewport origin.

Returns:

  • (Array<Fixnum>)

    [x,y]

Since:

  • 2.0.0



25
26
27
28
29
30
31
32
33
# File 'cursor.rb', line 25

def get_pos(mode = 1)
  x,y = AMS::C.get_cursor_pos()
  if mode == 2
    srect = AMS::C.get_viewport_rect()
    x -= srect[0]
    y -= srect[1]
  end
  return [x,y]
end

+ (Boolean) is_main_window_target?

Determine whether cursor is pointing at the main window.

Returns:

  • (Boolean)

Since:

  • 2.0.0



116
117
118
119
# File 'cursor.rb', line 116

def is_main_window_target?
  x,y = AMS::C.get_cursor_pos()
  AMS::C.get_main_window() == AMS::C.get_window_from_point(x,y)
end

+ (Boolean) is_viewport_target?

Determine whether cursor is within the view client area.

Returns:

  • (Boolean)

Since:

  • 2.0.0



124
125
126
127
128
# File 'cursor.rb', line 124

def is_viewport_target?
  rect = AMS::C.get_viewport_rect()
  x,y = AMS::C.get_cursor_pos()
  x.between?(rect[0], rect[2]) && y.between?(rect[1], rect[3])
end

+ (Boolean) is_visible?

Determine whether cursor is visible.

Returns:

  • (Boolean)

Since:

  • 2.0.0



15
16
17
# File 'cursor.rb', line 15

def is_visible?
  AMS::C.is_cursor_visible?()
end

+ (Boolean) set_clip_rect(x1, y1, x2, y2, mode = 1)

Set upper-left and lower-right coordinates of the cursor clip rectangle.

Parameters:

  • x1 (Fixnum)

    X coordinate of the upper-left corner of the rect.

  • y1 (Fixnum)

    Y coordinate of the upper-left corner of the rect.

  • x2 (Fixnum)

    X coordinate of the lower-right corner of the rect.

  • y2 (Fixnum)

    Y coordinate of the lower-right corner of the rect.

  • mode (Fixnum) (defaults to: 1)

    1 : Given coordinates are relative to screen origin. 2 : Given coordinates are relative to the viewport origin.

Returns:

  • (Boolean)

    success

Since:

  • 2.0.0



80
81
82
83
84
85
86
87
88
89
90
# File 'cursor.rb', line 80

def set_clip_rect(x1, y1, x2, y2, mode = 1)
  rect = AMS::C.get_cursor_clip_rect()
  if mode == 2
    srect = AMS::C.get_viewport_rect()
    x1 += srect[0]
    y1 += srect[1]
    x2 += srect[0]
    y2 += srect[1]
  end
  AMS::C.set_cursor_clip_rect(x1, y1, x2, y2)
end

+ (Boolean) set_pos(x, y, mode = 1)

Set cursor position.

Parameters:

  • x (Fixnum)
  • y (Fixnum)
  • mode (Fixnum) (defaults to: 1)

    1 : Given coordinates are relative to screen origin. 2 : Given coordinates are relative to the viewport origin.

Returns:

  • (Boolean)

    success

Since:

  • 2.0.0



43
44
45
46
47
48
49
50
# File 'cursor.rb', line 43

def set_pos(x, y, mode = 1)
  if mode == 2
    srect = AMS::C.get_viewport_rect()
    x += srect[0]
    y += srect[1]
  end
  AMS::C.set_cursor_pos(x,y)
end

+ (Boolean) show(state)

Show/Hide cursor.

Parameters:

  • state (Boolean)

Returns:

  • (Boolean)

    Whether cursor visibility state was changed.

Since:

  • 2.0.0



8
9
10
# File 'cursor.rb', line 8

def show(state)
  AMS::C.set_cursor_visible(state)
end