---------------------------------------------------------------------------
-- Vdo_shadow
--
-- Drop shadow designed to drop behind a rectangluar image.
-- Used to draw a rectangular shadow behind any object
-- Requires the use of 3 types of bitmaps:
-- Center : "ui_blank"
-- Side : "ui_dialog_shadow_side"
-- Corner : "ui_dialog_shadow_corner"
---------------------------------------------------------------------------
-- Inherited from Vdo_base_object
Vdo_shadow = Vdo_base_object:new_base()
function vdo_button_pc_init()
end
function vdo_button_pc_cleanup()
end
function Vdo_shadow:init()
--Store references to shadow...
self.c_h = vint_object_find("shadow_c", self.handle)
self.nw_h = vint_object_find("shadow_nw", self.handle)
self.n_h = vint_object_find("shadow_n", self.handle)
self.ne_h = vint_object_find("shadow_ne", self.handle)
self.e_h = vint_object_find("shadow_e", self.handle)
self.se_h = vint_object_find("shadow_se", self.handle)
self.s_h = vint_object_find("shadow_s", self.handle)
self.sw_h = vint_object_find("shadow_sw", self.handle)
self.w_h = vint_object_find("shadow_w", self.handle)
end
function Vdo_shadow:set_props(x, y, show_center, shadow_size)
x = x or 100
y = y or 100
show_center = show_center or false
shadow_size = shadow_size or 19 --default...
self:set_size(x,y)
self:show_center(show_center)
self:set_spread(shadow_size)
end
-- Set size of the triangle.
function Vdo_shadow:set_size(x, y)
-- Find shadow objects
--Top left Corner
local start_x = 0
local start_y = 0
local width = x
local height = y
local sides_width, sides_height = element_get_actual_size(self.n_h)
--N
element_set_actual_size(self.n_h, width, sides_height)
--NE
vint_set_property(self.ne_h, "anchor", width + start_x, start_y)
--E
vint_set_property(self.e_h, "anchor", width + start_x, start_y)
element_set_actual_size(self.e_h, height, sides_height)
--SE
vint_set_property(self.se_h, "anchor", width + start_x, height + start_y)
--S
vint_set_property(self.s_h, "anchor", start_x, height + start_y)
element_set_actual_size(self.s_h, width, -sides_height)
--SW
vint_set_property(self.sw_h, "anchor", start_x, height + start_y)
--element_set_actual_size(sw_h, width, sides_height)
--W
element_set_actual_size(self.w_h, height, sides_height)
--C
element_set_actual_size(self.c_h, width, height)
self.width = x
self.height = y
end
function Vdo_shadow:set_offset(x, y)
local shadow_h = vint_object_find("shadow_grp", self.handle)
vint_set_property(shadow_h, "anchor", x, y)
end
function Vdo_shadow:show_center(show_center)
vint_set_property(self.c_h, "visible", show_center)
end
function Vdo_shadow:set_spread(spread_px)
local sides_width, sides_height = element_get_actual_size(self.ne_h)
--have to flip the bitmaps, so this is how we keep track of the flipping
local corners = {
{self.nw_h, 1, 1}, --object_h, x, y
{self.ne_h, -1, 1},
{self.se_h, -1, -1},
{self.sw_h, 1, -1},
}
local sides = {
{self.n_h, 1,1},
{self.e_h, 1,1},
{self.s_h, 1,-1},
{self.w_h, 1,1},
}
for idx, corner in pairs(corners) do
element_set_actual_size(corner[1], abs(spread_px) * corner[2], abs(spread_px) * corner[3])
end
for idx, side in pairs(sides) do
local width, height = element_get_actual_size(side[1])
element_set_actual_size(side[1], abs(width) * side[2], abs(spread_px) * side[3])
end
end