Saturday, January 08, 2022

More Glimmer Custom Shape Gems like Cylinder and Cube

New Custom Shape Gems have been published for Glimmer DSL for SWT:






These have been extracted from the newest Glimmer DSL for SWT sample: Glimmer Quarto


Now, when you run the `glimmer` command for listing custom shape gems, you get the following:

% glimmer list:gems:customshape


  Glimmer Custom Shape Gems at rubygems.org:

                                                                                                                   

       Name                    Gem               Version     Author                    Description                 

                                                                                                                   

  Bevel             glimmer-cp-bevel             0.1.1     Andy Maleh   Bevel - Glimmer Custom Shape               

  Cube              glimmer-cp-cube              0.1.0     Andy Maleh   Cube - Glimmer Custom Shape                

  Cylinder          glimmer-cp-cylinder          0.1.0     Andy Maleh   Cylinder - Glimmer Custom Shape            

  Messageboxpanel   glimmer-cp-messageboxpanel   0.1.0     Andy Maleh   Message Box Panel - Glimmer Custom Shape   

  Stickfigure       glimmer-cp-stickfigure       0.1.1     Andy Maleh   Stick Figure - Glimmer Custom Shape        


Below are Hello samples of each Custom Shape.

Happy Glimmering!

# From: https://github.com/AndyObtiva/glimmer-cp-cylinder
require_relative '../../lib/glimmer-cp-cylinder' # Use `require 'glimmer-cp-cylinder'` if gem is installed
class HelloCylinder
include Glimmer::UI::CustomShell
body {
shell {
text 'Hello, Cylinder!'
minimum_size 310, 200
canvas {
background :white
text('Cylinders can be dragged and moved', :default, 30) {
font height: 16, style: :bold
}
cylinder(location_x: 30, location_y: 70, cylinder_height: 50, oval_width: 50, oval_height: 25, pitted: false, background_color: rgb(255, 255, 64), line_thickness: 2) { |c|
drag_and_move true
}
cylinder(location_x: 130, location_y: 70, cylinder_height: 50, oval_width: 50, oval_height: 25, pitted: false, background_color: rgb(255, 64, 255), line_thickness: 2) { |c|
drag_and_move true
}
cylinder(location_x: 230, location_y: 70, cylinder_height: 50, oval_width: 50, oval_height: 25, pitted: true, background_color: rgb(64, 255, 255), line_thickness: 2) { |c|
drag_and_move true
on_mouse_up do
c.pitted = !c.pitted
end
}
}
}
}
end
HelloCylinder.launch

require_relative '../../lib/glimmer-cp-cube' # Use `require 'glimmer-cp-cube'` if gem is installed
class HelloCube
include Glimmer::UI::CustomShell
body {
shell {
text 'Hello, Cube!'
minimum_size 310, 200
canvas {
background :white
text('Cubes can be dragged and moved', :default, 30) {
font height: 16, style: :bold
}
cube(location_x: 30, location_y: 70, cube_height: 50, rectangle_width: 50, rectangle_height: 25, pitted: false, background_color: rgb(255, 255, 64), line_thickness: 2) { |c|
drag_and_move true
}
cube(location_x: 130, location_y: 70, cube_height: 50, rectangle_width: 50, rectangle_height: 25, pitted: false, background_color: rgb(255, 64, 255), line_thickness: 2) { |c|
drag_and_move true
}
cube(location_x: 230, location_y: 70, cube_height: 50, rectangle_width: 50, rectangle_height: 25, pitted: true, background_color: rgb(64, 255, 255), line_thickness: 2) { |c|
drag_and_move true
on_mouse_up do
c.pitted = !c.pitted
end
}
}
}
}
end
HelloCube.launch

require_relative '../../lib/glimmer-cp-messageboxpanel' # Use `require 'glimmer-cp-messageboxpanel'` if gem is installed
class HelloMessageBoxPanel
include Glimmer::UI::CustomShell
body {
shell {
text 'Hello, Message Box Panel!'
minimum_size 425, 200
@canvas = canvas {
background :white
first_message_box_panel
}
}
}
def first_message_box_panel
message_box_panel(message: 'Hello, Message Box Panel!', background_color: rgb(255, 255, 128), text_font: {height: 16}) {
on_closed do
@canvas.content { # re-open canvas content and add a message box panel
second_message_box_panel
}
end
}
end
def second_message_box_panel
message_box_panel(message: "Message Box Panel is a graphical\nversion of the native Message Box", background_color: :cyan, text_font: {height: 16}, border_line_width: 3) {
on_closed do
@canvas.content { # re-open canvas content and add a message box panel
third_message_box_panel
}
end
}
end
def third_message_box_panel
message_box_panel(message: "It is a customizable alternative that can\n be used in Canvas-based applications", background_color: :yellow, foreground_color: :red, text_color: :dark_green, text_font: {height: 16, style: [:bold, :italic]}, border_line_width: 3) {
on_closed do
@canvas.content { # re-open canvas content and add a message box panel
fourth_message_box_panel
}
end
}
end
def fourth_message_box_panel
message_box_panel(message: 'Good bye, Message Box Panel!', background_color: :black, text_color: :white, text_font: {height: 16}) {
on_closed do
@canvas.content { # re-open canvas content and add a message box panel
first_message_box_panel
}
end
}
end
end
HelloMessageBoxPanel.launch

No comments: