Eiffel Media API
Overview Cluster Class Classes Index      Previous Next      Top Features

em.widget

Class EM_COMPONENT_SCENE


Direct ancestors

EM_SCENE, EM_SHARED_THEME, EM_SHARED_WIDGET_OPTIONS, EM_SHARED_COMPONENT_EVENT_QUEUE, EM_SHARED_SUBSYSTEMS, EM_SHARED_FOCUS, EM_CONSTANTS, GL_FUNCTIONS

Known direct descendants

EM_WIDGET_SCENE

Creation

Features

Invariants

indexing

description

A scene that can contain multiple components.

Components have to be subclasses of EM_COMPONENT. Add new components with add_component.
This enables mixing of widgets, 2D and 3D in one scene.

Implemented components are:
- EM_WIDGET: Display a widget.
- EM_WINDOW: Display a window (a special EM_WIDGET).
- EM_2D_COMPONENT: Use an EM_SURFACE to draw the content of the component.
- EM_3D_COMPONENT: Use OpenGL to draw the component.

The next scene can be set and started using set_next_scene and start_next_scene.

Subclasses must call make_component_scene at creation.

date

$Date: 2005/10/23 20:36:21 $

revision

$Revision: 1.26 $

class

EM_COMPONENT_SCENE

inherit

EM_SCENE

create

make_component_scene

-- Initialise component scene.

feature -- Initialization

uninitialize_scene

-- Uninitialize scene.
-- This is called right before next scene is displayed.
-- Redefine this to clean up some needed things (openGl properties, images, ...)

-- (From EM_SCENE)

feature -- Access

component_at_position (a_x, a_y: INTEGER): EM_COMPONENT

-- Top most component at position a_x a_y

components: DS_LINEAR [EM_COMPONENT]

-- List of components

ensure
components_not_void: Result /= Void
event_loop: EM_EVENT_LOOP

-- Event loop that makes scene running

-- (From EM_SCENE)

next_scene: EM_SCENE

-- Scene that should be executed after this scene ends.
-- If next_scene = Void the program just ends.

-- (From EM_SCENE)

screen: EM_VIDEO_SURFACE

-- Surface where scene is drawed

-- (From EM_SCENE)

feature -- Measurement

height: INTEGER

-- Height of scene

width: INTEGER

-- Width of scene

feature -- Status report

has_component (a_component: EM_COMPONENT): BOOLEAN

-- Does Current has a_component to display?

require
a_component_not_void: a_component /= Void
ensure
consistent: Result = components.has (a_component)
is_running: BOOLEAN

-- Is scene currently running?
-- Otherwise no events are dispatched and no animation will run right now.

-- (From EM_SCENE)

feature -- Status setting

set_frame_counter_visibility (a_value: BOOLEAN)

-- If a_value is True make frame counter visible,
-- else make it invisible.

-- (From EM_SCENE)

feature -- Element change

add_component (a_component: EM_COMPONENT)

-- Add a_component to components.

require
a_component_not_void: a_component /= Void
a_component_not_present: not components.has (a_component)
ensure
a_component_added: components.has (a_component)
components_size_incremented: components.count = old components.count + 1
callback_for_set_next_scene_and_start: FUNCTION[ANY, TUPLE[], EM_SCENE]

-- we have to create next scene in same thread as the SDL thread
-- this function should point to a feature were next scene is created

-- (From EM_SCENE)

next_scene_is_set: BOOLEAN

-- Indicates that next scene is set and must be proceeded by
-- the main SDL Thread (syncronise both threads)

-- (From EM_SCENE)

set_next_scene (a_scene: like next_scene)

-- Set next_scene to a_scene.

-- (From EM_SCENE)

ensure
next_scene_set: next_scene = a_scene
set_next_scene_from_outside (a_callback: like callback_for_set_next_scene_and_start)

-- Set next_scene to a_scene from an other thread
-- Make sure that start_next_scene is called by the main SDL Thread

-- (From EM_SCENE)

ensure
next_scene_set: callback_for_set_next_scene_and_start = a_callback
next_scene_set: next_scene_is_set = true

feature -- Removal

remove_component (a_component: EM_COMPONENT)

-- Remove a_component from components.

require
a_component_not_void: a_component /= Void
ensure
component_removed_if_present: old components.has (a_component) implies (not components.has (a_component))
components_size_decremented: old components.has (a_component) implies (components.count = old components.count - 1)
wipe_out_components

-- Remove all components.

ensure
components_removed: components.is_empty

feature -- Miscellaneous

quit

-- Stop scene whitout starting another one.

-- (From EM_SCENE)

run (a_screen: EM_VIDEO_SURFACE)

-- Run scene and show it on a_screen.

-- (From EM_SCENE)

require
a_screen_not_void: a_screen /= Void
start_next_scene

-- Stop Current and advance to next_scene.

-- (From EM_SCENE)

start_next_scene_threaded

-- Call creation procedure for next scene and start this scene immediadely

-- (From EM_SCENE)

feature -- Drawing

redraw

-- Redraw the scene.

-- (From EM_SCENE)

feature -- Events

animation_event: EM_EVENT_TYPE [TUPLE [INTEGER]]

-- Animation event, allows animatable objects to perform animation
-- (i.e. moving them selves) before they get drawed.
-- As an argument the reference time in milliseconds is passed
-- up to which the animatable objects should draw them selves.
-- This event gets published right before the scene is redrawed.

-- (From EM_SCENE)

feature {EM_WINDOW} -- Mouse management

set_mouse_focus (new_focus: EM_COMPONENT)

-- Set mouse focus to new_focus.

require
new_focus: new_focus /= Void implies has_component (new_focus)
ensure
mouse_focus_set: mouse_focus = new_focus

feature -- Animation

animate

-- Let all subscribed animatable objects perform their animation.
-- (Calls go_to_time of animatable objects with current time tick)

-- (From EM_SCENE)

start_animating (an_animatable: EM_ANIMATABLE)

-- Subscribe an_animatable to be animated when Current is running.

-- (From EM_SCENE)

stop_animating (an_animatable: EM_ANIMATABLE)

-- Unsubscribe an_animatable from beeing animated when Current is running.

-- (From EM_SCENE)

invariant

make_component_scene_called: is_make_component_scene_called
components_impl_not_void: components_impl /= Void

-- From EM_SCENE
make_scene_called: is_make_scene_called
animation_event_not_void: animation_event /= Void
event_loop_not_void: event_loop /= Void
screen_not_void_when_running: is_running implies screen /= Void

-- From ANY
reflexive_equality: standard_is_equal (Current)
reflexive_conformance: conforms_to (Current)

has_running_scene_definition: has_running_scene implies running_scene /= Void

end