/[enigma]/enigma/src/d_models.hh
ViewVC logotype

Diff of /enigma/src/d_models.hh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by dheck, Thu Mar 13 17:58:33 2003 UTC revision 1.6 by dheck, Tue May 13 18:55:05 2003 UTC
# Line 35  namespace display Line 35  namespace display
35      public:      public:
36          // Constructors.          // Constructors.
37          Image(px::Surface *i, int xoff=0, int yoff=0)          Image(px::Surface *i, int xoff=0, int yoff=0)
38              : image(i), rect(), refcount(1)          : image(i), rect(), refcount(1)
39          {          {
40              rect.w = i->width();              rect.w = i->width();
41              rect.h = i->height();              rect.h = i->height();
# Line 43  namespace display Line 43  namespace display
43              this->yoff = yoff;              this->yoff = yoff;
44          }          }
45          Image(px::Surface *i, px::Rect r, int xoff=0, int yoff=0)          Image(px::Surface *i, px::Rect r, int xoff=0, int yoff=0)
46              : image(i), rect(r), refcount(1)          : image(i), rect(r), refcount(1)
47          {          {
48              this->xoff = xoff;              this->xoff = xoff;
49              this->yoff = yoff;              this->yoff = yoff;
# Line 95  namespace display Line 95  namespace display
95                    
96          Image *get_image() { return image; }          Image *get_image() { return image; }
97    
98          void draw_shade(px::GC &gc, int x, int y) {}          void draw_shadow(px::GC &gc, int x, int y) {}
99          Model *clone() { return new ImageModel(image); }          Model *clone() { return new ImageModel(image); }
100      };      };
101    
102  //----------------------------------------  //----------------------------------------
103  // ShadedModel  // ShadedModel
104  //----------------------------------------  //----------------------------------------
105      class ShadedModel : public Model {      class ShadowModel : public Model {
106      public:      public:
107          ShadedModel(Model *m, Model *sh) {model=m; shade=sh;}          ShadowModel(Model *m, Model *sh) {model=m; shade=sh;}
108          ~ShadedModel() { delete model; delete shade; }          ~ShadowModel() { delete model; delete shade; }
109    
110          // Model interface          // Model interface
111    
# Line 122  namespace display Line 122  namespace display
122              if (model)              if (model)
123                  model->draw(gc,x,y);                  model->draw(gc,x,y);
124          }          }
125          void draw_shade(px::GC &gc, int x, int y) {          void draw_shadow(px::GC &gc, int x, int y) {
126              if (shade)              if (shade)
127                  shade->draw(gc,x,y);                  shade->draw(gc,x,y);
128          }          }
129          Model *get_shadow() const { return shade; }          Model *get_shadow() const { return shade; }
130          Model *clone() {          Model *clone() {
131              return new ShadedModel(model->clone(), shade->clone());              return new ShadowModel(model->clone(), shade->clone());
132          }          }
133    
134      private:      private:
135          Model *model, *shade;          Model *model, *shade;
136      };      };
# Line 155  namespace display Line 156  namespace display
156              bg->set_callback(cb);              bg->set_callback(cb);
157              fg->set_callback(cb);              fg->set_callback(cb);
158          }          }
         double duration() const { return 0; }  
159          void reverse() {          void reverse() {
160              bg->reverse();              bg->reverse();
161              fg->reverse();              fg->reverse();
# Line 174  namespace display Line 174  namespace display
174              bg->draw(gc,x,y);              bg->draw(gc,x,y);
175              fg->draw(gc,x,y);              fg->draw(gc,x,y);
176          }          }
177          void draw_shade(px::GC &gc, int x, int y) {          void draw_shadow(px::GC &gc, int x, int y) {
178              bg->draw_shade(gc,x,y);              bg->draw_shadow(gc,x,y);
179          }          }
180          Model *clone() {          Model *clone() {
181              return new CompositeModel(bg->clone(), fg->clone());              return new CompositeModel(bg->clone(), fg->clone());
# Line 189  namespace display Line 189  namespace display
189          std::vector<std::string> modelnames;          std::vector<std::string> modelnames;
190      public:      public:
191          void draw(px::GC &gc, int x, int y) {}          void draw(px::GC &gc, int x, int y) {}
192          void draw_shade(px::GC &gc, int x, int y) {}          void draw_shadow(px::GC &gc, int x, int y) {}
193          void add_model(const std::string &name) {modelnames.push_back(name);}          void add_model(const std::string &name) {modelnames.push_back(name);}
194    
195          // Model interface          // Model interface
# Line 204  namespace display Line 204  namespace display
204      public:      public:
205          AliasModel(const string &modelname) : name(modelname) {}          AliasModel(const string &modelname) : name(modelname) {}
206          void draw(px::GC &gc, int x, int y) {}          void draw(px::GC &gc, int x, int y) {}
207          void draw_shade(px::GC &gc, int x, int y) {}          void draw_shadow(px::GC &gc, int x, int y) {}
208          Model *clone();          Model *clone();
209      };      };
210    
# Line 225  namespace display Line 225  namespace display
225      public:      public:
226          AnimRep(bool l) : loop(l), refcount(1) {}          AnimRep(bool l) : loop(l), refcount(1) {}
227          ~AnimRep() { delete_sequence(frames.begin(), frames.end()); }          ~AnimRep() { delete_sequence(frames.begin(), frames.end()); }
         double duration() const {  
             double d = 0;  
             for (unsigned i=0; i<frames.size(); i++)  
                 d += frames[i]->duration;  
             return d;  
         }  
228          vector<AnimFrame*>  frames;          vector<AnimFrame*>  frames;
229          bool                loop;          bool                loop;
230          int                 refcount;          int                 refcount;
# Line 240  namespace display Line 234  namespace display
234      public:      public:
235          Anim2d(bool loop) : rep(new AnimRep(loop)) {}          Anim2d(bool loop) : rep(new AnimRep(loop)) {}
236          ~Anim2d();          ~Anim2d();
         double duration() const;  
237          void set_callback(ModelCallback *cb) { callback = cb; }          void set_callback(ModelCallback *cb) { callback = cb; }
238    
239          void add_frame(Model *m, double duration);          void add_frame(Model *m, double duration);
# Line 249  namespace display Line 242  namespace display
242          ** Model interface          ** Model interface
243          */          */
244          void draw(px::GC &gc, int x, int y);          void draw(px::GC &gc, int x, int y);
245          void draw_shade(px::GC &gc, int x, int y);          void draw_shadow(px::GC &gc, int x, int y);
246          Model *clone() { return new Anim2d(rep); }          Model *clone() { return new Anim2d(rep); }
247          void reverse() { reversep = !reversep; }          void reverse() { reversep = !reversep; }
248    

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26