glimmer-cs-calculator 1.1.0 → 1.1.4

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: 2f0e0c7392ffb6936fc36800a01b046828abdedd02a87b0b5e9ac9a2a2123df0
4
- data.tar.gz: 60f45b6cc247b361845f8dc183202b486be7e4347649b600a247b8b479faae07
3
+ metadata.gz: db2e112e9ef0539b67b5cccbd7ba2715d39ce0197a28949f8eee7b9d6d6e004c
4
+ data.tar.gz: a026682096bf13357bacbfb3863bf0ac95729c016c1bfc04eb1d8bac22b21e39
5
5
  SHA512:
6
- metadata.gz: 4deffe701265a3e8780556445e84b3f0438d89d3ec0cf4b2c3bea5e8ebd8697171f7c3d8a961272cafdbb9044516cf57da4c2566d3c238de4e82fa9a099a1aba
7
- data.tar.gz: b1579e191220e1d267bb3a5d525229f563378868008a543b02d88addfa31ab8bdade4af85bf892ab0974d3965dd683059edc4dc01517d20718cbcbedae17a25c
6
+ metadata.gz: 9e10ea594879dadba4ebacc35657e147f0d0ecaf7e629391f096c005987896bf9f6003a974a9621f6e637a3d48c671afb40e033fbd7c73d8814e798b6f84ffea
7
+ data.tar.gz: 3165ca8deefc79c121cccb9d66c1a192b767ebf34d7c1e1c865e52e8731e0651074b5b696ae39d173382489111c27ea28cd069925e33579900bb0c2499885b24
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.1.3
4
+
5
+ - Added back the `glimmer-dsl-swt` gem dependency (was mistakenly removed while testing with Glimmer DSL for Opal)
6
+
7
+ ## 1.1.2
8
+
9
+ - Official Opal (Web) support via [Glimmer DSL for Opal](https://github.com/AndyObtiva/glimmer-dsl-opal)
10
+
11
+ ## 1.1.1
12
+
13
+ - Official Windows support
14
+ - Official Linux support
15
+ - Refactorings, extracting method-based custom widgets
16
+
3
17
  ## 1.1.0
4
18
 
5
19
  - Upgrade support for glimmer-dsl-swt to 4.17.2.0 up to 5.0.0.0
data/README.md CHANGED
@@ -2,22 +2,48 @@
2
2
  ## [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=40 /> Glimmer Custom Shell](https://github.com/AndyObtiva/glimmer-dsl-swt#custom-shell-gem)
3
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-cs-calculator.svg)](http://badge.fury.io/rb/glimmer-cs-calculator)
4
4
 
5
+ Glimmer Calculator on Mac
6
+
5
7
  ![Calculator](glimmer-cs-calculator-screenshot.png)
6
8
 
9
+ Glimmer Calculator on Windows
10
+
11
+ ![Calculator](glimmer-cs-calculator-screenshot-windows.png)
12
+
13
+ Glimmer Calculator on Linux
14
+
15
+ ![Calculator](glimmer-cs-calculator-screenshot-linux.png)
16
+
17
+ Glimmer Calculator on [Opal](#glimmer-dsl-for-opal) (Web)
18
+
19
+ [![Calculator](glimmer-cs-calculator-screenshot-opal.png)](http://glimmer-cs-calculator-server.herokuapp.com)
20
+
7
21
  Glimmer Calculator is a sample desktop GUI application built with [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) (JRuby Desktop Development GUI Library).
8
22
 
9
- It is developed test-first following TDD (Test Driven Development).
10
- Design Patterns discovered in the process were Presenter/Facade and Command Pattern.
23
+ Architectural Pattern is MVP (Model View Presenter) thanks to [Glimmer data-binding](https://github.com/AndyObtiva/glimmer-dsl-swt#data-binding) support.
24
+
25
+ Glimmer Calculator was developed test-first following TDD (Test Driven Development) after [Glimmer Scaffolding](https://github.com/AndyObtiva/glimmer-dsl-swt#scaffolding).
26
+
27
+ Design Patterns discovered in the process were Facade (Presenter) and Command Pattern.
11
28
 
12
- Follows the MVP architectural pattern (Model View Presenter) thanks to [Glimmer data-binding](https://github.com/AndyObtiva/glimmer-dsl-swt#data-binding) support.
29
+ Here are the calculator commands under the [models directory](lib/models/glimmer/calculator):
13
30
 
14
- [<img alt="Glimmer Calculator Icon" src="glimmer-cs-calculator-icon.png" height=40 />Download Glimmer Calculator v1.1.0 for the Mac](https://www.dropbox.com/s/6c39vunxmx1eztz/Glimmer%20Calculator-1.1.0.dmg?dl=1)
31
+ ![Calculator Commands](glimmer-cs-calculator-command-pattern.png)
32
+
33
+ [<img alt="Glimmer Calculator Icon" src="glimmer-cs-calculator-icon.png" height=40 />Download Glimmer Calculator v1.1.1 DMG for Mac](https://www.dropbox.com/s/2wbyy0z0w875n39/Glimmer%20Calculator-1.1.1.dmg?dl=1)
34
+
35
+ [<img alt="Glimmer Calculator Icon" src="glimmer-cs-calculator-icon.png" height=40 />Download Glimmer Calculator v1.1.1 MSI for Windows](https://www.dropbox.com/s/e8b586s2xgjn9bg/Glimmer%20Calculator-1.1.1.msi?dl=1)
36
+
37
+ [<img alt="Glimmer Calculator Icon" src="glimmer-cs-calculator-icon.png" height=40 />Download Glimmer Calculator v1.1.3 GEM for Linux](#setup-instructions)
38
+
39
+ [<img alt="Glimmer Calculator Icon" src="glimmer-cs-calculator-icon.png" height=40 />Visit Glimmer Calculator v1.1.2 WEB for Opal](https://glimmer-cs-calculator-server.herokuapp.com)
15
40
 
16
41
  ## Platforms
17
42
 
18
- - Mac: Tested and [packaged](https://github.com/AndyObtiva/glimmer-dsl-swt#packaging--distribution) for the Mac. ([Download Here](https://www.dropbox.com/s/6c39vunxmx1eztz/Glimmer%20Calculator-1.1.0.dmg?dl=1))
19
- - Linux: Not tested/packaged for Linux, but should work by following setup instructions below.
20
- - Windows: Not tested/packaged for Windows, but should work by following setup instructions below.
43
+ - Mac: Tested and [packaged](https://github.com/AndyObtiva/glimmer-dsl-swt#packaging--distribution) for Mac. ([Download Here](https://www.dropbox.com/s/2wbyy0z0w875n39/Glimmer%20Calculator-1.1.1.dmg?dl=1))
44
+ - Windows: Tested and [packaged](https://github.com/AndyObtiva/glimmer-dsl-swt#packaging--distribution) for Windows. ([Download Here](https://www.dropbox.com/s/e8b586s2xgjn9bg/Glimmer%20Calculator-1.1.1.msi?dl=1))
45
+ - Linux: Tested and [packaged](http://rubygems.org/gems/glimmer-cs-calculator) for Linux (Follow [setup instructions](#setup-instructions) to install [gem](http://rubygems.org/gems/glimmer-cs-calculator) and run `calculator` command)
46
+ - Opal (Web): Tested with [Glimmer DSL for Opal](https://github.com/AndyObtiva/glimmer-dsl-opal) and [deployed to Heroku](https://glimmer-cs-calculator-server.herokuapp.com). Visit https://glimmer-cs-calculator-server.herokuapp.com
21
47
 
22
48
  ## Development Environment Pre-requisites
23
49
 
@@ -26,6 +52,8 @@ Follows the MVP architectural pattern (Model View Presenter) thanks to [Glimmer
26
52
 
27
53
  ## Setup Instructions
28
54
 
55
+ ### Glimmer DSL for SWT
56
+
29
57
  Install Calculator gem by running (`jgem`, `jruby -S gem`, or `gem` directly if you have RVM):
30
58
 
31
59
  ```
@@ -38,15 +66,15 @@ Afterwards, you may run `calculator` to bring up the calculator:
38
66
  calculator
39
67
  ```
40
68
 
41
- Note: If you cloned this project and bundle installed, you may invoke via `bin/calculator` instead.
69
+ Note: If you cloned this project and bundle installed, you may invoke via `bin/calculator` instead.
42
70
 
43
- ### Glimmer Custom Shell Reuse
71
+ #### Glimmer Custom Shell Reuse
44
72
 
45
- To reuse Calculator as a Glimmer Custom Shell inside another Glimmer application, add the
73
+ To reuse Calculator as a Glimmer Custom Shell inside another Glimmer application, add the
46
74
  following to the application's `Gemfile`:
47
75
 
48
76
  ```
49
- gem 'glimmer-cs-calculator', '1.1.0'
77
+ gem 'glimmer-cs-calculator', '1.1.4'
50
78
  ```
51
79
 
52
80
  Run:
@@ -57,6 +85,48 @@ jruby -S bundle
57
85
 
58
86
  And, then instantiate the Calculator custom shell in your Glimmer application via the `calculator` Glimmer DSL keyword.
59
87
 
88
+ ### Glimmer DSL for Opal
89
+
90
+ The app Rails server lives under: [server/glimmer-cs-calculator-server](server/glimmer-cs-calculator-server)
91
+
92
+ It is deployed to Heroku at: https://glimmer-cs-calculator-server.herokuapp.com
93
+
94
+ [Setup instructions](https://github.com/AndyObtiva/glimmer-dsl-opal#setup) from [Glimmer DSL for Opal](https://github.com/AndyObtiva/glimmer-dsl-opal) were followed in creating the Rails server.
95
+
96
+ This is the content of `app/assets/javascripts/application.rb`:
97
+
98
+ ```ruby
99
+ require 'glimmer-dsl-opal'
100
+
101
+ Document.ready? do
102
+ require 'glimmer-cs-calculator/launch'
103
+ end
104
+ ```
105
+
106
+ As you can see, Glimmer Calculator works as is by adding one require statement without needing to change a single line of its code thanks to [Glimmer DSL for Opal](https://github.com/AndyObtiva/glimmer-dsl-opal).
107
+
108
+ [![Calculator](glimmer-cs-calculator-screenshot-opal.png)](http://glimmer-cs-calculator-server.herokuapp.com)
109
+
110
+ #### CSS Themes
111
+
112
+ CSS can be applied externally in Rails onto any Rails Route serving an Opal app.
113
+
114
+ ##### Apple Calculator CSS Theme
115
+
116
+ Visit: http://glimmer-cs-calculator-server.herokuapp.com/welcomes/apple
117
+
118
+ [server/glimmer-cs-calculator-server/app/assets/stylesheets/welcomes_apple.scss](server/glimmer-cs-calculator-server/app/assets/stylesheets/welcomes_apple.scss)
119
+
120
+ [![Calculator](glimmer-cs-calculator-screenshot-opal-apple.png)](http://glimmer-cs-calculator-server.herokuapp.com/welcomes/apple)
121
+
122
+ ##### Tiles CSS Theme
123
+
124
+ Visit: http://glimmer-cs-calculator-server.herokuapp.com/welcomes/tiles
125
+
126
+ [server/glimmer-cs-calculator-server/app/assets/stylesheets/welcomes_tiles.scss](server/glimmer-cs-calculator-server/app/assets/stylesheets/welcomes_tiles.scss)
127
+
128
+ [![Calculator](glimmer-cs-calculator-screenshot-opal-tiles.png)](http://glimmer-cs-calculator-server.herokuapp.com/welcomes/tiles)
129
+
60
130
  ## Feature Suggestions
61
131
 
62
132
  [TODO.md](TODO.md)
@@ -85,4 +155,4 @@ Copyright (c) 2020 Andy Maleh. See [LICENSE.txt](LICENSE.txt) for further detail
85
155
 
86
156
  [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=40 />](https://github.com/AndyObtiva/glimmer) Built with [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) (JRuby Desktop Development GUI Library)
87
157
 
88
- Gladiator icon made by <a href="https://www.flaticon.com/authors/freepik" title="Freepik">Freepik</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a>
158
+ Glimmer Calculator icon made by <a href="https://www.flaticon.com/authors/freepik" title="Freepik">Freepik</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.1.4
data/bin/calculator CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ #!/usr/bin/env jruby
2
2
 
3
3
  require 'glimmer/launcher'
4
4
 
@@ -1,7 +1 @@
1
- #!/usr/bin/env ruby
2
-
3
- require_relative '../lib/glimmer-cs-calculator'
4
-
5
- include Glimmer
6
-
7
- calculator.open
1
+ require_relative '../lib/glimmer-cs-calculator/launch'
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: glimmer-cs-calculator 1.1.0 ruby lib
5
+ # stub: glimmer-cs-calculator 1.1.4 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "glimmer-cs-calculator".freeze
9
- s.version = "1.1.0"
9
+ s.version = "1.1.4"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Andy Maleh".freeze]
14
- s.date = "2020-09-27"
14
+ s.date = "2021-08-03"
15
15
  s.description = "Calculator - Glimmer Custom Shell".freeze
16
16
  s.email = "andy.am@gmail.com".freeze
17
17
  s.executables = ["glimmer-cs-calculator".freeze, "calculator".freeze]
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
28
28
  "bin/glimmer-cs-calculator",
29
29
  "glimmer-cs-calculator.gemspec",
30
30
  "lib/glimmer-cs-calculator.rb",
31
+ "lib/glimmer-cs-calculator/launch.rb",
31
32
  "lib/models/glimmer/calculator/command.rb",
32
33
  "lib/models/glimmer/calculator/command/all_clear.rb",
33
34
  "lib/models/glimmer/calculator/command/equals.rb",
@@ -39,11 +40,13 @@ Gem::Specification.new do |s|
39
40
  "lib/models/glimmer/calculator/command/operation/subtract.rb",
40
41
  "lib/models/glimmer/calculator/command/point.rb",
41
42
  "lib/models/glimmer/calculator/presenter.rb",
42
- "lib/views/glimmer/calculator.rb"
43
+ "lib/views/glimmer/calculator.rb",
44
+ "package/macosx/Glimmer Calculator.icns",
45
+ "package/windows/Glimmer Calculator.ico"
43
46
  ]
44
47
  s.homepage = "http://github.com/AndyObtiva/glimmer-cs-calculator".freeze
45
48
  s.licenses = ["MIT".freeze]
46
- s.rubygems_version = "3.1.4".freeze
49
+ s.rubygems_version = "3.1.6".freeze
47
50
  s.summary = "Calculator - Glimmer Custom Shell".freeze
48
51
 
49
52
  if s.respond_to? :specification_version then
@@ -51,7 +54,7 @@ Gem::Specification.new do |s|
51
54
  end
52
55
 
53
56
  if s.respond_to? :add_runtime_dependency then
54
- s.add_runtime_dependency(%q<glimmer-dsl-swt>.freeze, [">= 4.17.2.0", "< 5.0.0.0"])
57
+ s.add_runtime_dependency(%q<glimmer-dsl-swt>.freeze, [">= 4.17.2.2", "< 5.0.0.0"])
55
58
  s.add_runtime_dependency(%q<easily_typable>.freeze, ["~> 1.0.2"])
56
59
  s.add_development_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
57
60
  s.add_development_dependency(%q<jeweler>.freeze, ["= 2.3.9"])
@@ -59,7 +62,7 @@ Gem::Specification.new do |s|
59
62
  s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
60
63
  s.add_development_dependency(%q<glimmer-cs-gladiator>.freeze, [">= 0.3.0"])
61
64
  else
62
- s.add_dependency(%q<glimmer-dsl-swt>.freeze, [">= 4.17.2.0", "< 5.0.0.0"])
65
+ s.add_dependency(%q<glimmer-dsl-swt>.freeze, [">= 4.17.2.2", "< 5.0.0.0"])
63
66
  s.add_dependency(%q<easily_typable>.freeze, ["~> 1.0.2"])
64
67
  s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
65
68
  s.add_dependency(%q<jeweler>.freeze, ["= 2.3.9"])
@@ -1,4 +1,5 @@
1
1
  $LOAD_PATH.unshift(File.expand_path('..', __FILE__))
2
2
 
3
3
  require 'glimmer-dsl-swt'
4
+ require 'bigdecimal'
4
5
  require 'views/glimmer/calculator'
@@ -0,0 +1,5 @@
1
+ require_relative '../glimmer-cs-calculator'
2
+
3
+ include Glimmer
4
+
5
+ calculator.open
@@ -86,4 +86,14 @@ module Glimmer
86
86
  end
87
87
  end
88
88
 
89
- Dir[File.join(File.dirname(__FILE__), 'command', '**', '*.rb')].each {|f| require(f)}
89
+ # Dir[File.join(File.dirname(__FILE__), 'command', '**', '*.rb')].each {|f| require(f)}
90
+
91
+ require 'models/glimmer/calculator/command/all_clear'
92
+ require 'models/glimmer/calculator/command/equals'
93
+ require 'models/glimmer/calculator/command/number'
94
+ require 'models/glimmer/calculator/command/operation'
95
+ require 'models/glimmer/calculator/command/point'
96
+ require 'models/glimmer/calculator/command/operation/add'
97
+ require 'models/glimmer/calculator/command/operation/divide'
98
+ require 'models/glimmer/calculator/command/operation/multiply'
99
+ require 'models/glimmer/calculator/command/operation/subtract'
@@ -13,8 +13,8 @@ module Glimmer
13
13
  end
14
14
 
15
15
  def calculate
16
- calculation_result = number1.send(operation_method, number2)
17
- calculation_result.to_s.match(/\.0+$/) ? calculation_result.to_i : calculation_result
16
+ calculation_result = BigDecimal.new(number1.to_s).send(operation_method, BigDecimal.new(number2.to_s)).to_s('F')
17
+ calculation_result.match(/\.0+$/) ? calculation_result.to_i : calculation_result
18
18
  end
19
19
 
20
20
  # Subclasses must implement to indicate operation method on number (e.g. :+ for addition)
@@ -6,6 +6,7 @@ module Glimmer
6
6
  class Calculator
7
7
  include Glimmer::UI::CustomShell
8
8
 
9
+ APP_ROOT = File.expand_path('../../../..', __FILE__)
9
10
  VERSION = File.read(File.expand_path(File.join('..', '..', '..', '..', 'VERSION'), __FILE__))
10
11
  LICENSE = File.read(File.expand_path(File.join('..', '..', '..', '..', 'LICENSE.txt'), __FILE__))
11
12
 
@@ -29,7 +30,7 @@ module Glimmer
29
30
  display_about_dialog
30
31
  }
31
32
  on_preferences {
32
- # No need for preferences. Just display about dialog.
33
+ # No need for preferences. Just display about dialog.
33
34
  display_about_dialog
34
35
  }
35
36
  on_swt_keydown { |key_event|
@@ -50,8 +51,8 @@ module Glimmer
50
51
  #
51
52
  body {
52
53
  shell {
53
- # Replace example content below with custom shell content
54
- minimum_size 320, 240
54
+ minimum_size (OS.mac? ? 320 : (OS.windows? ? 390 : 520)), 240
55
+ image File.join(APP_ROOT, 'package', 'windows', "Glimmer Calculator.ico") if OS.windows?
55
56
  text "Glimmer - Calculator"
56
57
  grid_layout 4, true
57
58
  # Setting styled_text to multi in order for alignment options to activate
@@ -66,184 +67,54 @@ module Glimmer
66
67
  editable false
67
68
  caret nil
68
69
  }
69
- button {
70
- text 'AC'
71
- font @button_font
72
-
73
- layout_data(:fill, :fill, true, true)
74
-
75
- on_widget_selected {
76
- @presenter.press('AC')
77
- }
78
- }
79
- button {
80
- text '÷'
81
- font @button_font_operation
82
-
83
- layout_data(:fill, :fill, true, true)
84
-
85
- on_widget_selected {
86
- @presenter.press('/')
87
- }
88
- }
89
- button {
90
- text '×'
91
- font @button_font_operation
92
-
93
- layout_data(:fill, :fill, true, true)
94
-
95
- on_widget_selected {
96
- @presenter.press('*')
97
- }
98
- }
99
- button {
100
- text '−'
101
- font @button_font_operation
102
-
103
- layout_data(:fill, :fill, true, true)
104
-
105
- on_widget_selected {
106
- @presenter.press('-')
107
- }
108
- }
109
- button {
110
- text '7'
111
- font @button_font
112
-
113
- layout_data(:fill, :fill, true, true)
114
-
115
- on_widget_selected {
116
- @presenter.press('7')
117
- }
118
- }
119
- button {
120
- text '8'
121
- font @button_font
122
-
123
- layout_data(:fill, :fill, true, true)
124
-
125
- on_widget_selected {
126
- @presenter.press('8')
127
- }
128
- }
129
- button {
130
- text '9'
131
- font @button_font
132
-
133
- layout_data(:fill, :fill, true, true)
134
-
135
- on_widget_selected {
136
- @presenter.press('9')
137
- }
138
- }
139
- button {
140
- text '+'
141
- font @button_font_big
142
-
143
- layout_data(:fill, :fill, true, true) {
144
- vertical_span 2
145
- }
146
-
147
- on_widget_selected {
148
- @presenter.press('+')
149
- }
150
- }
151
- button {
152
- text '4'
153
- font @button_font
154
-
155
- layout_data(:fill, :fill, true, true)
156
-
157
- on_widget_selected {
158
- @presenter.press('4')
159
- }
160
- }
161
- button {
162
- text '5'
163
- font @button_font
164
-
165
- layout_data(:fill, :fill, true, true)
166
-
167
- on_widget_selected {
168
- @presenter.press('5')
169
- }
170
- }
171
- button {
172
- text '6'
173
- font @button_font
174
-
175
- layout_data(:fill, :fill, true, true)
176
-
177
- on_widget_selected {
178
- @presenter.press('6')
179
- }
180
- }
181
- button {
182
- text '1'
183
- font @button_font
184
-
185
- layout_data(:fill, :fill, true, true)
186
-
187
- on_widget_selected {
188
- @presenter.press('1')
189
- }
190
- }
191
- button {
192
- text '2'
193
- font @button_font
194
-
195
- layout_data(:fill, :fill, true, true)
196
-
197
- on_widget_selected {
198
- @presenter.press('2')
199
- }
200
- }
201
- button {
202
- text '3'
203
- font @button_font
204
-
205
- layout_data(:fill, :fill, true, true)
206
-
207
- on_widget_selected {
208
- @presenter.press('3')
209
- }
210
- }
211
- button {
212
- text '='
213
- font @button_font_big
214
-
215
- layout_data(:fill, :fill, true, true) {
216
- vertical_span 2
217
- }
218
-
219
- on_widget_selected {
220
- @presenter.press('=')
221
- }
222
- }
223
- button {
224
- text '0'
225
- font @button_font
226
-
227
- layout_data(:fill, :fill, true, true) {
228
- horizontal_span 2
229
- }
230
-
231
- on_widget_selected {
232
- @presenter.press('0')
233
- }
234
- }
235
- button {
236
- text '.'
237
- font @button_font_operation
238
-
239
- layout_data(:fill, :fill, true, true)
240
-
241
- on_widget_selected {
242
- @presenter.press('.')
243
- }
244
- }
70
+ command_button('AC')
71
+ operation_button('÷')
72
+ operation_button('×')
73
+ operation_button('−')
74
+ (7..9).each { |number|
75
+ number_button(number)
76
+ }
77
+ operation_button('+', font: @button_font_big, vertical_span: 2)
78
+ (4..6).each { |number|
79
+ number_button(number)
80
+ }
81
+ (1..3).each { |number|
82
+ number_button(number)
83
+ }
84
+ command_button('=', font: @button_font_big, vertical_span: 2)
85
+ number_button(0, horizontal_span: 2)
86
+ operation_button('.')
245
87
  }
246
88
  }
89
+
90
+ def number_button(number, options = {})
91
+ command_button(number, options)
92
+ end
93
+
94
+ def operation_button(operation, options = {})
95
+ command_button(operation, options.merge(font: @button_font_operation))
96
+ end
97
+
98
+ def command_button(command, options = {})
99
+ command = command.to_s
100
+ options[:font] ||= @button_font
101
+ options[:horizontal_span] ||= 1
102
+ options[:vertical_span] ||= 1
103
+
104
+ button { |proxy|
105
+ text command
106
+ font options[:font]
107
+
108
+ layout_data(:fill, :fill, true, true) {
109
+ horizontal_span options[:horizontal_span]
110
+ vertical_span options[:vertical_span]
111
+ }
112
+
113
+ on_widget_selected {
114
+ @presenter.press(command)
115
+ }
116
+ }
117
+ end
247
118
 
248
119
  def display_about_dialog
249
120
  message_box(body_root) {
metadata CHANGED
@@ -1,21 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-cs-calculator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-27 00:00:00.000000000 Z
11
+ date: 2021-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: 4.17.2.0
18
+ version: 4.17.2.2
19
19
  - - "<"
20
20
  - !ruby/object:Gem::Version
21
21
  version: 5.0.0.0
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 4.17.2.0
29
+ version: 4.17.2.2
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: 5.0.0.0
@@ -132,6 +132,7 @@ files:
132
132
  - bin/glimmer-cs-calculator
133
133
  - glimmer-cs-calculator.gemspec
134
134
  - lib/glimmer-cs-calculator.rb
135
+ - lib/glimmer-cs-calculator/launch.rb
135
136
  - lib/models/glimmer/calculator/command.rb
136
137
  - lib/models/glimmer/calculator/command/all_clear.rb
137
138
  - lib/models/glimmer/calculator/command/equals.rb
@@ -144,6 +145,8 @@ files:
144
145
  - lib/models/glimmer/calculator/command/point.rb
145
146
  - lib/models/glimmer/calculator/presenter.rb
146
147
  - lib/views/glimmer/calculator.rb
148
+ - package/macosx/Glimmer Calculator.icns
149
+ - package/windows/Glimmer Calculator.ico
147
150
  homepage: http://github.com/AndyObtiva/glimmer-cs-calculator
148
151
  licenses:
149
152
  - MIT
@@ -163,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
166
  - !ruby/object:Gem::Version
164
167
  version: '0'
165
168
  requirements: []
166
- rubygems_version: 3.1.4
169
+ rubygems_version: 3.1.6
167
170
  signing_key:
168
171
  specification_version: 4
169
172
  summary: Calculator - Glimmer Custom Shell