Module: Shoes::Swt::Common::Resource
- Included in:
- Painter, ImagePainter, TextBlock::Painter
- Defined in:
- shoes-swt/lib/shoes/swt/common/resource.rb
Constant Summary collapse
- OPAQUE =
255
Instance Method Summary collapse
- #clip_context_to(graphics_context, element, use_parent_height = true) ⇒ Object
- #dispose_previous_contexts ⇒ Object
- #reset_graphics_context(graphics_context) ⇒ Object
- #set_defaults_on_context(graphics_context) ⇒ Object
- #track_graphics_context(graphics_context) ⇒ Object
Instance Method Details
#clip_context_to(graphics_context, element, use_parent_height = true) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'shoes-swt/lib/shoes/swt/common/resource.rb', line 32 def clip_context_to(graphics_context, element, use_parent_height = true) parent = element.parent clipping = graphics_context.clipping height = use_parent_height ? parent.height : parent.app.height graphics_context.set_clipping(parent.absolute_left, parent.absolute_top, parent.width + element.translate_left.to_i, height + element.translate_top.to_i) yield graphics_context ensure if clipping graphics_context.set_clipping(clipping.x, clipping.y, clipping.width, clipping.height) end end |
#dispose_previous_contexts ⇒ Object
15 16 17 18 19 |
# File 'shoes-swt/lib/shoes/swt/common/resource.rb', line 15 def dispose_previous_contexts @graphic_contexts ||= [] @graphic_contexts.each { |g| g&.dispose } @graphic_contexts.clear end |
#reset_graphics_context(graphics_context) ⇒ Object
9 10 11 12 13 |
# File 'shoes-swt/lib/shoes/swt/common/resource.rb', line 9 def reset_graphics_context(graphics_context) dispose_previous_contexts set_defaults_on_context(graphics_context) track_graphics_context(graphics_context) end |
#set_defaults_on_context(graphics_context) ⇒ Object
21 22 23 24 25 26 |
# File 'shoes-swt/lib/shoes/swt/common/resource.rb', line 21 def set_defaults_on_context(graphics_context) graphics_context.set_alpha OPAQUE graphics_context.set_antialias(::Swt::SWT::ON) graphics_context.set_line_cap(::Swt::SWT::CAP_FLAT) graphics_context.set_transform(nil) end |
#track_graphics_context(graphics_context) ⇒ Object
28 29 30 |
# File 'shoes-swt/lib/shoes/swt/common/resource.rb', line 28 def track_graphics_context(graphics_context) @graphic_contexts << graphics_context end |