blue_shoes 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,11 @@
1
+ module Shoes
2
+ class Flow
3
+
4
+ def flow(style, &blk)
5
+ end
6
+
7
+ def draw painter
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,28 @@
1
+ module Shoes
2
+ class Image
3
+ # The full pixel height of the image. Normally, you can just use the height method to figure out how many pixels high the image is. But if you've resized the image or styled it to be larger or something, then height will return the scaled size.
4
+ def full_height
5
+ # returns a number
6
+ throw NotImplementedError
7
+ end
8
+
9
+ # The full pixel width of the image. See the full_height method for an explanation of why you might use this method rather than width.
10
+ def full_width
11
+ # returns a number
12
+ throw NotImplementedError
13
+ end
14
+
15
+ # The URL or file name of the image.
16
+ def path
17
+ # returns a string
18
+ throw NotImplementedError
19
+ end
20
+
21
+ # Swaps the image with a different one, loaded from a file or URL.
22
+ def path=(str)
23
+ # returns a string
24
+ throw NotImplementedError
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,4 @@
1
+ module Shoes
2
+ class LinkUrl
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Shoes
2
+ class Mask
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Shoes
2
+ class Mouse
3
+ end
4
+ end
@@ -0,0 +1,242 @@
1
+ module Shoes
2
+ class Native
3
+
4
+ # Displacing an element moves it. But without changing the layout around it. This is great for subtle animations, especially if you want to reserve a place for an element while it is still animating. Like maybe a quick button shake or a slot sliding into view.
5
+ def displace(left, top)
6
+ #returns self
7
+ throw NotImplementedError
8
+ end
9
+
10
+ # The vertical screen size of the element in pixels. In the case of images, this is not the full size of the image. This is the height of the element as it is shown right now.
11
+ def height
12
+ # returns a number
13
+ throw NotImplementedError
14
+ end
15
+
16
+ # Hides the element, so that it can't be seen. See also show and toggle.
17
+ def hide
18
+ # returns self
19
+ throw NotImplementedError
20
+ end
21
+
22
+ # Gets you the pixel position of the left edge of the element.
23
+ def left
24
+ # returns a number
25
+ throw NotImplementedError
26
+ end
27
+
28
+ # Moves the element to a specific pixel position within its slot. The element is still inside the slot. But it will no longer be stacked or flowed in with the other stuff in the slot. The element will float freely, now absolutely positioned instead.
29
+ def move(left, top)
30
+ # returns self
31
+ throw NotImplementedError
32
+ end
33
+
34
+ # Gets the object for this element's container. Also see the slot's contents to do the opposite: get a container's elements.
35
+ def parent
36
+ # returns a Shoes::Stack or Shoes::Flow
37
+ throw NotImplementedError
38
+ end
39
+
40
+ # Removes the element from its slot. (In other words: throws it in the garbage.) # The element will no longer be displayed.
41
+ def remove
42
+ # returns self
43
+ throw NotImplementedError
44
+ end
45
+
46
+ # Reveals the element, if it is hidden. See also hide and toggle.
47
+ def show
48
+ # returns self
49
+ throw NotImplementedError
50
+ end
51
+
52
+ # Gives you the full set of styles applied to this element, in the form of a Hash. While methods like width and height and top give you back specific pixel dimensions, using style[:width] or style[:top], you can get the original setting (things like "100%" for width or "10px" for top.)
53
+ def style
54
+ # returns styles
55
+ throw NotImplementedError
56
+ end
57
+
58
+ # Changes the style of an element. This could include the :width and :height of an element, the font :size of some text, the :stroke and :fill of a shape. Or any other number of style settings.
59
+ def style(styles)
60
+ # returns styles
61
+ throw NotImplementedError
62
+ end
63
+
64
+ # Hides an element if it is shown. Or shows the element, if it is hidden.
65
+ def toggle
66
+ # returns self
67
+ throw NotImplementedError
68
+ end
69
+
70
+ # Gets the pixel position of the top edge of the element.
71
+ def top
72
+ # returns a number
73
+ throw NotImplementedError
74
+ end
75
+
76
+ # Gets the pixel width for the full size of the element. This method always returns an exact pixel size. In the case of images, this is not the full width of the image, just the size it is shown at. See the height method for more.
77
+ def width
78
+ # returns a number
79
+ throw NotImplementedError
80
+ end
81
+
82
+ end
83
+
84
+ class Button < Native
85
+ # When a button is clicked, its click block is called. The block is handed self. Meaning: the button which was clicked.
86
+ def click(&blk)
87
+ # returns self
88
+ throw NotImplementedError
89
+ end
90
+
91
+ # Moves focus to the button. The button will be highlighted and, if the user hits Enter, the button will be clicked.
92
+ def focus
93
+ # returns self
94
+ throw NotImplementedError
95
+ end
96
+
97
+ end
98
+
99
+ class Check < Native
100
+ # Returns whether the box is checked or not. So, true means "yes, the box is checked!"
101
+ def checked?
102
+ throw NotImplementedError
103
+ end
104
+
105
+ # Marks or unmarks the check box. Using checked = false, for instance, unchecks the box.
106
+ def checked=(bool)
107
+ throw NotImplementedError
108
+ end
109
+
110
+ # When the check is clicked, its click block is called. The block is handed self, which is the check object which was clicked.
111
+ def click(&blk)
112
+ # returns self
113
+ throw NotImplementedError
114
+ end
115
+
116
+ # Moves focus to the check. The check will be highlighted and, if the user hits Enter, the check will be toggled between its checked and unchecked states.
117
+ def focus
118
+ # returns self
119
+ throw NotImplementedError
120
+ end
121
+
122
+ end
123
+
124
+ class EditBox < Native
125
+ # Each time a character is added to or removed from the edit box, its change block is called. The block is given self, which is the edit box object which has changed.
126
+ def change(&blk)
127
+ # returns self
128
+ throw NotImplementedError
129
+ end
130
+
131
+ # Moves focus to the edit box. The edit box will be highlighted and the user will be able to type into the edit box.
132
+ def focus
133
+ # returns self
134
+ throw NotImplementedError
135
+ end
136
+
137
+ # Return a string of characters which have been typed into the box.
138
+ def text
139
+ # returns self
140
+ throw NotImplementedError
141
+ end
142
+
143
+ # Fills the edit box with the characters of a string.
144
+ def text=(str)
145
+ throw NotImplementedError
146
+ end
147
+
148
+ end
149
+
150
+ class EditLine < Native
151
+ # Each time a character is added to or removed from the edit line, its change block is called. The block is given self, which is the edit line object which has changed.
152
+ def change(&blk)
153
+ # returns self
154
+ throw NotImplementedError
155
+ end
156
+
157
+ # Moves focus to the edit line. The edit line will be highlighted and the user will be able to type into the edit line.
158
+ def focus
159
+ # returns self
160
+ throw NotImplementedError
161
+ end
162
+
163
+ # Return a string of characters which have been typed into the line.
164
+ def text
165
+ # returns self
166
+ throw NotImplementedError
167
+ end
168
+
169
+ # Fills the edit line with the characters of a string.
170
+ def text=(str)
171
+ throw NotImplementedError
172
+ end
173
+ end
174
+
175
+ class ListBox < Native
176
+ # Selects the option in the list box that matches the string given by item.
177
+ def choose(item)
178
+ # returns self
179
+ throw NotImplementedErrror
180
+ end
181
+
182
+ # Moves focus to the list box. The list box will be highlighted and, if the user hits the up and down arrow keys, other options in the list will be selected.
183
+ def focus
184
+ # returns self
185
+ throw NotImplementedErrror
186
+ end
187
+
188
+ # Returns the complete list of strings that the list box presently shows as its options.
189
+ def items
190
+ # returns an array of strings
191
+ throw NotImplementedErrror
192
+ end
193
+
194
+ # Replaces the list box's options with a new list of strings.
195
+ def items=(arr)
196
+ # returns
197
+ throw NotImplementedErrror
198
+ end
199
+
200
+ # A string containing whatever text is shown highlighted in the list box right now. If nothing is selected, nil will be the reply.
201
+ def text
202
+ # returns a string
203
+ throw NotImplementedErrror
204
+ end
205
+
206
+ end
207
+
208
+ class Progress < Native
209
+ # a decimal number from 0.0 to 1.0, indicating how far along the progress bar is.
210
+ attr_accessor :fraction
211
+ end
212
+
213
+ class Radio < Native
214
+ # Returns whether the radio button is checked or not. So, true means "yes, it is checked!"
215
+ def checked?
216
+ # returns true or false
217
+ throw NotImplementedErrror
218
+ end
219
+
220
+ # Marks or unmarks the radio button. Using checked = false, for instance, clears the radio.
221
+ def checked=(bool)
222
+ throw NotImplementedErrror
223
+ end
224
+
225
+ # When the radio button is clicked, its click block is called. The block is handed self, which is an object representing the radio which was clicked.
226
+ def click(&blk)
227
+ # returns self
228
+ throw NotImplementedErrror
229
+ end
230
+
231
+ # Moves focus to the radio. The radio will be highlighted and, if the user hits Enter, the radio will be toggled between its marked and unmarked states.
232
+ def focus
233
+ # returns self
234
+ throw NotImplementedErrror
235
+ end
236
+
237
+ end
238
+
239
+ class Slider < Native
240
+ end
241
+
242
+ end
@@ -0,0 +1,72 @@
1
+ module Shoes
2
+ class Pattern
3
+ end
4
+
5
+ class Background < Pattern
6
+ attr_accessor :first
7
+ attr_accessor :last
8
+ attr_accessor :style
9
+
10
+ def initialize(pattern, style)
11
+ if pattern.first.length == 4
12
+ f = pattern.first
13
+ self.first = "#" + (f[1,1] * 2) + (f[2,1] * 2) + (f[3,1] * 2)
14
+ else
15
+ self.first = pattern.first
16
+ end
17
+ if pattern.last.length == 4
18
+ l = pattern.last
19
+ self.last = "#" + (l[1,1] * 2) + (l[2,1] * 2) + (l[3,1] * 2)
20
+ else
21
+ self.last = pattern.last
22
+ end
23
+ self.style = style
24
+ end
25
+
26
+ def r color
27
+ color[1,2].to_i 16
28
+ end
29
+ def g color
30
+ color[3,2].to_i 16
31
+ end
32
+ def b color
33
+ color[5,2].to_i 16
34
+ end
35
+
36
+ #draws the background
37
+ def draw painter
38
+ painter.setRenderHint Qt::Painter::Antialiasing
39
+ painter.setPen Qt::NoPen
40
+ painter.setBrush Qt::HorPattern
41
+ gradient = Qt::LinearGradient.new(0, 0, 0, 100)
42
+ bottom = Qt::Color.new(r(first),g(first),b(first))
43
+ top = Qt::Color.new(r(last),g(last),b(last))
44
+ gradient.setColorAt(0.0, bottom)
45
+ gradient.setColorAt(1.0, top)
46
+ painter.setBrush(Qt::Brush.new(gradient))
47
+ window = painter.window
48
+ window.setLeft(window.left + style[:margin])
49
+ window.setTop(window.top + style[:margin])
50
+ window.setHeight(window.height - style[:margin])
51
+ window.setWidth(window.width - style[:margin])
52
+ painter.drawRoundRect(window, style[:curve], style[:curve])
53
+ end
54
+
55
+ # Yanks out the color, gradient or image used to paint this background and places it in a normal Shoes::Pattern object.
56
+ def to_pattern
57
+ # returns a Shoes::Pattern
58
+ throw NotImplementedError
59
+ end
60
+
61
+ end
62
+
63
+ class Border < Pattern
64
+ #Creates a basic pattern object based on the color, gradient or image used to paint this border. The pattern may then be re-used in new borders and backgrounds.
65
+ def to_pattern
66
+ # returns a Shoes::Pattern
67
+ throw NotImplementedError
68
+ end
69
+
70
+ end
71
+
72
+ end
@@ -0,0 +1,4 @@
1
+ module Shoes
2
+ class Search
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Shoes
2
+ class Shape
3
+ end
4
+ end
@@ -0,0 +1,19 @@
1
+ require 'forwardable'
2
+ module Shoes
3
+ class Stack < Qt::VBoxLayout
4
+ extend Forwardable
5
+ # TODO most are still missing
6
+ def_delegators :@layout, :add_widget#, :add_layout, :add_item, :remove_item,
7
+ #:remove_widget, :remove_layout, :count
8
+ def initialize
9
+ super
10
+ @layout = Qt::VBoxLayout.new
11
+ add_layout(@layout, 0)
12
+ add_stretch(1)
13
+ end
14
+
15
+ def draw painter
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,48 @@
1
+ module Shoes
2
+
3
+ class Text
4
+ attr_accessor :text
5
+
6
+ def strong?; false; end
7
+
8
+ def initialize(text)
9
+ self.text = text.to_s
10
+ end
11
+
12
+ def to_s
13
+ text
14
+ end
15
+ end
16
+
17
+ class Code < Text
18
+ end
19
+
20
+ class Del < Text
21
+ end
22
+
23
+ class Em < Text
24
+ end
25
+
26
+ class Ins < Text
27
+ end
28
+
29
+ class Link < Text
30
+ end
31
+
32
+ class LinkHover < Text
33
+ end
34
+
35
+ class Span < Text
36
+ end
37
+
38
+ class Strong < Text
39
+ def strong?; true; end
40
+ end
41
+
42
+ class Sub < Text
43
+ end
44
+
45
+ class Sup < Text
46
+ end
47
+
48
+ end
@@ -0,0 +1,66 @@
1
+ module Shoes
2
+ class TextBlock
3
+ # Lists all of the strings and styled text objects inside this block.
4
+ def contents
5
+ # returns an array of elements
6
+ throw NotImplementedError
7
+ end
8
+
9
+ attr_accessor :label
10
+
11
+ def initialize(text)
12
+ if text.is_a? Shoes::Text
13
+ text = text
14
+ else
15
+ text = Shoes::Text.new(text.to_s)
16
+ end
17
+ self.label = Qt::Label.new
18
+ label.setText text.to_s
19
+ if text.strong?
20
+ label.setFont(Qt::Font.new("Purisa", 12, Qt::Font::Bold));
21
+ else
22
+ label.setFont(Qt::Font.new("Purisa", 12));
23
+ end
24
+ end
25
+
26
+ # Replaces the text of the entire block with the characters of a string.
27
+ def replace(str)
28
+ label.setText str.to_s
29
+ end
30
+
31
+ attr_accessor :text
32
+
33
+ # An alias for text. Returns a flattened string of all of this TextBlock's contents.
34
+ def to_s
35
+ label.getText
36
+ end
37
+
38
+ def to_label
39
+ label
40
+ end
41
+
42
+ end
43
+
44
+ class Banner < TextBlock
45
+ end
46
+
47
+ class Caption < TextBlock
48
+ end
49
+
50
+ class Inscription < TextBlock
51
+ end
52
+
53
+ class Para < TextBlock
54
+ def draw; end;
55
+ end
56
+
57
+ class Subtitle < TextBlock
58
+ end
59
+
60
+ class Tagline < TextBlock
61
+ end
62
+
63
+ class Title < TextBlock
64
+ end
65
+
66
+ end
@@ -0,0 +1,32 @@
1
+ module Shoes
2
+ class TimerBase
3
+ # Both types of timers automatically start themselves, so there's no need to use this normally. But if you stop a timer and would like to start it up again, then by all means: use this!
4
+ def start
5
+ # returns self
6
+ throw NotImplementedError
7
+ end
8
+
9
+ # Pauses the animation or timer. In the case of a one-shot timer that's already happened, it's already stopped and this method will have no effect.
10
+ def stop
11
+ # returns self
12
+ throw NotImplementedError
13
+ end
14
+
15
+ # If the animation or timer is stopped, it is started. Otherwise, if it is already running, it is stopped.
16
+ def toggle
17
+ # returns self
18
+ throw NotImplementedError
19
+ end
20
+ end
21
+
22
+ class Animation < TimerBase
23
+ end
24
+
25
+ class Every < TimerBase
26
+ end
27
+
28
+ class Timer < TimerBase
29
+
30
+ end
31
+
32
+ end
@@ -0,0 +1,4 @@
1
+ module BlueShoes
2
+ VERSION = "0.0.1"
3
+ end
4
+
@@ -0,0 +1,39 @@
1
+ module Shoes
2
+ class Video
3
+ # Removes the video from its slot. This will stop the video as well.
4
+ def remove
5
+ #returns self
6
+ throw NotImplementedError
7
+ end
8
+
9
+ # Reveals the video, if it has been hidden by the hide() method.
10
+ def show
11
+ # returns self
12
+ throw NotImplementedError
13
+ end
14
+
15
+ # Stops the video, if it is playing.
16
+ def stop
17
+ # returns self
18
+ throw NotImplementedError
19
+ end
20
+
21
+ # The time position of the video in milliseconds. So, if the video is 10 seconds into play, this method would return the number 10000.
22
+ def time
23
+ # returns a number
24
+ throw NotImplementedError
25
+ end
26
+
27
+ # Set the position of the video to a time in milliseconds.
28
+ def time=(number)
29
+ throw NotImplementedError
30
+ end
31
+
32
+ # Toggles the visibility of the video. If the video can be seen, then hide is called. Otherwise, show is called.
33
+ def toggle
34
+ # returns self
35
+ throw NotImplementedError
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,4 @@
1
+ module Shoes
2
+ class Widget
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Shoes
2
+ class Window
3
+ end
4
+ end
data/lib/blue_shoes.rb ADDED
@@ -0,0 +1,31 @@
1
+ #yay qt4!
2
+ require 'Qt4'
3
+
4
+ #we want to require everything in the blue_shoes directory.
5
+ Dir.glob("#{File.expand_path(File.dirname(__FILE__))}/blue_shoes/*.rb").each do |f|
6
+ require_relative f
7
+ end
8
+
9
+ module Shoes
10
+
11
+ #this is the code name for this release of Shoes.
12
+ RELEASE_NAME = "Suede"
13
+
14
+ #this is the ID, I haven't decided how to generate them yet.
15
+ RELEASE_ID = 1337
16
+
17
+ #this is the specific git revision. Haven't decided if I'm keeping it.
18
+ REVISION = "e3dce7d0b5c2a45f67b2a0d453aa8c31ecd4422e"
19
+
20
+ # a list of fonts
21
+ FONTS = []
22
+
23
+ # all the currently running apps, as Shoes::App objects
24
+ APPS = []
25
+
26
+ def self.app opts = {}, &blk
27
+ Shoes::App.new opts, blk
28
+ end
29
+
30
+ end
31
+
data/samples/hello.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.setup
4
+
5
+ require 'blue_shoes'
6
+
7
+ Shoes.app do
8
+ para "Hello, world."
9
+ end
@@ -0,0 +1,23 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.setup
4
+
5
+ require 'blue_shoes'
6
+
7
+ Shoes.app do
8
+ background rgb(0, 0, 0)
9
+ fill rgb(255, 255, 255)
10
+ rects = [
11
+ rect(0, 0, 50, 50),
12
+ rect(0, 0, 100, 100),
13
+ rect(0, 0, 75, 75)
14
+ ]
15
+ animate(24) do |i|
16
+ rects.each do |r|
17
+ r.move((0..400).rand, (0..400).rand)
18
+ end
19
+ end
20
+ button "OK", :top => 0.5, :left => 0.5 do
21
+ quit unless confirm "You ARE sure you're OK??"
22
+ end
23
+ end
Binary file