Tinkering.
authorCarl Hetherington <cth@carlh.net>
Tue, 24 Jul 2012 22:05:11 +0000 (23:05 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 24 Jul 2012 22:05:11 +0000 (23:05 +0100)
src/wscript
src/wx/dvdomatic.cc [new file with mode: 0644]
src/wx/film_editor.cc [new file with mode: 0644]
src/wx/film_editor.h [new file with mode: 0644]
src/wx/film_viewer.cc [new file with mode: 0644]
src/wx/film_viewer.h [new file with mode: 0644]
src/wx/wscript [new file with mode: 0644]

index 2ddd90f5c2cc89c511aaa67503af390f5d8b4d18..88b11de7a1081b5f4ae6b7e7ccd525603ec8873d 100644 (file)
@@ -2,9 +2,11 @@ def configure(conf):
     conf.recurse('lib')
     if not conf.env.DISABLE_GUI:
         conf.recurse('gtk')
+        conf.recurse('wx')
 
 def build(bld):
     bld.recurse('lib')
     bld.recurse('tools')
     if not bld.env.DISABLE_GUI:
         bld.recurse('gtk')
+        bld.recurse('wx')
diff --git a/src/wx/dvdomatic.cc b/src/wx/dvdomatic.cc
new file mode 100644 (file)
index 0000000..3e1114f
--- /dev/null
@@ -0,0 +1,76 @@
+#include <wx/wx.h>
+#include "lib/util.h"
+#include "lib/film.h"
+#include "film_viewer.h"
+#include "film_editor.h"
+
+enum {
+       ID_Quit = 1,
+};
+
+class Frame : public wxFrame
+{
+public:
+       Frame (wxString const & title, wxPoint const & pos, wxSize const & size)
+               : wxFrame (NULL, -1, title, pos, size)
+       {
+               wxMenuBar* bar = new wxMenuBar;
+               
+               wxMenu *menu_file = new wxMenu;
+               menu_file->Append (ID_Quit, _("&Quit"));
+
+               bar->Append (menu_file, _("&File"));
+
+               SetMenuBar (bar);
+
+               CreateStatusBar ();
+               SetStatusText (_("Welcome to DVD-o-matic!"));
+       }
+       
+       void OnQuit (wxCommandEvent& event)
+       {
+               Close (true);
+       }
+};
+
+class App : public wxApp
+{
+       bool OnInit ()
+       {
+               if (!wxApp::OnInit ()) {
+                       return false;
+               }
+
+               wxInitAllImageHandlers ();
+               
+               dvdomatic_setup ();
+
+               Film* film = new Film ("/home/carl/DCP/BitHarvest");
+               
+               Frame* frame = new Frame (_("DVD-o-matic"), wxPoint (50, 50), wxSize(450, 350));
+               frame->Show (true);
+               
+               frame->Connect (
+                       ID_Quit, wxEVT_COMMAND_MENU_SELECTED,
+                       (wxObjectEventFunction) &Frame::OnQuit
+                       );
+
+               FilmEditor* editor = new FilmEditor (film, frame);
+               editor->Show (true);
+               FilmViewer* viewer = new FilmViewer (film, frame);
+               viewer->load_thumbnail (22);
+
+               wxBoxSizer* main_sizer = new wxBoxSizer (wxHORIZONTAL);
+               main_sizer->Add (editor, 0);
+               main_sizer->Add (viewer->get_widget (), 1, wxEXPAND);
+               frame->SetSizer (main_sizer);
+
+//             frame->Add (viewer->get_widget ());
+
+               SetTopWindow (frame);
+               return true;
+       }
+};
+
+IMPLEMENT_APP (App)
+
diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc
new file mode 100644 (file)
index 0000000..b993278
--- /dev/null
@@ -0,0 +1,8 @@
+#include "film_editor.h"
+
+FilmEditor::FilmEditor (Film* f, wxFrame* p)
+       : wxPanel (p)
+       , _film (f)
+{
+       new wxButton (this, 0, wxT("FUCK"));
+}
diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h
new file mode 100644 (file)
index 0000000..d1278b8
--- /dev/null
@@ -0,0 +1,12 @@
+#include <wx/wx.h>
+
+class Film;
+
+class FilmEditor : public wxPanel
+{
+public:
+       FilmEditor (Film* f, wxFrame *);
+
+private:
+       Film* _film;
+};
diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc
new file mode 100644 (file)
index 0000000..c2481ef
--- /dev/null
@@ -0,0 +1,73 @@
+#include <iostream>
+#include "lib/film.h"
+#include "film_viewer.h"
+
+using namespace std;
+
+class ThumbPanel : public wxPanel
+{
+public:
+       ThumbPanel (wxFrame* parent)
+               : wxPanel (parent)
+               , _bitmap (0)
+       {
+       }
+
+       void paint_event (wxPaintEvent& ev)
+       {
+               if (!_bitmap) {
+                       return;
+               }
+
+               cout << "RENDER\n";
+               
+               wxPaintDC dc (this);
+               dc.DrawBitmap (*_bitmap, 0, 0, false);
+       }
+
+       void set_bitmap (wxBitmap* bitmap)
+       {
+               _bitmap = bitmap;
+       }
+
+       DECLARE_EVENT_TABLE ();
+
+private:
+       wxBitmap* _bitmap;
+};
+
+BEGIN_EVENT_TABLE (ThumbPanel, wxPanel)
+EVT_PAINT (ThumbPanel::paint_event)
+END_EVENT_TABLE ()
+
+FilmViewer::FilmViewer (Film* f, wxFrame* p)
+       : _film (f)
+       , _image (0)
+       , _scaled_image (0)
+       , _bitmap (0)
+{
+       _thumb_panel = new ThumbPanel (p);
+       _thumb_panel->Show (true);
+       int x, y;
+       _thumb_panel->GetSize (&x, &y);
+       cout << x << " " << y << "\n";
+}
+
+void
+FilmViewer::load_thumbnail (int n)
+{
+       if (_film == 0 && _film->num_thumbs() <= n) {
+               return;
+       }
+
+       _image = new wxImage (wxString (_film->thumb_file(n).c_str (), wxConvUTF8));
+       _scaled_image = new wxImage (_image->Scale (512, 512));
+       _bitmap = new wxBitmap (*_scaled_image);
+       _thumb_panel->set_bitmap (_bitmap);
+}
+
+wxPanel *
+FilmViewer::get_widget ()
+{
+       return _thumb_panel;
+}
diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h
new file mode 100644 (file)
index 0000000..b0a6aab
--- /dev/null
@@ -0,0 +1,21 @@
+#include <wx/wx.h>
+
+class Film;
+class ThumbPanel;
+
+class FilmViewer
+{
+public:
+       FilmViewer (Film *, wxFrame *);
+
+       void load_thumbnail (int);
+       wxPanel* get_widget ();
+
+private:
+       Film* _film;
+
+       wxImage* _image;
+       wxImage* _scaled_image;
+       wxBitmap* _bitmap;
+       ThumbPanel* _thumb_panel;
+};
diff --git a/src/wx/wscript b/src/wx/wscript
new file mode 100644 (file)
index 0000000..f8aa928
--- /dev/null
@@ -0,0 +1,16 @@
+def configure(conf):
+    conf.check_cfg(package = '', path = 'wx-config', args = '--cppflags --cxxflags --libs', uselib_store = 'WXWIDGETS', mandatory = True)
+
+def build(bld):
+    obj = bld(features = 'cxx cxxprogram')
+    obj.name   = 'dvdomatic-wx'
+    obj.includes = [ '..' ]
+    obj.export_includes = ['.']
+    obj.uselib = 'WXWIDGETS'
+    obj.use = 'dvdomatic'
+    obj.source = """
+                 dvdomatic.cc
+                 film_viewer.cc
+                 film_editor.cc
+                """
+    obj.target = 'dvdomatic-wx'