summaryrefslogtreecommitdiffhomepage
path: root/dragon/mouse_docs.rb
diff options
context:
space:
mode:
authorAmir Rajan <[email protected]>2020-07-30 16:45:24 -0500
committerAmir Rajan <[email protected]>2020-07-30 16:58:40 -0500
commiteb8b770e1952af371832f5f31e00dae09d498cf9 (patch)
tree0884e11fedbfa01c7ce9f1e028cb6c43a13d2052 /dragon/mouse_docs.rb
parent8d000345a3489988e9e86ee9fda9dcc6c70b7012 (diff)
downloaddragonruby-game-toolkit-contrib-eb8b770e1952af371832f5f31e00dae09d498cf9.tar.gz
dragonruby-game-toolkit-contrib-eb8b770e1952af371832f5f31e00dae09d498cf9.zip
OSS synced with 1.12.
Diffstat (limited to 'dragon/mouse_docs.rb')
-rw-r--r--dragon/mouse_docs.rb65
1 files changed, 65 insertions, 0 deletions
diff --git a/dragon/mouse_docs.rb b/dragon/mouse_docs.rb
new file mode 100644
index 0000000..ef4b923
--- /dev/null
+++ b/dragon/mouse_docs.rb
@@ -0,0 +1,65 @@
+# coding: utf-8
+# Copyright 2019 DragonRuby LLC
+# MIT License
+# mouse_docs.rb has been released under MIT (*only this file*).
+
+module MouseDocs
+ def docs_class
+<<-S
+* DOCS: ~GTK::Mouse~
+
+The mouse is accessible via ~args.inputs.mouse~:
+
+#+begin_src ruby
+ def tick args
+ # Rendering a label that shows the mouse's x and y position (via args.inputs.mouse).
+ args.outputs.labels << [
+ 10,
+ 710,
+ "The mouse's position is: \#{args.inputs.mouse.x} \#{args.inputs.mouse.y}."
+ ]
+ end
+#+end_src
+
+The mouse has the following properties.
+
+- ~args.inputs.mouse.x~: Returns the x position of the mouse.
+- ~args.inputs.mouse.y~: Returns the y position of the mouse.
+- ~args.inputs.mouse.moved~: Returns true if the mouse moved during the tick.
+- ~args.inputs.mouse.moved_at~: Returns the tick_count (~args.state.tick_count~) that the mouse was moved at. This property will be ~nil~ if the mouse didn't move.
+- ~args.inputs.mouse.global_moved_at~: Returns the global tick_count (~Kernel.global_tick_count~) that the mouse was moved at. This property will be ~nil~ if the mouse didn't move.
+- ~args.inputs.mouse.click~: Returns a ~GTK::MousePoint~ for that specific frame (~args.state.tick_count~) if the mouse button was pressed.
+- ~args.inputs.mouse.previous_click~: Returns a ~GTK::MousePoint~ for the previous frame (~args.state.tick_count - 1~) if the mouse button was pressed.
+- ~args.inputs.mouse.up~: Returns true if for that specific frame (~args.state.tick_count~) if the mouse button was released.
+- ~args.inputs.mouse.point~ | ~args.inputs.mouse.position~: Returns an ~Array~ which contains the ~x~ and ~y~ position of the mouse.
+- ~args.inputs.mouse.has_focus~: Returns true if the game window has the mouse's focus.
+- ~args.inputs.mouse.wheel~: Returns an ~GTK::OpenEntity~ that contains an ~x~ and ~y~ property which represents how much the wheel has moved. If the wheel has not moved within the tick, this property will be ~nil~.
+- ~args.inputs.mouse.button_left~: Returns true if the left mouse button is down.
+- ~args.inputs.mouse.button_right~: Returns true if the right mouse button is down.
+- ~args.inputs.mouse.button_middle~: Returns true if the middle mouse button is down.
+- ~args.inputs.mouse.button_bits~: Gives the bits for each mouse button and its current state.
+
+* DOCS: ~GTK::MousePoint~
+
+The ~GTK::MousePoint~ has the following properties.
+
+- ~x~: Integer representing the mouse's x.
+- ~y~: Integer representing the mouse's y.
+- ~point~: Array with the ~x~ and ~y~ values.
+- ~w~: Width of the point that always returns ~0~ (included so that it can seemlessly work with ~GTK::Geometry~ functions).
+- ~h~: Height of the point that always returns ~0~ (included so that it can seemlessly work with ~GTK::Geometry~ functions).
+- ~left~: This value is the same as ~x~ (included so that it can seemlessly work with ~GTK::Geometry~ functions).
+- ~right~: This value is the same as ~x~ (included so that it can seemlessly work with ~GTK::Geometry~ functions).
+- ~top~: This value is the same as ~y~ (included so that it can seemlessly work with ~GTK::Geometry~ functions).
+- ~bottom~: This value is the same as ~y~ (included so that it can seemlessly work with ~GTK::Geometry~ functions).
+- ~created_at~: The tick (~args.state.tick_count~) that this structure was created.
+- ~global_created_at~: The global tick (~Kernel.global_tick_count~) that this structure was created.
+
+S
+ end
+end
+
+class GTK::Mouse
+ extend Docs
+ extend MouseDocs
+end