indexing description: "[ Drawable panel demo. ]" date: "$Date$" revision: "$Revision$" class DRAWABLES_DEMO_PANEL inherit EM_PANEL EM_SHARED_STANDARD_FONTS export {NONE} all end create make feature {NONE} -- Initialisation make (a_scene: EM_SCENE) is -- Initialise panel and register animations on 'a_scene'. local text: STRING label: EM_LABEL never_ending_horizontal: EM_NEVER_ENDING_BACKGROUND_HORIZONTAL string: EM_STRING polygon: EM_POLYGON circle: EM_CIRCLE do make_void_surface -- Help text create text.make_empty text.append_string ("To display EM_DRAWABLEs use an EM_DRAWABLE_PANEL.%N") text.append_string ("Basic approach:%N") text.append_string (" - create EM_DRAWABLE_PANEL%N") text.append_string (" - place drawables inside 'container' of drawable-panel%N") create label.make_from_text (text) label.set_position (70, 10) label.set_dimension (500, 90) label.enable_multilined label.align_top add_widget (label) -- EM_DRAWABLE_PANEL creation create container.make (500, 500) create drawable_panel.make_from_container (container) drawable_panel.set_dimension (500, 500) drawable_panel.set_position (70, 100) drawable_panel.set_tooltip ("Middle + Drag = Zoom / Right + Drag = Scroll") drawable_panel.set_border (create {EM_BEVEL_BORDER}.make_down) add_widget (drawable_panel) never_ending_horizontal := the_demo_code (a_scene) never_ending_horizontal.set_y (10) never_ending_horizontal.set_speed (-100) container.put_right (never_ending_horizontal) a_scene.start_animating (never_ending_horizontal) create string.make ("An EM_STRING", Standard_ttf_fonts.bitstream_vera_sans_bold (24)) string.set_x_y (50, 250) container.put_right (string) create polygon.make_empty polygon.extend (create {EM_VECTOR_2D}.make (0, 0)) polygon.extend (create {EM_VECTOR_2D}.make (50, 30)) polygon.extend (create {EM_VECTOR_2D}.make (100, 20)) polygon.extend (create {EM_VECTOR_2D}.make (60, 60)) polygon.set_line_width (10) polygon.set_line_color (create {EM_COLOR}.make_with_rgb (0, 0, 255)) polygon.set_x_y (300, 300) container.put_right (polygon) create circle.make (create {EM_VECTOR_2D}.make (0, 0), 40) circle.set_filled (True) circle.set_fill_color (create {EM_COLOR}.make_with_rgb (255, 0, 0)) circle.set_line_color (create {EM_COLOR}.make_with_rgb (0, 255, 0)) circle.set_line_width (10) circle.set_x_y (100, 400) container.put_right (circle) -- Usage text create label.make_from_text ("middle button and dragging to zoom - right button and dragging to scroll") label.set_position (70, 600) label.set_dimension (500, 20) label.align_center add_widget (label) end the_demo_code (a_scene: EM_SCENE): EM_NEVER_ENDING_BACKGROUND_HORIZONTAL is -- This is the sequence of code that builds the never ending background -- Code copied from $EM/example/drawable/first_scene.e local flag: EM_BITMAP chain: EM_BITMAP plane: EM_BITMAP em_logo: EM_ANIMATION tp: EM_TILE_PATTERN_HORIZONTAL sprite: EM_SPRITE a_container: EM_DRAWABLE_CONTAINER [EM_DRAWABLE] do -- 1. Load all needed images bitmap_factory.create_bitmap_from_image ("./image/a_ende.png") flag := bitmap_factory.last_bitmap flag.set_transparent_color (255, 255, 255) bitmap_factory.create_bitmap_from_image ("./image/a_kette.png") chain := bitmap_factory.last_bitmap chain.set_transparent_color (255, 255, 255) bitmap_factory.create_bitmap_from_image ("./image/a_flieger.png") plane := bitmap_factory.last_bitmap plane.set_transparent_color (255, 255, 255) create em_logo.make_from_file ("./image/em.anim") -- 2. Create an EM_TILE_PATTERN_HORIZONTAL and an EM_SPRITE create tp.make (chain, 3) create sprite.make_from_animation (em_logo, 14, 30) -- 3. Put it all into an EM_DRAWABLE_CONTAINER create a_container.make a_container.extend (flag) tp.set_x_y (flag.width,0) a_container.extend (tp) plane.set_x_y (tp.x+tp.width,0) a_container.extend (plane) sprite.start sprite.set_do_loop (True) a_container.extend (sprite) -- 4. Now create a EM_NEVER_ENDING_BACKGROUND_HORIZONTAL create Result.make (a_container) end feature -- Access drawable_panel: EM_DRAWABLE_PANEL -- Drawable panel container: EM_ZOOMABLE_WIDGET -- Zoomable container on drawable panel end