summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-07-24 23:05:11 +0100
committerCarl Hetherington <cth@carlh.net>2012-07-24 23:05:11 +0100
commitd7a07b98f5b740921e9d7555740e05801ebfc1fc (patch)
tree0f873a25a25d0e030cf33a8e22e09944e3eded2d /src
parent6acc7a2579c7842d8031aee29fb5fa1e015747fa (diff)
Tinkering.
Diffstat (limited to 'src')
-rw-r--r--src/wscript2
-rw-r--r--src/wx/dvdomatic.cc76
-rw-r--r--src/wx/film_editor.cc8
-rw-r--r--src/wx/film_editor.h12
-rw-r--r--src/wx/film_viewer.cc73
-rw-r--r--src/wx/film_viewer.h21
-rw-r--r--src/wx/wscript16
7 files changed, 208 insertions, 0 deletions
diff --git a/src/wscript b/src/wscript
index 2ddd90f5c..88b11de7a 100644
--- a/src/wscript
+++ b/src/wscript
@@ -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
index 000000000..3e1114f03
--- /dev/null
+++ b/src/wx/dvdomatic.cc
@@ -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
index 000000000..b99327879
--- /dev/null
+++ b/src/wx/film_editor.cc
@@ -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
index 000000000..d1278b80e
--- /dev/null
+++ b/src/wx/film_editor.h
@@ -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
index 000000000..c2481efb9
--- /dev/null
+++ b/src/wx/film_viewer.cc
@@ -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
index 000000000..b0a6aab04
--- /dev/null
+++ b/src/wx/film_viewer.h
@@ -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
index 000000000..f8aa92896
--- /dev/null
+++ b/src/wx/wscript
@@ -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'