glimmer-cs-calculator 1.0.0 → 1.1.2

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: 1181ebd61993301957b214666f187c7ecf1be2aea7bb288aa6abb67ddc664225
4
- data.tar.gz: 170e6809beb9a4b6dca428a8cd83f9772d496e54ab1a8a92a15982704ffcfa14
3
+ metadata.gz: 897141c9ef84b60521fb95588fc994824e573fb3a75f60f964df9f46fb586409
4
+ data.tar.gz: '008c1d1874d3cfcb3c0dc281f678ce84b2b0ce188c6889db18594e54c7761791'
5
5
  SHA512:
6
- metadata.gz: 38d88bed477197cfd91b52eeac642ae31ccecdcf56df7324f1e6bbd009c15db28038486df02921ddbdcb36cf0f3858799b09dee26691c601995283e5a131c7f8
7
- data.tar.gz: 7680cbdd1555d5db2e55a2724807ad7812ca943a879bd873115150bf342d4e5d88b0845ac5dbf8ff4ac2e1d2273bc777336b0e12322c6143da73b8a207ae5aac
6
+ metadata.gz: 17eb51f99d846c5b4711ae8d828099eec41cff6efa2447f8eda36ea26d7e3068379ffd39cf2402950f06eec043baeeb531ee80afef57e22eb21b79ddfe2dbd2f
7
+ data.tar.gz: aa0e0237a9831a6d9cb98a903f8f08a819f9a0813ba1f8dcd49dd53417b265c392f99e24a75b92816b18d2b9da6afa4b67688e3275176871b13a29de6c410811
@@ -0,0 +1,27 @@
1
+ # Change Log
2
+
3
+ ## 1.1.2
4
+
5
+ - Official Opal (Web) support via [Glimmer DSL for Opal](https://github.com/AndyObtiva/glimmer-dsl-opal)
6
+
7
+ ## 1.1.1
8
+
9
+ - Official Windows support
10
+ - Official Linux support
11
+ - Refactorings, extracting method-based custom widgets
12
+
13
+ ## 1.1.0
14
+
15
+ - Upgrade support for glimmer-dsl-swt to 4.17.2.0 up to 5.0.0.0
16
+
17
+ ## 1.0.2
18
+
19
+ - Relaxed dependency on glimmer-dsl-swt (>= 0.1.1 < 2.0.0) / updated logo / used new Glimmer `message_box` keyword syntax
20
+
21
+ ## 1.0.1
22
+
23
+ - Upgraded to glimmer-dsl-swt v0.1.1 / added delete/backspace shortcut for AC / fixed issues with pressing operations without any number
24
+
25
+ ## 1.0.0
26
+
27
+ - Initial calculator implementation
data/README.md CHANGED
@@ -1,20 +1,47 @@
1
- # <img alt="Glimmer Calculator Icon" src="glimmer-cs-calculator-icon.png" width="60" /> Calculator - Glimmer Custom Shell
1
+ # <img alt="Glimmer Calculator Icon" src="glimmer-cs-calculator-icon.png" height=85 /> Glimmer Calculator
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)
2
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-cs-calculator.svg)](http://badge.fury.io/rb/glimmer-cs-calculator)
3
4
 
5
+ Glimmer Calculator on Mac
6
+
4
7
  ![Calculator](glimmer-cs-calculator-screenshot.png)
5
8
 
6
- Calculator sample desktop GUI application built with [Glimmer](https://github.com/AndyObtiva/glimmer) (Ruby Desktop Development Library).
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](https://github.com/AndyObtiva/glimmer-dsl-opal) (Web)
18
+
19
+ ![Calculator](glimmer-cs-calculator-screenshot-opal.png)
20
+
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).
22
+
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).
7
26
 
8
- It is developed test-first following TDD (Test Driven Development).
9
27
  Design Patterns discovered in the process were Presenter/Facade and Command Pattern.
10
28
 
11
- Follows the MVP architectural pattern (Model View Presenter) thanks to [Glimmer data-binding](https://github.com/AndyObtiva/glimmer#data-binding) support.
29
+ Here are the calculator commands under the [models directory](lib/models/glimmer/calculator):
30
+
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.2 GEM for Linux](#setup-instructions)
12
38
 
13
39
  ## Platforms
14
40
 
15
- - Mac: Tested and [packaged](https://github.com/AndyObtiva/glimmer#packaging--distribution) for the Mac. ([Download Here<img alt="Glimmer Calculator Icon" src="glimmer-cs-calculator-icon.png" width="30" />](https://www.dropbox.com/s/tdgwt2vfxfh13ro/Glimmer%20Calculator-1.0.0.dmg?dl=1))
16
- - Linux: Not tested/packaged for Linux, but should work by following setup instructions below.
17
- - Windows: Not tested/packaged for Windows, but should work by following setup instructions below.
41
+ - 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))
42
+ - 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))
43
+ - 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)
44
+ - Opal (Web): Tested with [Glimmer DSL for Opal](https://github.com/AndyObtiva/glimmer-dsl-opal)
18
45
 
19
46
  ## Development Environment Pre-requisites
20
47
 
@@ -43,7 +70,7 @@ To reuse Calculator as a Glimmer Custom Shell inside another Glimmer application
43
70
  following to the application's `Gemfile`:
44
71
 
45
72
  ```
46
- gem 'glimmer-cs-calculator', '1.0.0'
73
+ gem 'glimmer-cs-calculator', '1.1.2'
47
74
  ```
48
75
 
49
76
  Run:
@@ -54,6 +81,14 @@ jruby -S bundle
54
81
 
55
82
  And, then instantiate the Calculator custom shell in your Glimmer application via the `calculator` Glimmer DSL keyword.
56
83
 
84
+ ## Feature Suggestions
85
+
86
+ [TODO.md](TODO.md)
87
+
88
+ ## Change Log
89
+
90
+ [CHANGELOG.md](CHANGELOG.md)
91
+
57
92
  ## Contributing to glimmer-cs-calculator
58
93
 
59
94
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
@@ -66,5 +101,12 @@ And, then instantiate the Calculator custom shell in your Glimmer application vi
66
101
 
67
102
  ## Copyright
68
103
 
69
- Copyright (c) 2020 Andy Maleh. See LICENSE.txt for
70
- further details.
104
+ [MIT](https://opensource.org/licenses/MIT)
105
+
106
+ Copyright (c) 2020 Andy Maleh. See [LICENSE.txt](LICENSE.txt) for further details.
107
+
108
+ --
109
+
110
+ [<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)
111
+
112
+ 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>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.1.2
@@ -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'
@@ -0,0 +1,72 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: glimmer-cs-calculator 1.1.2 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "glimmer-cs-calculator".freeze
9
+ s.version = "1.1.2"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib".freeze]
13
+ s.authors = ["Andy Maleh".freeze]
14
+ s.date = "2020-10-15"
15
+ s.description = "Calculator - Glimmer Custom Shell".freeze
16
+ s.email = "andy.am@gmail.com".freeze
17
+ s.executables = ["glimmer-cs-calculator".freeze, "calculator".freeze]
18
+ s.extra_rdoc_files = [
19
+ "LICENSE.txt",
20
+ "README.md"
21
+ ]
22
+ s.files = [
23
+ "CHANGELOG.md",
24
+ "LICENSE.txt",
25
+ "README.md",
26
+ "VERSION",
27
+ "bin/calculator",
28
+ "bin/glimmer-cs-calculator",
29
+ "glimmer-cs-calculator.gemspec",
30
+ "lib/glimmer-cs-calculator.rb",
31
+ "lib/glimmer-cs-calculator/launch.rb",
32
+ "lib/models/glimmer/calculator/command.rb",
33
+ "lib/models/glimmer/calculator/command/all_clear.rb",
34
+ "lib/models/glimmer/calculator/command/equals.rb",
35
+ "lib/models/glimmer/calculator/command/number.rb",
36
+ "lib/models/glimmer/calculator/command/operation.rb",
37
+ "lib/models/glimmer/calculator/command/operation/add.rb",
38
+ "lib/models/glimmer/calculator/command/operation/divide.rb",
39
+ "lib/models/glimmer/calculator/command/operation/multiply.rb",
40
+ "lib/models/glimmer/calculator/command/operation/subtract.rb",
41
+ "lib/models/glimmer/calculator/command/point.rb",
42
+ "lib/models/glimmer/calculator/presenter.rb",
43
+ "lib/views/glimmer/calculator.rb",
44
+ "package/macosx/Glimmer Calculator.icns",
45
+ "package/windows/Glimmer Calculator.ico"
46
+ ]
47
+ s.homepage = "http://github.com/AndyObtiva/glimmer-cs-calculator".freeze
48
+ s.licenses = ["MIT".freeze]
49
+ s.rubygems_version = "3.1.4".freeze
50
+ s.summary = "Calculator - Glimmer Custom Shell".freeze
51
+
52
+ if s.respond_to? :specification_version then
53
+ s.specification_version = 4
54
+ end
55
+
56
+ if s.respond_to? :add_runtime_dependency then
57
+ s.add_runtime_dependency(%q<easily_typable>.freeze, ["~> 1.0.2"])
58
+ s.add_development_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
59
+ s.add_development_dependency(%q<jeweler>.freeze, ["= 2.3.9"])
60
+ s.add_development_dependency(%q<warbler>.freeze, ["= 2.0.5"])
61
+ s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
62
+ s.add_development_dependency(%q<glimmer-cs-gladiator>.freeze, [">= 0.3.0"])
63
+ else
64
+ s.add_dependency(%q<easily_typable>.freeze, ["~> 1.0.2"])
65
+ s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
66
+ s.add_dependency(%q<jeweler>.freeze, ["= 2.3.9"])
67
+ s.add_dependency(%q<warbler>.freeze, ["= 2.0.5"])
68
+ s.add_dependency(%q<simplecov>.freeze, [">= 0"])
69
+ s.add_dependency(%q<glimmer-cs-gladiator>.freeze, [">= 0.3.0"])
70
+ end
71
+ end
72
+
@@ -1,4 +1,5 @@
1
1
  $LOAD_PATH.unshift(File.expand_path('..', __FILE__))
2
2
 
3
- require 'glimmer'
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'
@@ -2,7 +2,7 @@ module Glimmer
2
2
  class Calculator
3
3
  class Command
4
4
  class AllClear < Command
5
- keywords 'AC', 'c', 'C', 27.chr
5
+ keywords 'AC', 'c', 'C', 8.chr, 27.chr, 127.chr
6
6
 
7
7
  def execute
8
8
  self.result = '0'
@@ -5,11 +5,11 @@ module Glimmer
5
5
  keywords '=', "\r"
6
6
 
7
7
  def execute
8
- if operation
8
+ if number1 && number2 && operation
9
9
  self.result = operation.calculate.to_s
10
10
  self.number1 = self.result
11
11
  else
12
- self.result = last_result
12
+ self.result = last_result || '0'
13
13
  end
14
14
  end
15
15
  end
@@ -2,9 +2,24 @@ module Glimmer
2
2
  class Calculator
3
3
  class Command
4
4
  class Operation < Command
5
- # Calculate operation result using number1 and number2 attributes
5
+ def execute
6
+ if number1 && number2 && operation && !last_command.equals?
7
+ self.result = operation.calculate.to_s
8
+ self.number1 = self.result
9
+ else
10
+ self.result = last_result || '0'
11
+ self.operation = self
12
+ end
13
+ end
14
+
6
15
  def calculate
7
- raise 'Not implemented! A subclass must implement to calculate operation using number1 and number2 attributes'
16
+ calculation_result = BigDecimal.new(number1.to_s).send(operation_method, BigDecimal.new(number2.to_s)).to_f
17
+ calculation_result.to_s.match(/\.0+$/) ? calculation_result.to_i : calculation_result
18
+ end
19
+
20
+ # Subclasses must implement to indicate operation method on number (e.g. :+ for addition)
21
+ def operation_method
22
+ raise 'Not implemented!'
8
23
  end
9
24
  end
10
25
  end
@@ -4,20 +4,9 @@ module Glimmer
4
4
  class Operation < Command
5
5
  class Add < Operation
6
6
  keyword '+'
7
-
8
- def execute
9
- if number2 && operation && !last_command.equals?
10
- self.result = operation.calculate.to_s
11
- self.number1 = self.result
12
- else
13
- self.result = last_result
14
- self.operation = self
15
- end
16
- end
17
7
 
18
- def calculate
19
- calculation_result = number1 + number2
20
- calculation_result.to_s.match(/\.0+$/) ? calculation_result.to_i : calculation_result
8
+ def operation_method
9
+ :+
21
10
  end
22
11
  end
23
12
  end
@@ -4,20 +4,9 @@ module Glimmer
4
4
  class Operation < Command
5
5
  class Divide < Operation
6
6
  keywords '÷', '/'
7
-
8
- def execute
9
- if number2 && operation && !last_command.equals?
10
- self.result = operation.calculate.to_s
11
- self.number1 = self.result
12
- else
13
- self.result = last_result
14
- self.operation = self
15
- end
16
- end
17
7
 
18
- def calculate
19
- calculation_result = number1 / number2
20
- calculation_result.to_s.match(/\.0+$/) ? calculation_result.to_i : calculation_result #TODO consider moving this to result= method in Command
8
+ def operation_method
9
+ :/
21
10
  end
22
11
  end
23
12
  end
@@ -5,19 +5,8 @@ module Glimmer
5
5
  class Multiply < Operation
6
6
  keywords '×', '*'
7
7
 
8
- def execute
9
- if number2 && operation && !last_command.equals?
10
- self.result = operation.calculate.to_s
11
- self.number1 = self.result
12
- else
13
- self.result = last_result
14
- self.operation = self
15
- end
16
- end
17
-
18
- def calculate
19
- calculation_result = number1 * number2
20
- calculation_result.to_s.match(/\.0+$/) ? calculation_result.to_i : calculation_result
8
+ def operation_method
9
+ :*
21
10
  end
22
11
  end
23
12
  end
@@ -4,20 +4,9 @@ module Glimmer
4
4
  class Operation < Command
5
5
  class Subtract < Operation
6
6
  keywords '−', '-'
7
-
8
- def execute
9
- if number2 && operation && !last_command.equals?
10
- self.result = operation.calculate.to_s
11
- self.number1 = self.result
12
- else
13
- self.result = last_result
14
- self.operation = self
15
- end
16
- end
17
7
 
18
- def calculate
19
- calculation_result = number1 - number2
20
- calculation_result.to_s.match(/\.0+$/) ? calculation_result.to_i : calculation_result
8
+ def operation_method
9
+ :-
21
10
  end
22
11
  end
23
12
  end
@@ -3,15 +3,23 @@ require 'models/glimmer/calculator/command'
3
3
  module Glimmer
4
4
  class Calculator
5
5
  class Presenter
6
+ FORMATTER = {
7
+ nil => '0',
8
+ 'NaN' => 'Not a number'
9
+ }
10
+
6
11
  attr_accessor :result
7
12
 
8
13
  def initialize
9
14
  self.result = '0'
10
15
  end
11
-
16
+
12
17
  def press(button)
13
18
  command = Command.for(button)
14
- self.result = command.result if command
19
+ if command
20
+ new_result = command.result
21
+ self.result = FORMATTER[new_result] || new_result
22
+ end
15
23
  end
16
24
  end
17
25
  end
@@ -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
 
@@ -25,7 +26,14 @@ module Glimmer
25
26
  @button_font_big = {height: 28}
26
27
  Display.setAppName('Glimmer Calculator')
27
28
  @display = display {
28
- on_event_keydown { |key_event|
29
+ on_about {
30
+ display_about_dialog
31
+ }
32
+ on_preferences {
33
+ # No need for preferences. Just display about dialog.
34
+ display_about_dialog
35
+ }
36
+ on_swt_keydown { |key_event|
29
37
  char = key_event.character.chr rescue nil
30
38
  @presenter.press(char)
31
39
  }
@@ -43,17 +51,10 @@ module Glimmer
43
51
  #
44
52
  body {
45
53
  shell {
46
- # Replace example content below with custom shell content
47
- 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?
48
56
  text "Glimmer - Calculator"
49
57
  grid_layout 4, true
50
- on_about {
51
- display_about_dialog
52
- }
53
- on_preferences {
54
- # No need for preferences. Just display about dialog.
55
- display_about_dialog
56
- }
57
58
  # Setting styled_text to multi in order for alignment options to activate
58
59
  styled_text(:multi, :wrap, :border) {
59
60
  text bind(@presenter, :result)
@@ -66,192 +67,60 @@ 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
- message_box = MessageBox.new(swt_widget)
250
- message_box.setText("About")
251
- message = "Glimmer - Calculator #{VERSION}\n"
252
- message += LICENSE
253
- message_box.setMessage(message)
254
- message_box.open
120
+ message_box(body_root) {
121
+ text 'About'
122
+ message "Glimmer - Calculator #{VERSION}\n#{LICENSE}"
123
+ }.open
255
124
  end
256
125
 
257
126
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-cs-calculator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.2
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-05-30 00:00:00.000000000 Z
11
+ date: 2020-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- requirement: !ruby/object:Gem::Requirement
15
- requirements:
16
- - - "~>"
17
- - !ruby/object:Gem::Version
18
- version: 0.7.7
19
- name: glimmer
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 0.7.7
27
13
  - !ruby/object:Gem::Dependency
28
14
  requirement: !ruby/object:Gem::Requirement
29
15
  requirements:
@@ -31,8 +17,8 @@ dependencies:
31
17
  - !ruby/object:Gem::Version
32
18
  version: 1.0.2
33
19
  name: easily_typable
34
- type: :runtime
35
20
  prerelease: false
21
+ type: :runtime
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
24
  - - "~>"
@@ -45,8 +31,8 @@ dependencies:
45
31
  - !ruby/object:Gem::Version
46
32
  version: 3.5.0
47
33
  name: rspec
48
- type: :development
49
34
  prerelease: false
35
+ type: :development
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
38
  - - "~>"
@@ -59,8 +45,8 @@ dependencies:
59
45
  - !ruby/object:Gem::Version
60
46
  version: 2.3.9
61
47
  name: jeweler
62
- type: :development
63
48
  prerelease: false
49
+ type: :development
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
52
  - - '='
@@ -69,60 +55,64 @@ dependencies:
69
55
  - !ruby/object:Gem::Dependency
70
56
  requirement: !ruby/object:Gem::Requirement
71
57
  requirements:
72
- - - ">="
58
+ - - '='
73
59
  - !ruby/object:Gem::Version
74
- version: '0'
75
- name: simplecov
76
- type: :development
60
+ version: 2.0.5
61
+ name: warbler
77
62
  prerelease: false
63
+ type: :development
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
- - - ">="
66
+ - - '='
81
67
  - !ruby/object:Gem::Version
82
- version: '0'
68
+ version: 2.0.5
83
69
  - !ruby/object:Gem::Dependency
84
70
  requirement: !ruby/object:Gem::Requirement
85
71
  requirements:
86
- - - "~>"
72
+ - - ">="
87
73
  - !ruby/object:Gem::Version
88
- version: 0.1.6
89
- name: glimmer-cs-gladiator
90
- type: :development
74
+ version: '0'
75
+ name: simplecov
91
76
  prerelease: false
77
+ type: :development
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
- - - "~>"
80
+ - - ">="
95
81
  - !ruby/object:Gem::Version
96
- version: 0.1.6
82
+ version: '0'
97
83
  - !ruby/object:Gem::Dependency
98
84
  requirement: !ruby/object:Gem::Requirement
99
85
  requirements:
100
- - - "~>"
86
+ - - ">="
101
87
  - !ruby/object:Gem::Version
102
- version: 0.8.1
103
- name: puts_debuggerer
104
- type: :development
88
+ version: 0.3.0
89
+ name: glimmer-cs-gladiator
105
90
  prerelease: false
91
+ type: :development
106
92
  version_requirements: !ruby/object:Gem::Requirement
107
93
  requirements:
108
- - - "~>"
94
+ - - ">="
109
95
  - !ruby/object:Gem::Version
110
- version: 0.8.1
96
+ version: 0.3.0
111
97
  description: Calculator - Glimmer Custom Shell
112
98
  email: andy.am@gmail.com
113
99
  executables:
100
+ - glimmer-cs-calculator
114
101
  - calculator
115
102
  extensions: []
116
103
  extra_rdoc_files:
117
104
  - LICENSE.txt
118
105
  - README.md
119
106
  files:
107
+ - CHANGELOG.md
120
108
  - LICENSE.txt
121
109
  - README.md
122
110
  - VERSION
123
111
  - bin/calculator
124
112
  - bin/glimmer-cs-calculator
113
+ - glimmer-cs-calculator.gemspec
125
114
  - lib/glimmer-cs-calculator.rb
115
+ - lib/glimmer-cs-calculator/launch.rb
126
116
  - lib/models/glimmer/calculator/command.rb
127
117
  - lib/models/glimmer/calculator/command/all_clear.rb
128
118
  - lib/models/glimmer/calculator/command/equals.rb
@@ -135,6 +125,8 @@ files:
135
125
  - lib/models/glimmer/calculator/command/point.rb
136
126
  - lib/models/glimmer/calculator/presenter.rb
137
127
  - lib/views/glimmer/calculator.rb
128
+ - package/macosx/Glimmer Calculator.icns
129
+ - package/windows/Glimmer Calculator.ico
138
130
  homepage: http://github.com/AndyObtiva/glimmer-cs-calculator
139
131
  licenses:
140
132
  - MIT
@@ -154,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
146
  - !ruby/object:Gem::Version
155
147
  version: '0'
156
148
  requirements: []
157
- rubygems_version: 3.0.6
149
+ rubygems_version: 3.1.4
158
150
  signing_key:
159
151
  specification_version: 4
160
152
  summary: Calculator - Glimmer Custom Shell