indexing description: "[ A box that decorates its child box with a colored border that may be hidden. The size of the border can be set separately for each dimension. The size of a border box is determined by the size of its child box plus double the size of the border. Initially, the border is hidden. Use set_border_hidden to change this. ]" author: "" date: "$Date$" revision: "$Revision$" class EM_VIZ_BORDER_BOX [B -> EM_VIZ_BOX] inherit EM_VIZ_DECORATOR_BOX [B] redefine resize_container, realign_contents, vz_render end EM_VIZ_COLORED rename color as border_color, set_color as set_border_color end create make feature -- Initialization make (a_size: like border_size) is -- Initialize with `a_border_size' do make_decorator make_colored (Viz_options.default_border_color) set_border_size (a_size) set_border_hidden (False) end feature -- Access border_size: EM_VECTOR3D -- Border size in all three dimensions border_hidden: BOOLEAN -- Is border hidden when rendering? feature -- Element change set_border_size (a_size: like border_size) is -- Set border size do border_size := a_size expire ensure set: border_size = a_size expired: needs_update end set_border_hidden (hide: like border_hidden) is -- Set border hidden or visible do border_hidden := hide expire ensure set: border_hidden = hide expired: needs_update end feature {NONE} -- Implementation vz_render (viewing_direction: EM_VECTOR3D) is -- Render border and child (if any) do if viewing_direction.z > 0.0 then Precursor (viewing_direction) if not border_hidden then render_border end else if not border_hidden then render_border end Precursor (viewing_direction) end end render_border is -- Render border local e00, e01, e11, e10: EM_VECTOR3D m00, m01, m11, m10: EM_VECTOR3D do vz_push_attributes (Vz_polygon_bit | Vz_depth_buffer_bit) vz_set_depth_test (False, True) vz_set_culling (False, Vz_front_and_back) e00 := bounds.min e11 := bounds.max e11.set_z (e00.z) m00 := e00 + [border_size.x, border_size.y, 0.0] m11 := e11 - [border_size.x, border_size.y, 0.0] e10 := [e11.x, e00.y, e00.z] e01 := [e00.x, e11.y, e00.z] m10 := e10 + [-border_size.x, border_size.y, 0.0] m01 := e01 + [ border_size.x, -border_size.y, 0.0] vz_begin_quad_strip vz_color (border_color) vz_normal3d (0, 0, -1) vz_vertex (m00) vz_vertex (e00) vz_vertex (m10) vz_vertex (e10) vz_vertex (m11) vz_vertex (e11) vz_vertex (m01) vz_vertex (e01) vz_vertex (m00) vz_vertex (e00) vz_end vz_pop_attributes end resize_container is -- Resize container do set_size_internal (border_size + content_size + border_size) end realign_contents is -- Realign child do if item /= Void then item.reposition (border_size) end end end