Skip to content
Browse files

shows image in scrollable area

  • Loading branch information...
1 parent 118a539 commit 5da8505be41b6fcae4b954983b462db273dc1605 @pithyless committed Feb 15, 2011
Showing with 41 additions and 2 deletions.
  1. +28 −0 lib/toolkit.rb
  2. +13 −2 main.rb
View
28 lib/toolkit.rb
@@ -1,2 +1,30 @@
$toolkit = :qt
require 'rui'
+
+RUI::GuiBuilder::Label.class_eval do
+ def create_element(window, parent, desc)
+ label = Qt::Label.new(desc.opts[:text].to_s, window)
+ if desc.opts[:image]
+ label.setPixmap desc.opts[:image].to_pix
+ end
+ setup_widget(label, window, parent, desc)
+ if desc.opts[:buddy]
+ window.buddies[label] = desc.opts[:buddy]
+ end
+ label
+ end
+end
+
+class Qt::ScrollArea
+ def add_widget(widget)
+ setWidget(widget)
+ end
+end
+
+module RUI::GuiBuilder
+ class ScrollArea < Widget
+ def factory(desc)
+ Qt::ScrollArea
+ end
+ end
+end
View
15 main.rb
@@ -1,10 +1,21 @@
require_relative 'lib/toolkit'
RUI::Application.init('hello') do |app|
+ img = Qt::Image.new('samples/01-a-100.png')
+
widget = Qt::Widget.new
widget.gui = RUI::autogui do
- layout(:type => :vertical) do
- button(:name => :quit, :text => 'Quit')
+ layout :type => :horizontal do
+ layout :type => :vertical do
+ scroll_area :name => :scrollable do
+ label :name => :pic_label, :image => img
+ end
+ label :name => :footer_label, :text => 'Footer'
+ end
+ layout :type => :vertical do
+ button :name => :hello, :text => 'Hello'
+ button :name => :quit, :text => 'Quit'
+ end
end
end
widget.quit.on(:clicked) { app.exit }

0 comments on commit 5da8505

Please sign in to comment.
Something went wrong with that request. Please try again.