Sha256: ad3f3756befa7b2128a35c29882a085814750b4789e16dc8922ac27d650d30eb

Contents?: true

Size: 1.2 KB

Versions: 92

Compression:

Stored size: 1.2 KB

Contents

require 'glimmer-dsl-libui'

class Login
  include Glimmer
  
  attr_accessor :username, :password, :logged_in
  
  def logged_out
    !logged_in
  end
  
  def launch
    window('Login') {
      margined true
      
      vertical_box {
        form {
          entry {
            label 'Username:'
            text <=> [self, :username]
            enabled <= [self, :logged_out, computed_by: :logged_in] # computed_by option ensures being notified of changes to logged_in
          }
          
          password_entry {
            label 'Password:'
            text <=> [self, :password]
            enabled <= [self, :logged_out, computed_by: :logged_in]
          }
        }
        
        horizontal_box {
          button('Login') {
            enabled <= [self, :logged_out, computed_by: :logged_in]
            
            on_clicked do
              self.logged_in = true
            end
          }
          
          button('Logout') {
            enabled <= [self, :logged_in]
            
            on_clicked do
              self.logged_in = false
              self.username = ''
              self.password = ''
            end
          }
        }
      }
    }.show
  end
end

Login.new.launch

Version data entries

92 entries across 92 versions & 1 rubygems

Version Path
glimmer-dsl-libui-0.12.7 examples/login2.rb
glimmer-dsl-libui-0.12.6 examples/login2.rb
glimmer-dsl-libui-0.12.5 examples/login2.rb
glimmer-dsl-libui-0.12.4 examples/login2.rb
glimmer-dsl-libui-0.12.3 examples/login2.rb
glimmer-dsl-libui-0.12.2 examples/login2.rb
glimmer-dsl-libui-0.12.1 examples/login2.rb
glimmer-dsl-libui-0.12.0 examples/login2.rb
glimmer-dsl-libui-0.11.10 examples/login2.rb
glimmer-dsl-libui-0.11.9 examples/login2.rb
glimmer-dsl-libui-0.11.8 examples/login2.rb
glimmer-dsl-libui-0.11.7 examples/login2.rb
glimmer-dsl-libui-0.11.6 examples/login2.rb
glimmer-dsl-libui-0.11.5 examples/login2.rb
glimmer-dsl-libui-0.11.4 examples/login2.rb
glimmer-dsl-libui-0.11.3 examples/login2.rb
glimmer-dsl-libui-0.11.2 examples/login2.rb
glimmer-dsl-libui-0.11.1 examples/login2.rb
glimmer-dsl-libui-0.11.0 examples/login2.rb
glimmer-dsl-libui-0.10.2 examples/login2.rb