Module: SKUI

Defined in:
src/SKUI/core.rb,
src/SKUI/base.rb,
src/SKUI/enum.rb,
src/SKUI/font.rb,
src/SKUI/json.rb,
src/SKUI/rect.rb,
src/SKUI/debug.rb,
src/SKUI/image.rb,
src/SKUI/label.rb,
src/SKUI/bridge.rb,
src/SKUI/button.rb,
src/SKUI/events.rb,
src/SKUI/window.rb,
src/SKUI/control.rb,
src/SKUI/listbox.rb,
src/SKUI/textbox.rb,
src/SKUI/version.rb,
src/SKUI/checkbox.rb,
src/SKUI/groupbox.rb,
src/SKUI/container.rb,
src/SKUI/typecheck.rb,
src/SKUI/embed_skui.rb,
src/SKUI/properties.rb,
src/SKUI/radiobutton.rb,
src/SKUI/control_manager.rb,
src/SKUI/enum_system_font.rb,
src/SKUI/enum_system_color.rb

Overview

Since:

  • 1.0.0

Defined Under Namespace

Modules: ControlManager, Debug, Enum, Events, Properties, SystemColor, SystemFont, TypeCheck Classes: Base, Bridge, Button, Checkbox, Container, Control, Font, Groupbox, Image, JSON, Label, Listbox, RadioButton, Rect, Textbox, Window

Constant Summary collapse

PATH =

Since:

  • 1.0.0

current_path.freeze
PATH_JS =

Since:

  • 1.0.0

File.join( PATH, 'js' ).freeze
PATH_CSS =

Since:

  • 1.0.0

File.join( PATH, 'css' ).freeze
PATH_HTML =

Since:

  • 1.0.0

File.join( PATH, 'html' ).freeze
PLATFORM_IS_OSX =

Since:

  • 1.0.0

( Object::RUBY_PLATFORM =~ /darwin/i ) ? true : false
PLATFORM_IS_WINDOWS =

Since:

  • 1.0.0

!PLATFORM_IS_OSX
VERSION =

Since:

  • 1.0.0

'0.1.0'.freeze

Class Method Summary collapse

Class Method Details

.embed_in(context) ⇒ Boolean

Method to load SKUI into a given namespace - ensuring SKUI can be distributed easily within other projects.

Examples:

module Example
  load File.join( skui_path, 'SKUI', 'embed_skui.rb' )
  ::SKUI.embed_in( self )
  # SKUI module is now available under Example::SKUI
end

Parameters:

  • context (Module)

Returns:

  • (Boolean)

Since:

  • 1.0.0



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'src/SKUI/embed_skui.rb', line 18

def self.embed_in( context )
  # Temporarily rename existing root SKUI.
  Object.send( :const_set, :SKUI_Temp, SKUI )
  Object.send( :remove_const, :SKUI )
  # Load SKUI for this SKUI implementation.
  path = File.dirname( __FILE__ )
  # In SU2014, with Ruby 2.0 the __FILE__ constant return an UTF-8 string with
  # incorrect encoding label which will cause load errors when the file path
  # contain multi-byte characters. This happens when the user has non-english
  # characters in their username.
  path.force_encoding( "UTF-8" ) if path.respond_to?( :force_encoding )
  core = File.join( path, 'core.rb' )
  loaded = require( core )
  # One can only embed SKUI into one context per SKUI installation. This is
  # because `require` prevents the files to be loaded multiple times.
  # This should not be an issue though as an extension that implements SKUI
  # should only use the SKUI version it distribute itself.
  if loaded
    # Move SKUI to the target context.
    context.send( :const_set, :SKUI, SKUI )
    Object.send( :remove_const, :SKUI )
    true
  else
    false
  end
ensure
  # Restore root SKUI and clean up temp namespace.
  Object.send( :const_set, :SKUI, SKUI_Temp )
  Object.send( :remove_const, :SKUI_Temp )
end

.reloadInteger

Returns Number of files reloaded.

Returns:

  • (Integer)

    Number of files reloaded.

Since:

  • 1.0.0



46
47
48
49
50
51
52
53
54
55
56
# File 'src/SKUI/core.rb', line 46

def self.reload
  original_verbose = $VERBOSE
  $VERBOSE = nil
  filter = File.join( PATH, '*.{rb,rbs}' )
  x = Dir.glob( filter ).each { |file|
    load file
  }
  x.length
ensure
  $VERBOSE = original_verbose
end