lib/shoes/swt/image.rb in shoes-swt-4.0.0.pre9 vs lib/shoes/swt/image.rb in shoes-swt-4.0.0.pre10

- old
+ new

@@ -1,16 +1,19 @@ # frozen_string_literal: true +require 'fileutils' + class Shoes module Swt class Image import java.io.ByteArrayInputStream include Common::Resource include Common::Clickable include Common::PainterUpdatesPosition include Common::Visibility include Common::Remove + include Common::ImageHandling include ::Shoes::BackendDimensionsDelegations attr_reader :app, :real, :dsl, :painter def initialize(dsl, app) @@ -45,19 +48,21 @@ @saved_height = dsl.element_height end def display_temporary_download_image temporary_download_image = File.join(DIR, 'static/downloading.png') - create_image(temporary_download_image) + create_image(load_file_image_data(temporary_download_image)) end def create_image(data) @real = ::Swt::Graphics::Image.new(::Swt.display, data) @full_width = @real.getImageData.width @full_height = @real.getImageData.height dsl.element_width ||= default_width dsl.element_height ||= default_height + + cleanup_temporary_files end def default_width if dsl.element_height ratio = dsl.element_height.to_r / @full_height @@ -91,10 +96,10 @@ def display_image(name_or_data) data = if raw_image_data?(name_or_data) load_raw_image_data(name_or_data) else - name_or_data + load_file_image_data(name_or_data) end create_image(data) end def raw_image_data?(name_or_data)