Class: Shoes::Image

Inherits:
Common::UIElement show all
Includes:
Common::Clickable, Common::Hover, Common::ImageHandling, Common::Translate
Defined in:
shoes-core/lib/shoes/image.rb

Constant Summary collapse

BINARY_ENCODING =
Encoding.find('binary')
STYLES =
{ fill: Shoes::COLORS[:black] }.freeze

Constants included from Common::Style

Common::Style::DEFAULT_STYLES, Common::Style::STYLE_GROUPS

Instance Attribute Summary

Attributes included from Common::Hover

#hover_blk, #leave_blk

Attributes included from Common::Clickable

#pass_coordinates

Attributes inherited from Common::UIElement

#app, #dimensions, #gui, #parent

Instance Method Summary collapse

Methods included from Common::Translate

#clear_translate, #translate_left, #translate_top

Methods included from Common::ImageHandling

#absolute_file_path, #default_search_paths, #search_for

Methods included from Common::Hover

#add_mouse_hover_control, #apply_style_from_hover_class, #apply_style_from_pre_hover, create_hover_class, #eval_hover_block, #hover, #hover_class, #hovered?, #leave, #mouse_hovered, #mouse_left

Methods included from Common::Clickable

#click, #pass_coordinates?, #register_click, #release

Methods inherited from Common::UIElement

#add_to_parent, #after_initialize, #create_backend, #create_dimensions, #handle_block, #initialize, #needs_rotate?, #painted?, #redraw_height, #redraw_left, #redraw_top, #redraw_width, #update_fill, #update_stroke

Methods included from Common::Style

#applicable_app_styles, #create_style_hash, included, #style, #style_init

Methods included from Common::SafelyEvaluate

#safely_evaluate

Methods included from Common::Remove

#remove

Methods included from Common::Positioning

#_position, #displace, #move

Methods included from Common::Visibility

#hidden?, #hidden_from_view?, #hide, #outside_parent_view?, #show, #toggle, #visible?

Methods included from Common::Inspect

#inspect, #to_s

Methods included from Common::Attachable

#attached_to

Constructor Details

This class inherits a constructor from Shoes::Common::UIElement

Instance Method Details

#before_initialize(styles, file_path_or_data) ⇒ Object


16
17
18
# File 'shoes-core/lib/shoes/image.rb', line 16

def before_initialize(styles, file_path_or_data)
  styles[:file_path] = normalized_source(file_path_or_data)
end

#pathObject


20
21
22
# File 'shoes-core/lib/shoes/image.rb', line 20

def path
  @style[:file_path]
end

#path=(path_or_data) ⇒ Object


24
25
26
27
# File 'shoes-core/lib/shoes/image.rb', line 24

def path=(path_or_data)
  style(file_path: normalized_source(path_or_data))
  @gui.update_image
end

#raw_image_data?(name_or_data) ⇒ Boolean

Returns:

  • (Boolean)

33
34
35
# File 'shoes-core/lib/shoes/image.rb', line 33

def raw_image_data?(name_or_data)
  name_or_data.encoding == BINARY_ENCODING
end

#url?(path_or_data) ⇒ Boolean

Returns:

  • (Boolean)

29
30
31
# File 'shoes-core/lib/shoes/image.rb', line 29

def url?(path_or_data)
  path_or_data =~ %r{^https?://}
end