#--
-# $Id: part.rb 5 2005-03-26 20:23:02Z tilman $
+# $Id: part.rb 18 2005-04-02 21:45:24Z tilman $
#
# Copyright (c) 2005 Tilman Sauerbeck (tilman at code-monkey de)
#
end
class Description
- attr_reader :rel
- attr_accessor :visible
+ attr_reader :rel, :aspect, :step
+ attr_accessor :visible, :aspect_preference
def initialize(name = "default", value = 0.0)
@name = name.to_str.dup.freeze
@align = [0.5, 0.5]
@min = [0, 0]
@max = [-1, -1]
- @step_x = 0
- @step_y = 0
+ @step = [0, 0]
+ @aspect = [0.0, 0.0]
+ @aspect_preference = :none
@rel = [Relation.new(0.0, 0), Relation.new(1.0, -1)]
@color = [].fill(255, 0..3)
@color_class = ""
end
+ def set_step(x = 0, y = 0)
+ @step = [x, y]
+ end
+
+ def set_aspect(x = 0.0, y = 0.0)
+ @aspect = [x, y]
+ end
+
def set_align(x = 0.5, y = 0.5)
@align = [x, y]
end
pairs.map { |p| p.hex }
end
+ def map_aspect_preference
+ case @aspect_preference
+ when :none
+ 0
+ when :vertical
+ 1
+ when :horizontal
+ 2
+ when :both
+ 3
+ else
+ raise(RedactError, "invalid aspect preference value - " +
+ @aspect_preference.to_s)
+ end
+ end
+
def to_eet_name
"Edje_Part_Description"
end
"min.h" => [@min[1]],
"max.w" => [@max[0]],
"max.h" => [@max[1]],
- "step.x" => [@step_x],
- "step.y" => [@step_y],
- "aspect.min" => [0.0, :double],
- "aspect.max" => [0.0, :double],
- "aspect.prefer" => [0, :char],
+ "step.x" => [@step[0]],
+ "step.y" => [@step[1]],
+ "aspect.min" => [@aspect[0], :double],
+ "aspect.max" => [@aspect[1], :double],
+ "aspect.prefer" => [map_aspect_preference, :char],
"rel1.relative_x" => [@rel[0].rel[0], :double],
"rel1.relative_y" => [@rel[0].rel[1], :double],
"rel1.offset_x" => [@rel[0].offset[0]],