RIUI 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb8de0a9a6ad212738359b0dfb4b35996b235afba556246317180457e78c2fff
4
- data.tar.gz: 915bb622575612ac8875231a40fbb8ad11e50480559cd73085df3f57e8502d30
3
+ metadata.gz: e1a38e303e77fe46c9b0573315644439dcdbcc20b573128b37a62afb6db0d346
4
+ data.tar.gz: 913e27253af8d68dcf9efbf0758addb0d3335172d212b1d04bb58ceb16163519
5
5
  SHA512:
6
- metadata.gz: 448b92ffa4b809f3a718cddfee04e0545c9877db8db22b415434082acf43374ec3d079111e2ca100c3a2b7495beb559ba2bef4090a4497cd7f84da9a160e1a3b
7
- data.tar.gz: cc049080ad7e718f419174c79f183630d8a652d40d4a2f78d1c802836fe471b1eab641df7fbba3e31bdcf59d3bd8361637648e63c82e08be5e9542274d7e9eb1
6
+ metadata.gz: b70238c656296f2408b83becb265e9c98d53cfe9045dc3bc21b3886698c39451b7e683d9f55e97028ce1706999f72b25313775780c86e58a320e9cce4e2ead9c
7
+ data.tar.gz: e3a2ed300f67ba2ffe1c53f22e145eba2df7810ab54a456fa7b3fe0a66eec65b44f3f69e6ab7a3752b237ac6d69d773a33abfbb43ded2f2d97d9461f7507fabe
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- RIUI (0.1.1)
4
+ RIUI (0.2.0)
5
5
  ruby2d (~> 0.5.1)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,7 +1,10 @@
1
+ [![Gem Version](https://badge.fury.io/rb/RIUI.svg)](https://badge.fury.io/rb/RIUI)
1
2
  # RIUI
2
3
 
3
4
  A small, simple Ruby user interface framework
4
5
 
6
+ **NOTE:** *This project is its very early stages of development. If you experience a bug or have an idea for a new feature, don't hesitate to open an issue*
7
+
5
8
  ## Installation
6
9
 
7
10
  Add this line to your application's Gemfile:
@@ -1,67 +1,87 @@
1
1
  require 'RIUI'
2
2
 
3
- @image = RIImage.new(x: 500, y: 275, image: "tree.png", width: 100, height: 75)
3
+ class Example < RIView
4
+ @image = RIImage.new(x: 500, y: 275, image: "tree.png", width: 100, height: 75)
5
+ puts 'ex 1'
6
+ def self.onreset
7
+ @image.setSize(width: @orig_w, height: @orig_h)
8
+ @slider1.reset
9
+ @slider2.reset
10
+ puts "click"
11
+ end
12
+ def self.on_slider1_change
13
+ @image.setSize(height: @slider1.value + @orig_h, width: @slider2.value + @orig_w)
14
+ @label.setText(text: "Image width: #{@slider1.value + @orig_h}, Image height: #{@slider2.value + @orig_w}")
15
+ end
4
16
 
5
- def onclick
6
- @image.setSize(width: @orig_w, height: @orig_h)
7
- @slider1.reset
8
- @slider2.reset
9
- end
10
- def on_slider1_change
11
- @image.setSize(height: @slider1.value + @orig_h, width: @slider2.value + @orig_w)
12
- end
13
-
14
- def on_slider2_change
15
- @image.setSize(height: @slider1.value + @orig_h, width: @slider2.value + @orig_w)
16
- end
17
+ def self.on_slider2_change
18
+ @image.setSize(height: @slider1.value + @orig_h, width: @slider2.value + @orig_w)
19
+ @label.setText(text: "Image width: #{@slider1.value + @orig_h}, Image height: #{@slider2.value + @orig_w}")
20
+ end
17
21
 
18
- actions = RIActions.new
19
- onclick = method(:onclick)
20
- @button1 = RIButton.new(x: 125, y: 100, width: 150, height: 100, color: "green", hover_color: "blue")
21
- @button1.onClick(onclick: onclick)
22
+ def self.setRed
23
+ @image.setColor(color: 'red')
24
+ puts 'red'
25
+ end
26
+ def self.setGreen
27
+ @image.setColor(color: 'green')
28
+ puts 'green'
29
+ end
30
+ def self.setBlue
31
+ @image.setColor(color: 'blue')
32
+ puts 'blue'
33
+ end
34
+ def self.setYellow
35
+ @image.setColor(color: 'yellow')
36
+ puts 'yellow'
37
+ end
38
+ @actions = RIActions.new
39
+ onclick = method(:onreset)
40
+ @button1 = RIButton.new(x: 150, y: 350, width: 100, height: 50, color: "green", hover_color: "blue")
41
+ @button1.onClick(onclick: onclick)
42
+ @button1.setLabel(text: "Reset", font: "SF-PRO-Text-Bold.otf", size: 15, color: "white")
22
43
 
23
- @button1.setLabel(text: "Reset", font: "SF-PRO-Text-Bold.otf", size: 25, color: "white")
44
+ @button2 = RIButton.new(x: 125, y: 100, width: 50, height: 50, color: 'red')
45
+ red = method(:setRed)
46
+ @button2.onClick(onclick: red)
24
47
 
25
- @slider1 = RISlider.new(length: 200, square_size: 10, x: 100, y: 250, ticks: 200)
26
- @slider1.setColors(line_color: "black", square_color: "blue")
27
- @slider1.setLabel(size: 20, font: 'SF-PRO-Text-Bold.otf', color: 'black')
28
- slider1Change = method(:on_slider1_change)
29
- @slider1.onChange(onchange: slider1Change)
48
+ @button3 = RIButton.new(x: 200, y: 100, width: 50, height: 50, color: 'green')
49
+ green = method(:setGreen)
50
+ @button3.onClick(onclick: green)
30
51
 
31
- @slider2 = RISlider.new(length: 200, square_size: 10, x: 100, y: 300, ticks: 200)
32
- @slider2.setColors(line_color: "black", square_color: "blue")
33
- @slider2.setLabel(size: 20, font: 'SF-PRO-Text-Bold.otf', color: 'black')
34
- slider2Change = method(:on_slider2_change)
35
- @slider2.onChange(onchange: slider2Change)
52
+ @button4 = RIButton.new(x: 125, y: 175, width: 50, height: 50, color: 'blue')
53
+ blue = method(:setBlue)
54
+ @button4.onClick(onclick: blue)
36
55
 
56
+ @button5 = RIButton.new(x: 200, y: 175, width: 50, height: 50, color: 'yellow')
57
+ yellow = method(:setYellow)
58
+ @button5.onClick(onclick: yellow)
37
59
 
38
- actions.add(@slider1)
39
- actions.add(@slider2)
40
- actions.add(@button1)
41
- @orig_h = @image.height
42
- @orig_w = @image.width
60
+ @slider1 = RISlider.new(length: 200, square_size: 10, x: 100, y: 250, ticks: 200)
61
+ @slider1.setColors(line_color: "black", square_color: "blue")
62
+ @slider1.setLabel(size: 20, font: 'SF-PRO-Text-Bold.otf', color: 'black')
63
+ slider1Change = method(:on_slider1_change)
64
+ @slider1.onChange(onchange: slider1Change)
43
65
 
66
+ @slider2 = RISlider.new(length: 200, square_size: 10, x: 100, y: 300, ticks: 200)
67
+ @slider2.setColors(line_color: "black", square_color: "blue")
68
+ @slider2.setLabel(size: 20, font: 'SF-PRO-Text-Bold.otf', color: 'black')
69
+ slider2Change = method(:on_slider2_change)
70
+ @slider2.onChange(onchange: slider2Change)
44
71
 
72
+ @label = RILabel.new(x: 300, y: 125, font: 'SF-PRO-Text-Bold.otf', size: 20, color: 'black', text: "Image width: #{@image.width}, Image height: #{@image.height}")
45
73
 
74
+ @actions.add(@slider1)
75
+ @actions.add(@slider2)
76
+ @actions.add(@button1)
77
+ @actions.add(@button2)
78
+ @actions.add(@button3)
79
+ @actions.add(@button4)
80
+ @actions.add(@button5)
81
+ @actions.add(@label)
82
+ @orig_h = @image.height
83
+ @orig_w = @image.width
46
84
 
47
-
48
- extend Ruby2D::DSL
49
- set background: 'white'
50
- set title: 'RIUI Example'
51
- show
52
-
53
- #on :mouse_down do |e|
54
- # if button1.contains(e.x, e.y)
55
- # puts 'Reset'
56
- # image.setSize(width: @orig_w, height: @orig_h)
57
- # slider1.reset
58
- # slider2.reset
59
- # end
60
- #end
61
- #update do
62
- # slider1.update_actions
63
- # slider2.update_actions
64
- # if(slider1.active || slider2.active)
65
- # image.setSize(height: slider1.value + @orig_h, width: slider2.value + @orig_w)
66
- # end
67
- #end
85
+ self.initialize(width: 700, height: 450, background_color: 'white', title: 'RIUI')
86
+ self.show
87
+ end
@@ -2,7 +2,9 @@ require "RIUI/version"
2
2
  require "RIUI/RIActions"
3
3
  require "RIUI/RIButton"
4
4
  require "RIUI/RIImage"
5
+ require "RIUI/RILabel"
5
6
  require "RIUI/RISlider"
7
+ require "RIUI/RIView"
6
8
  module RIUI
7
9
  # Your code goes here...
8
10
  end
@@ -18,7 +18,8 @@ class RIActions
18
18
  def holding; @holding; end
19
19
  def active; @active; end
20
20
  def initialized; @initialized; end
21
-
21
+ def objects; @objects; end
22
+
22
23
  private
23
24
 
24
25
  def actions
@@ -1,6 +1,6 @@
1
1
  class RIImage
2
2
 
3
- attr_accessor :image, :x, :y, :width, :height
3
+ attr_accessor :image, :x, :y, :width, :height, :color
4
4
 
5
5
  def initialize(opts={})
6
6
  @path = opts[:image] || "/"
@@ -16,6 +16,9 @@ class RIImage
16
16
  @image.remove
17
17
  @image = Image.new(path: @path, x: @x-@width/2, y: @y-@height/2, width: @width, height: @height)
18
18
  end
19
+ def setColor(opts=[:color])
20
+ @image.color = opts[:color]
21
+ end
19
22
  def width; @width; end
20
23
  def height; @height; end
21
24
  end
@@ -0,0 +1,21 @@
1
+ class RILabel
2
+ attr_accessor :x, :y, :font, :size, :color, :text
3
+ def initialize(opts = {})
4
+ @x = opts[:x] || 0
5
+ @y = opts[:y] || 0
6
+ @font = opts[:font] || ''
7
+ @size = opts[:size] || 20
8
+ @color = opts[:color] || 'black'
9
+ @text = opts[:text] || 'RIUI Label'
10
+ @label = Text.new(x: @x, y: @y, font: @font, size: @size, color: @color, text: @text)
11
+ end
12
+ def setText(opts = [:text])
13
+ @text = opts[:text]
14
+ @label.remove
15
+ @label = Text.new(x: @x, y: @y, font: @font, size: @size, color: @color, text: @text)
16
+ end
17
+ def update_actions; end
18
+ def mouse_up_actions; end
19
+ def mouse_down_actions(x, y); end
20
+ def mouse_move_actions(x, y); end
21
+ end
@@ -0,0 +1,19 @@
1
+ require 'ruby2d'
2
+ class RIView
3
+ attr_accessor :width, :height, :background_color, :title
4
+ def self.initialize(opts = {})
5
+ @width = opts[:width] || 250
6
+ @height = opts[:height] || 300
7
+ @background_color = opts[:background_color] || 'white'
8
+ @title = opts[:title] || "RIUI View"
9
+ end
10
+ def self.show
11
+ extend Ruby2D::DSL
12
+ set width: @width, height: @height, background: @background_color, title: @title
13
+ show
14
+ end
15
+ def self.exit
16
+ extend Ruby2D::DSL
17
+ close
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module RIUI
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
data/test.rb ADDED
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: RIUI
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - lukecrum20
@@ -91,8 +91,11 @@ files:
91
91
  - lib/RIUI/RIActions.rb
92
92
  - lib/RIUI/RIButton.rb
93
93
  - lib/RIUI/RIImage.rb
94
+ - lib/RIUI/RILabel.rb
94
95
  - lib/RIUI/RISlider.rb
96
+ - lib/RIUI/RIView.rb
95
97
  - lib/RIUI/version.rb
98
+ - test.rb
96
99
  homepage: https://github.com/lukecrum/RIUI
97
100
  licenses:
98
101
  - MIT