Sha256: 9ba3e57eeeaf0e419a8d988453ef150c177708356e56f1f0b27b4efb7aa9731b
Contents?: true
Size: 934 Bytes
Versions: 1
Compression:
Stored size: 934 Bytes
Contents
class Shoes module Common # Style methods. # # Including classes must have instance variable `@style` module Style # Adds style, or just returns current style if no argument # # Returns the updated style def style(new_styles = nil) update_style(new_styles) if need_to_update_style?(new_styles) @style end private def update_style(new_styles) normalized_style = StyleNormalizer.new.normalize new_styles @style.merge! normalized_style end def need_to_update_style?(new_styles) new_styles && style_changed?(new_styles) end # check necessary because update_style trigger a redraw in the redrawing # aspect and we want to avoid unnecessary redraws def style_changed?(new_styles) new_styles.each_pair.any? do |key, value| @style[key] != value end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shoes-4.0.0.pre1 | lib/shoes/common/style.rb |