From 4eff39fc09668d7984ee93e0a291df39a8dd3d4a Mon Sep 17 00:00:00 2001 From: Tilman Sauerbeck Date: Sat, 2 Apr 2005 21:45:24 +0000 Subject: [PATCH] Made 'step' and 'aspect' parameters configurable. --- ChangeLog | 6 +++++- lib/redact/part.rb | 45 +++++++++++++++++++++++++++++++++++---------- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 98c5fda..8d3b24e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,11 @@ -- -$Id: ChangeLog 16 2005-03-29 20:11:04Z tilman $ +$Id: ChangeLog 18 2005-04-02 21:45:24Z tilman $ ++ +2005-04-02 Tilman Sauerbeck (tilman at code-monkey de) + * lib/redact/part.rb: Made 'step' and 'aspect' parameters + configurable + 2005-03-29 Tilman Sauerbeck (tilman at code-monkey de) * Released version 0.1.0 diff --git a/lib/redact/part.rb b/lib/redact/part.rb index 71f9823..395b536 100644 --- a/lib/redact/part.rb +++ b/lib/redact/part.rb @@ -1,5 +1,5 @@ #-- -# $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) # @@ -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 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]], -- 2.30.2