X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=lib%2Fredact%2Fpart.rb;h=4d6cf9f5e410f230580bb7c40cec08c1dea2b71d;hb=e9365708ca242a2f4104adcd9551743b505894f8;hp=6b0b53696594223af9ac5991cd4e7f2d26d20417;hpb=2c25c90e2aaf57a7508a7988f58b2784d5071a7e;p=redact.git diff --git a/lib/redact/part.rb b/lib/redact/part.rb index 6b0b536..4d6cf9f 100644 --- a/lib/redact/part.rb +++ b/lib/redact/part.rb @@ -1,5 +1,5 @@ #-- -# $Id: part.rb 1 2005-03-26 01:32:38Z tilman $ +# $Id: part.rb 19 2005-04-02 22:05:24Z tilman $ # # Copyright (c) 2005 Tilman Sauerbeck (tilman at code-monkey de) # @@ -69,7 +69,7 @@ module Redact end end - def description(name = "default", value = 0.0) + def description(name = "default", value = 0.0) # :yields: desc d = @descriptions[desc_key(name, value)] block_given? ? (yield d) : d @@ -211,8 +211,8 @@ module Redact end class Description - attr_reader :rel - attr_accessor :visible + attr_reader :rel, :aspect, :step + attr_accessor :visible, :aspect_preference, :color_class def initialize(name = "default", value = 0.0) @name = name.to_str.dup.freeze @@ -221,13 +221,22 @@ module Redact @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 @@ -266,6 +275,22 @@ module Redact 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 @@ -280,11 +305,11 @@ module Redact "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]], @@ -429,7 +454,7 @@ module Redact class TextDescription < Description attr_reader :font - attr_accessor :text, :font_size + attr_accessor :text, :font_size, :text_class def initialize(name = "default", value = 0.0) super