source: golgotha/src/golg/editor/dialogs/d_time.cc @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 14 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 3.1 KB
Line 
1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9#include "window/style.hh"
10#include "gui/text_input.hh"
11#include "gui/text.hh"
12#include "g1_speed.hh"
13#include "window/colorwin.hh"
14#include "editor/editor.hh"
15#include "editor/e_res.hh"
16
17class g1_time_edit_window : public i4_color_window_class
18{
19  i4_text_input_class *si, *mi;
20  w32 t_sec, t_msec;
21
22public:
23  char *name() { return "time edit"; }
24
25  g1_time_edit_window(i4_graphical_style_class *style, w32 cur_frame)
26    : i4_color_window_class(0,0,style->color_hint->neutral(), style)
27  {
28    i4_text_window_class *st,*mt;
29    i4_str *sec_str, *msec_str;
30
31    st=new i4_text_window_class(g1_ges("sec"),style);
32    mt=new i4_text_window_class(g1_ges("msec"),style);
33
34    t_sec=cur_frame/G1_MOVIE_HZ;
35    t_msec=(cur_frame-t_sec*G1_MOVIE_HZ)*60/G1_MOVIE_HZ;
36
37
38    sec_str=g1_ges("sec_fmt").sprintf(10,t_sec);
39    si=new i4_text_input_class(style, *sec_str, 40, 8, this);
40
41    msec_str=g1_ges("msec_fmt").sprintf(10,t_msec);
42    mi=new i4_text_input_class(style, *msec_str, 40, 8, this);
43
44    delete sec_str;
45    delete msec_str;
46
47    add_child(0,3,st);
48    add_child(st->width(),0,si);
49
50    add_child(st->width() + si->width(),3,mt);
51    add_child(st->width() + si->width() + mt->width(),0,mi);
52
53    resize_to_fit_children();
54  }
55
56  void change_time()
57  {     
58    i4_spline_class *s[g1_controller_edit_class::MAX_SPLINE_EDIT];
59    int t=g1_editor_instance.get_current_splines(s,g1_controller_edit_class::MAX_SPLINE_EDIT);
60   
61    int nf=t_sec*G1_MOVIE_HZ+t_msec*G1_MOVIE_HZ/60;
62
63    for (int i=0; i<t; i++)
64    {
65      i4_spline_class::point *sp=s[i]->begin(), *last=0;
66      for (;sp;sp=sp->next)
67      {
68        if (sp->selected)
69          if (sp->frame<nf || (!last || last->frame<nf))
70          {
71            int advance=nf-sp->frame;
72
73            for (i4_spline_class::point *q=sp; q; q=q->next)
74              q->frame+=advance;
75          }           
76        last=sp;
77      }
78    }     
79  }
80
81  void receive_event(i4_event *ev)
82  {
83    CAST_PTR(tev, i4_text_change_notify_event, ev);
84
85    if (tev->type()==i4_event::OBJECT_MESSAGE)
86    {
87      if (tev->object==si)
88      {
89        i4_const_str::iterator i=tev->new_text->begin();
90        t_sec=i.read_number();
91        change_time();
92      }
93
94      if (tev->object==mi)
95      {
96        i4_const_str::iterator i=tev->new_text->begin();
97        t_msec=i.read_number();
98        change_time();
99      }
100    }
101    i4_color_window_class::receive_event(ev);
102  }
103};
104
105i4_parent_window_class *g1_create_time_edit_window(i4_graphical_style_class *style,
106                                                   w32 cur_frame)
107{
108  return new g1_time_edit_window(style, cur_frame);
109}
Note: See TracBrowser for help on using the repository browser.