Sha256: e0c8c77b67138d359e5fe0c7687e47db2d72b476e2300080507a2b8fe3dc3540

Contents?: true

Size: 1.05 KB

Versions: 102

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

# NOTE:
# This example displays images that can be freely downloaded from the Studio Ghibli website.

require 'glimmer-dsl-libui'
require 'chunky_png'
require 'open-uri'

include Glimmer

IMAGE_ROWS = []

5.times do |i|
  url = format('https://www.ghibli.jp/gallery/thumb-redturtle%03d.png', (i + 1))
  puts "Processing Image: #{url}"
  $stdout.flush # for Windows
  f = URI.open(url)
  canvas = ChunkyPNG::Canvas.from_io(f)
  f.close
  data = canvas.to_rgba_stream
  width = canvas.width
  height = canvas.height
  img = image {
    image_part(data, width, height, width * 4)
  }
  text = url.sub('https://www.ghibli.jp/gallery/thumb-redturtle', '').sub('.png', '')
  IMAGE_ROWS << [[img, text], [img, text]] # cell values are dual-element arrays
rescue StandardError => e
  warn url, e.message
end

window('The Red Turtle', 670, 350) {
  horizontal_box {
    table {
      image_text_column('image/number')
      image_text_column('image/number (editable)') {
        editable true
      }
      
      cell_rows IMAGE_ROWS
    }
  }
}.show

Version data entries

102 entries across 102 versions & 1 rubygems

Version Path
glimmer-dsl-libui-0.11.7 examples/basic_table_image_text3.rb
glimmer-dsl-libui-0.11.6 examples/basic_table_image_text3.rb
glimmer-dsl-libui-0.11.5 examples/basic_table_image_text3.rb
glimmer-dsl-libui-0.11.4 examples/basic_table_image_text3.rb
glimmer-dsl-libui-0.11.3 examples/basic_table_image_text3.rb
glimmer-dsl-libui-0.11.2 examples/basic_table_image_text3.rb
glimmer-dsl-libui-0.11.1 examples/basic_table_image_text3.rb
glimmer-dsl-libui-0.11.0 examples/basic_table_image_text3.rb
glimmer-dsl-libui-0.10.2 examples/basic_table_image_text3.rb
glimmer-dsl-libui-0.10.1 examples/basic_table_image_text3.rb
glimmer-dsl-libui-0.10.0 examples/basic_table_image_text3.rb
glimmer-dsl-libui-0.9.7 examples/basic_table_image_text3.rb
glimmer-dsl-libui-0.9.6 examples/basic_table_image_text3.rb
glimmer-dsl-libui-0.9.5 examples/basic_table_image_text3.rb
glimmer-dsl-libui-0.9.4 examples/basic_table_image_text3.rb
glimmer-dsl-libui-0.9.3 examples/basic_table_image_text3.rb
glimmer-dsl-libui-0.9.2 examples/basic_table_image_text3.rb
glimmer-dsl-libui-0.9.1 examples/basic_table_image_text3.rb
glimmer-dsl-libui-0.9.0 examples/basic_table_image_text3.rb
glimmer-dsl-libui-0.8.0 examples/basic_table_image_text3.rb