Viewer kind of works.
authorCarl Hetherington <cth@carlh.net>
Wed, 25 Jul 2012 04:19:06 +0000 (05:19 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 25 Jul 2012 04:19:06 +0000 (05:19 +0100)
src/tools/dvdomatic.cc
src/wx/film_viewer.cc
src/wx/film_viewer.h
src/wx2/dvdomatic.cc

index 8fe447da5a42f8b5768bac845b036bdbc0250215..81da111e7353dab083e0e510c860b8c46a95fda8 100644 (file)
@@ -383,8 +383,8 @@ class App : public wxApp
 #endif         
 
                wxBoxSizer* main_sizer = new wxBoxSizer (wxHORIZONTAL);
-               main_sizer->Add (film_editor, 0);
-               main_sizer->Add (film_viewer, 1, wxEXPAND);
+               main_sizer->Add (film_editor, 0, wxALL, 6);
+               main_sizer->Add (film_viewer, 1, wxEXPAND | wxALL, 6);
                frame->SetSizer (main_sizer);
 
                SetTopWindow (frame);
index 06608339754b11f33275969ebff94b7311651a03..c9a72f225adce4535ad8e2a39360292f98572941 100644 (file)
@@ -62,6 +62,11 @@ public:
                        return;
                }
 
+               resize ();
+       }
+
+       void resize ()
+       {
                int vw, vh;
                GetSize (&vw, &vh);
 
@@ -75,13 +80,15 @@ public:
                        /* view is shorter (horizontally) than the ratio; fit width */
                        _bitmap = new wxBitmap (_image->Scale (vw, vw / target));
                }
+
+               Refresh ();
        }
 
        void load (string f)
        {
-               clear ();
+               delete _image;
                _image = new wxImage (wxString (f.c_str(), wxConvUTF8));
-               _bitmap = new wxBitmap (_image->Scale (512, 512));
+               resize ();
        }
 
        void clear ()
@@ -113,30 +120,16 @@ FilmViewer::FilmViewer (Film* f, wxWindow* p)
        SetSizer (_sizer);
        
        _thumb_panel = new ThumbPanel (this, f);
-       _thumb_panel->Show (true);
        _sizer->Add (_thumb_panel, 1, wxEXPAND);
 
-#if 0  
-       _scroller.add (_image);
-       
-       Gtk::HBox* controls = manage (new Gtk::HBox);
-       controls->set_spacing (6);
-       controls->pack_start (_position_slider);
-       
-       _vbox.pack_start (_scroller, true, true);
-       _vbox.pack_start (*controls, false, false);
-       _vbox.set_border_width (12);
-
-       _position_slider.set_digits (0);
-       _position_slider.signal_format_value().connect (sigc::mem_fun (*this, &FilmViewer::format_position_slider_value));
-       _position_slider.signal_value_changed().connect (sigc::mem_fun (*this, &FilmViewer::position_slider_changed));
+       int const max = f ? f->num_thumbs() : 0;
+       _slider = new wxSlider (this, wxID_ANY, 0, 0, max);
+       _sizer->Add (_slider, 0, wxEXPAND | wxLEFT | wxRIGHT);
+       load_thumbnail (0);
 
-       _scroller.signal_size_allocate().connect (sigc::mem_fun (*this, &FilmViewer::scroller_size_allocate));
-#endif 
+       _slider->Connect (wxID_ANY, wxEVT_COMMAND_SLIDER_UPDATED, wxCommandEventHandler (FilmViewer::slider_changed), 0, this);
 
        set_film (_film);
-
-       load_thumbnail (42);//XXX
 }
 
 void
@@ -152,24 +145,16 @@ FilmViewer::load_thumbnail (int n)
        int const bottom = _film->bottom_crop ();
 
        _thumb_panel->load (_film->thumb_file(n));
-
-//     _pixbuf = Gdk::Pixbuf::create_from_file (_film->thumb_file (n));
-
-//     int const cw = _film->size().width - left - right;
-//     int const ch = _film->size().height - top - bottom;
-//     _cropped_pixbuf = Gdk::Pixbuf::create_subpixbuf (_pixbuf, left, top, cw, ch);
-//     update_scaled_pixbuf ();
-//     _image.set (_scaled_pixbuf);
 }
 
 void
 FilmViewer::reload_current_thumbnail ()
 {
-       load_thumbnail (42);//_position_slider.get_value ());
+       load_thumbnail (_slider->GetValue ());
 }
 
 void
-FilmViewer::position_slider_changed ()
+FilmViewer::slider_changed (wxCommandEvent &)
 {
        reload_current_thumbnail ();
 }
index 416dc7260aa568c7d53eb536fe6a2a6c75362ded..f1213e023f8252069c75358ac886768394adca81 100644 (file)
@@ -38,7 +38,7 @@ public:
        void setup_visibility ();
 
 private:
-       void position_slider_changed ();
+       void slider_changed (wxCommandEvent &);
        void update_thumbs ();
        std::string format_position_slider_value (double) const;
        void load_thumbnail (int);
@@ -51,6 +51,7 @@ private:
        Film* _film;
        wxBoxSizer* _sizer;
        ThumbPanel* _thumb_panel;
+       wxSlider* _slider;
 //     Gtk::VBox _vbox;
 //     Gtk::ScrolledWindow _scroller;
 //     Gtk::Image _image;
index 3e1114f0353220a3d3199b83836c59086248d416..44e51de096b421e75f5ca51b56eb26ea3289ebf7 100644 (file)
@@ -61,8 +61,8 @@ class App : public wxApp
                viewer->load_thumbnail (22);
 
                wxBoxSizer* main_sizer = new wxBoxSizer (wxHORIZONTAL);
-               main_sizer->Add (editor, 0);
-               main_sizer->Add (viewer->get_widget (), 1, wxEXPAND);
+               main_sizer->Add (editor, 0, wxALL, 6);
+               main_sizer->Add (viewer->get_widget (), 1, wxEXPAND | wxALL, 6);
                frame->SetSizer (main_sizer);
 
 //             frame->Add (viewer->get_widget ());