dlist.h

Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
00003 // 
00004 // This program is free software; you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation; either version 2 of the License, or
00007 // (at your option) any later version.
00008 // 
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 // You should have received a copy of the GNU General Public License
00014 // along with this program; if not, write to the Free Software
00015 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00016 //
00017 // 
00018 //
00019 
00020 
00021 
00022 #ifndef GNASH_DLIST_H
00023 #define GNASH_DLIST_H
00024 
00025 
00026 #include "container.h"
00027 #include "types.h"
00028 #include "impl.h"
00029 
00030 #include <list>
00031 #include <iosfwd>
00032 
00033 namespace gnash {
00034 
00036 typedef boost::intrusive_ptr<character> DisplayItem;
00037 
00039 //
00045 class DisplayList {
00046 
00047 public:
00048 
00052         //
00080         void    place_character(
00081                 character* ch,
00082                 uint16_t depth,
00083                 const cxform& color_xform,
00084                 const matrix& mat,
00085                 float ratio,
00086                 uint16_t clip_depth);
00087 
00091         //
00099         void replace_character(
00100                 character* ch,
00101                 uint16_t depth,
00102                 bool use_cxform,
00103                 const cxform& color_xform,
00104                 bool use_matrix,
00105                 const matrix& mat,
00106                 float ratio,
00107                 uint16_t clip_depth);
00108 
00109         void swap_characters(character* ch, character* ch2);
00110 
00113         void    move_display_object(
00114                 uint16_t depth,
00115                 bool use_cxform,
00116                 const cxform& color_xform,
00117                 bool use_matrix,
00118                 const matrix& mat,
00119                 float ratio,
00120                 uint16_t clip_depth);
00121 
00123         void    remove_display_object(uint16_t depth);
00124 
00128         void clear();
00129 
00130         //Vitaly:
00131         // It is executed only before the second and the subsequent
00132         // execution of execute_frame_tags(0) for sprite_instance
00133         // with frame count > 1.
00134         // Deletes the display objects created during execution 
00135         // of frames 2,... and not displayed in the 1-st frame.
00136         // Macromedia Flash does not call remove display object tag
00137         // for 1-st frame
00138         void clear_unaffected(std::vector<uint16>& affected_depths);
00139 
00143         void reset();
00144 
00146         void advance(float delta_time);
00147 
00151         void display();
00152 
00154         character* get_character_at_depth(int depth);
00155 
00156         const character* get_character_at_depth(int depth) const {
00157                 return const_cast<DisplayList*>(this)->get_character_at_depth(depth);
00158         }
00159 
00163         character* get_character_by_name(const std::string& name);
00164 
00165         const character* get_character_by_name(const std::string& name) const
00166         {
00167                 return const_cast<DisplayList*>(this)->get_character_by_name(name);
00168         }
00169 
00173         character* get_character_by_name_i(const std::string& name);
00174 
00178         //
00182         template <class V>
00183         inline void visitForward(V& visitor);
00184 
00188         //
00193         template <class V>
00194         inline void visitBackward(V& visitor);
00195 
00197         void dump(std::ostream& os) const;
00198 
00201         void get_invalidated_bounds(rect* bounds, bool force);
00202         
00203 
00205         size_t size() const { 
00206                 return _characters.size();
00207         }
00208 
00210         //
00215         int getNextHighestDepth() const;
00216 
00217 private:
00218 
00219         typedef std::list<DisplayItem> container_type;
00220         typedef container_type::iterator iterator;
00221         typedef container_type::const_iterator const_iterator;
00222         typedef container_type::reverse_iterator reverse_iterator;
00223         typedef container_type::const_reverse_iterator const_reverse_iterator;
00224 
00225         container_type _characters;
00226 
00227 
00228 };
00229 
00230 template <class V>
00231 void
00232 DisplayList::visitForward(V& visitor)
00233 {
00234         for (iterator it = _characters.begin(),
00235                         itEnd = _characters.end();
00236                 it != itEnd; ++it)
00237         {
00238                 DisplayItem& di = *it;
00239                 if ( ! visitor(di.get()) )
00240                 {
00241                         break;
00242                 }
00243         }
00244 }
00245 
00246 template <class V>
00247 void
00248 DisplayList::visitBackward(V& visitor)
00249 {
00250         for (reverse_iterator it = _characters.rbegin(),
00251                         itEnd = _characters.rend();
00252                 it != itEnd; ++it)
00253         {
00254                 DisplayItem& di = *it;
00255 
00256                 //if ( ! di.get() ) continue;
00257 
00258                 if ( ! visitor(di.get()) )
00259                 {
00260                         break;
00261 
00262 // The following logic must be implemented in the VISITOR,
00263 // not in the visiting function !!
00264 // (Vitaly, did you mean to do this in the MouseEntityFinder?)
00265 #if 0
00266                         // Can so happens that the uppermost depth contains shape
00267                         // and under it the button lays
00268                         // therefore we skip empty(no events) depth
00269                         if (di->can_handle_mouse_event())
00270                         {
00271                                 break;
00272                         }
00273 #endif
00274                 }
00275         }
00276 }
00277 
00278 }
00279 
00280 
00281 #endif // GNASH_DLIST_H
00282 
00283 
00284 
00285 // Local Variables:
00286 // mode: C++
00287 // c-basic-offset: 8 
00288 // tab-width: 8
00289 // indent-tabs-mode: t
00290 // End:

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