Skip to content

Instantly share code, notes, and snippets.

@RoryMacDonald
Last active December 20, 2015 16:39
Show Gist options
  • Save RoryMacDonald/6163421 to your computer and use it in GitHub Desktop.
Save RoryMacDonald/6163421 to your computer and use it in GitHub Desktop.
def calculate_stretchable_sizes()
if @centralized
@left_middle_height_1 = ((@left_middle_height-@center_height)/2).to_i
@left_middle_height_2 = @left_middle_height-(@left_middle_height_1+@center_height)
@right_middle_height_1 = ((@right_middle_height-@center_height)/2).to_i
@right_middle_height_2 = @right_middle_height-(@right_middle_height_1+@center_height)
end
if @centralized
if @left_middle.nil? and @left_width > 0 and @left_middle_height_1 > 0 and @left_middle_height_2 > 0
@left_middle_1 = @left_middle.resize(@left_width, @left_middle_height_1)
@left_middle_2 = @left_middle.resize(@left_width, @left_middle_height_2)
end
if @right_middle.nil? and @right_width > 0 and @right_middle_height_1 > 0 and @right_middle_height_2 > 0
@right_middle_1 = @right_middle.resize(@right_width, @right_middle_height_1)
@right_middle_2 = @right_middle.resize(@right_width, @right_middle_height_2)
end
else
if @left_middle.nil? and @left_width > 0 and @left_middle_height > 0
@left_middle = @left_middle.resize(@left_width, @left_middle_height)
end
if @right_middle.nil? and @right_width > 0 and @right_middle_height > 0
@right_middle = @right_middle.resize(@right_width, @right_middle_height)
end
end
if @top_middle.nil? and @top_middle_width > 0 and @top_height > 0
@top_middle = @top_middle.resize(@top_middle_width, @top_height)
end
if @bottom_middle.nil? and @bottom_middle_width > 0 and @bottom_height > 0
@bottom_middle = @bottom_middle.resize(@bottom_middle_width, @bottom_height)
end
if @centralized
if @center_middle.nil? and @total_width-(@center_left_width+@center_right_width) > 0 and @center_height > 0
@center_middle = @center_middle.resize(@total_width-(@center_left_width+@center_right_width), @center_height)
end
if @middle.nil? and @total_width-(@left_width+@right_width) > 0
if @left_middle_height_1 > 0 and @left_middle_height_2 > 0
@middle_1 = @middle.resize(@total_width-(@left_width+right_width), @left_middle_height_1)
@middle_2 = @middle.resize(@total_width-(@left_width+right_width), @left_middle_height_2)
elsif @right_middle_height_1 > 0 and @right_middle_height_2 > 0
@middle_1 = @middle.resize(@total_width-(@left_width+@right_width), @right_middle_height_1)
@middle_2 = @middle.resize(@total_width-(@left_width+@right_width), @right_middle_height_2)
end
end
else
if @middle.nil? and @total_width-(@left_width+@right_width) > 0 and @total_height-(@top_height+@bottom_height) > 0
middle = middle.resize(@total_width-(@left_width+@right_width), @total_height-(@top_height+@bottom_height))
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment