button_character_def.h

Go to the documentation of this file.
00001 // -- Thatcher Ulrich <tu@tulrich.com> 2003
00002 
00003 // This source code has been donated to the Public Domain.  Do
00004 // whatever you want with it.
00005 
00006 // SWF buttons.  Mouse-sensitive update/display, actions, etc.
00007 
00008 
00009 #ifndef GNASH_BUTTON_CHARACTER_DEF_H
00010 #define GNASH_BUTTON_CHARACTER_DEF_H
00011 
00012 
00013 #include "character_def.h"
00014 #include "sound.h"
00015 #include "rect.h" // for get_bound
00016 
00017 #ifndef UNUSED
00018 #define UNUSED(x) ((x) = (x))
00019 #endif
00020 
00021 // Forward declarations
00022 namespace gnash {
00023         class sprite_instance;
00024 }
00025 
00026 namespace gnash {
00027 
00028 class button_record
00029 {
00030 
00031 // TODO: make private, provide accessors 
00032 public:
00033 
00034         bool    m_hit_test;
00035         bool    m_down;
00036         bool    m_over;
00037         bool    m_up;
00038         int     m_character_id;
00039         character_def* m_character_def;
00040         int     m_button_layer;
00041         matrix  m_button_matrix;
00042         cxform  m_button_cxform;
00043 
00044 public:
00045 
00047         //
00049         bool    read(stream* in, int tag_type, movie_definition* m);
00050 
00052         //
00055         bool is_valid();
00056 
00057 };
00058         
00059 class button_action
00060 {
00061 public:
00062         enum condition
00063         {
00064                 IDLE_TO_OVER_UP = 1 << 0,
00065                 OVER_UP_TO_IDLE = 1 << 1,
00066                 OVER_UP_TO_OVER_DOWN = 1 << 2,
00067                 OVER_DOWN_TO_OVER_UP = 1 << 3,
00068                 OVER_DOWN_TO_OUT_DOWN = 1 << 4,
00069                 OUT_DOWN_TO_OVER_DOWN = 1 << 5,
00070                 OUT_DOWN_TO_IDLE = 1 << 6,
00071                 IDLE_TO_OVER_DOWN = 1 << 7,
00072                 OVER_DOWN_TO_IDLE = 1 << 8
00073         };
00074         int     m_conditions;
00075         std::vector<action_buffer*>     m_actions;
00076 
00077         ~button_action();
00078         void    read(stream* in, int tag_type);
00079 };
00080 
00081 
00082 class button_character_definition : public character_def
00083 {
00084 public:
00085 
00087   int m_min_layer;
00088 
00090   int m_max_layer;
00091 
00092         struct sound_info
00093         {
00094                 void read(stream* in);
00095 
00096                 bool m_no_multiple;
00097                 bool m_stop_playback;
00098                 bool m_has_envelope;
00099                 bool m_has_loops;
00100                 bool m_has_out_point;
00101                 bool m_has_in_point;
00102                 uint32_t m_in_point;
00103                 uint32_t m_out_point;
00104                 uint16_t m_loop_count;
00105                 std::vector<sound_handler::sound_envelope> m_envelopes;
00106         };
00107 
00108         struct button_sound_info
00109         {
00110                 uint16_t m_sound_id;
00111                 sound_sample_impl*      m_sam;
00112                 sound_info m_sound_style;
00113         };
00114 
00115         struct button_sound_def
00116         {
00117                 void    read(stream* in, movie_definition* m);
00118                 button_sound_info m_button_sounds[4];
00119         };
00120 
00121 
00122         bool m_menu;
00123         std::vector<button_record>      m_button_records;
00124         std::vector<button_action>      m_button_actions;
00125         button_sound_def*       m_sound;
00126 
00127         button_character_definition();
00128         virtual ~button_character_definition();
00129 
00131         character* create_character_instance(character* parent, int id);
00132 
00133         void    read(stream* in, int tag_type, movie_definition* m);
00134         
00135         const rect&     get_bound() const {
00136     // It is required that get_bound() is implemented in character definition
00137     // classes. However, button character definitions do not have shape 
00138     // definitions themselves. Instead, they hold a list of shape_character_def.
00139     // get_bound() is currently only used by generic_character which normally
00140     // is used only shape character definitions. See character_def.h to learn
00141     // why it is virtual anyway.
00142     // get_button_bound() is used for buttons.
00143     assert(0); // should not be called  
00144                 static rect unused;
00145                 return unused;
00146   }
00147   
00148   const rect&   get_button_bound(int id) const {
00149     UNUSED(id);
00150     assert(0); // not implemented
00151   }
00152         
00153 };
00154 
00155 }       // end namespace gnash
00156 
00157 
00158 #endif // GNASH_BUTTON_CHARACTER_DEF_H
00159 
00160 
00161 // Local Variables:
00162 // mode: C++
00163 // c-basic-offset: 8 
00164 // tab-width: 8
00165 // indent-tabs-mode: t
00166 // End:

Generated on Thu Nov 23 22:31:30 2006 for Gnash by  doxygen 1.4.6