Permalink
Browse files

-Implemented GMasterSource, now looks sleeker

  • Loading branch information...
1 parent 30713d5 commit 9cfa4b20fa84827ac0411bf054fa8ef4a59e74f5 @harryhaaren harryhaaren committed Mar 30, 2012
Showing with 193 additions and 16 deletions.
  1. +133 −0 src/g_mastersource.cpp
  2. +48 −0 src/g_mastersource.hpp
  3. +9 −15 src/g_window.cpp
  4. +2 −1 src/g_window.hpp
  5. +1 −0 wscript
View
@@ -0,0 +1,133 @@
+
+/*
+ This file is part of Luppp.
+ Copyright 2012, Harry van Haaren
+
+ Luppp is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Luppp is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Luppp. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "g_mastersource.hpp"
+
+#include "top.hpp"
+#include "offlineworker.hpp"
+#include "g_widgets.hpp"
+
+using namespace std;
+using namespace Luppp;
+
+GMasterSource::GMasterSource(Top* t)
+{
+ top = t;
+
+ playing = true;
+
+ add_events(Gdk::BUTTON_PRESS_MASK);
+ signal_button_press_event().connect(sigc::mem_fun(*this, &GMasterSource::on_button_press_event) );
+
+ set_size_request(74*3, 20);
+}
+
+bool GMasterSource::redraw()
+{
+ // force our program to redraw the entire widget.
+ Glib::RefPtr<Gdk::Window> win = get_window();
+ if (win)
+ {
+ Gdk::Rectangle r(0, 0, get_allocation().get_width(),
+ get_allocation().get_height());
+ win->invalidate_rect(r, false);
+ }
+ return true;
+}
+
+void GMasterSource::setPlaying(bool p )
+{
+ playing = p;
+ redraw();
+}
+
+/*
+bool GMasterSource::on_button_press_event(GdkEventButton* event)
+{
+
+ std::cout << "Event Type: " << event->type << ". Event Button: " << event->button << "." << std::endl;
+
+ if( event->type == GDK_BUTTON_PRESS ) // && event->button == 3
+ {
+ std::cout << "Event Type: " << event->type << ". Event Button: " << event->button << "." << std::endl;
+
+ if(event->button == 3)
+ {
+ //ifdef DEBUG
+ std::cout << "GMasterSource.cpp: Event RightClick on GMasterSource instance at " << this <<"." << std::endl;
+
+ pMenu.popup(event->button, event->time);
+ }
+ else if (event->button == 1)
+ {
+ // normal click: trigger !currentRecordState
+ //lo_send( lo_address_new( NULL,"14688") , "/luppp/track/record","ii",ID, !recording );
+ }
+
+ return true; //It's been handled.
+ }
+ else
+ {
+ std::cout << event -> type << std::endl;
+ }
+
+ return true;
+}
+*/
+
+bool GMasterSource::on_expose_event(GdkEventExpose* event)
+{
+ // This is where we draw on the window
+ Glib::RefPtr<Gdk::Window> window = get_window();
+
+ if(window) // Only run if Window does exist
+ {
+ Gtk::Allocation allocation = get_allocation();
+ int width = allocation.get_width();
+ int height = allocation.get_height();
+
+ // clip to the area indicated by the expose event so that we only redraw
+ // the portion of the window that needs to be redrawn
+ Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
+ cr->rectangle(event->area.x, event->area.y,
+ event->area.width, event->area.height);
+ cr->clip();
+
+ cr->rectangle(event->area.x, event->area.y,
+ event->area.width, event->area.height);
+ setColour(cr, COLOUR_GREY_3 );
+ cr->fill();
+
+ cr->rectangle(event->area.x, event->area.y,
+ event->area.width, event->area.height);
+ if ( playing )
+ setColour(cr, COLOUR_GREEN_1 );
+ cr->fill();
+
+ cr->select_font_face ("Impact" , Cairo::FONT_SLANT_NORMAL, Cairo::FONT_WEIGHT_BOLD);
+ cr->set_font_size ( 13 );
+ cr->move_to ( 11 , 15 );
+ setColour(cr, COLOUR_ORANGE_1 );
+ if ( playing )
+ setColour(cr, COLOUR_GREY_3 );
+ cr->show_text ( "Master" );
+
+ }
+ return true;
+}
View
@@ -0,0 +1,48 @@
+
+/*
+ This file is part of Luppp.
+ Copyright 2012, Harry van Haaren
+
+ Luppp is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Luppp is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Luppp. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef LUPPP_GMASTERSOURCE
+#define LUPPP_GMASTERSOURCE
+
+class Top;
+
+#include <vector>
+#include <iostream>
+
+#include <gtkmm.h>
+#include <gtkmm/drawingarea.h>
+
+class GMasterSource : public Gtk::DrawingArea
+{
+ public:
+ GMasterSource(Top*);
+
+ bool redraw();
+ void setPlaying(bool);
+
+ protected:
+ Top* top;
+
+ bool playing;
+
+ bool on_expose_event(GdkEventExpose* event);
+ //bool on_button_press_event(GdkEventButton* event);
+};
+
+#endif // SCENE_SELECTOR
View
@@ -49,6 +49,7 @@ Window::Window(Gtk::Main *k, Top* t) :
effectSelector(t, &guiState),
instrumentSelector(t, &guiState),
automove(t),
+ masterSource(t),
waveview(t),
inputWaveview(t)
@@ -127,22 +128,18 @@ Window::Window(Gtk::Main *k, Top* t) :
refBuilder->get_widget("masterOutputBox", masterOutputBox);
refBuilder->get_widget("masterClipSelectorBox", masterClipSelectorBox);
- // master track widgets
+ // master source & clip selector widgets
Gtk::VBox* tmpVbox = new Gtk::VBox();
-
- masterClipEventBox = new Gtk::EventBox();
- Gtk::Label* tmpLabel = new Gtk::Label( "Master" );
- masterClipEventBox->modify_bg(Gtk::STATE_NORMAL, Gdk::Color("green"));
- masterClipEventBox->add( *tmpLabel );
-
masterClipSelector = new ClipSelector(top, &guiState, true);
- tmpVbox->add( *masterClipEventBox );
+ tmpVbox->add( masterSource );
tmpVbox->add( *masterClipSelector);
masterClipSelectorBox->add( *tmpVbox );
+ masterClipSelectorBox->add( masterProgress );
masterClipSelectorBox->show_all();
// master output widget
- masterOutputBox->add( masterProgress );
+ masterOutputBox->pack_end( masterOutput, false, true, 0 );
+ masterOutputBox->show_all();
// AutoMove & Waveform boxs & widgets
refBuilder->get_widget("bottomWidgetBox", bottomWidgetBox);
@@ -164,9 +161,6 @@ Window::Window(Gtk::Main *k, Top* t) :
//masterOutputBox->add( inputWaveview );
//masterOutputBox->add( waveview );
- masterOutputBox->pack_end( masterOutput, false, true, 0 );
- masterOutputBox->show_all();
-
refBuilder->get_widget("eeLabel", eeLabel);
refBuilder->get_widget("menuFileAddTrack", menuFileAddTrack);
@@ -372,10 +366,10 @@ int Window::handleEvent()
guiState.masterClipPlaying = scene;
masterClipSelector->queue_draw();
- if ( scene != -1 )
- masterClipEventBox->modify_bg(Gtk::STATE_NORMAL, Gdk::Color("black"));
+ if ( scene == -1 )
+ masterSource.setPlaying( true );
else
- masterClipEventBox->modify_bg(Gtk::STATE_NORMAL, Gdk::Color("green"));
+ masterSource.setPlaying( false );
//lo_send( lo_address_new(NULL, "7773") , "/harmonyseq/event", "i", scene );
//lo_send( lo_address_new(NULL, "7773") , "/harmonyseq/sync", "" );
View
@@ -35,6 +35,7 @@ class Top;
#include "g_automove.hpp"
#include "g_audiosource.hpp"
#include "g_trackoutput.hpp"
+#include "g_mastersource.hpp"
#include "g_clipselector.hpp"
#include "g_fileselector.hpp"
#include "g_masteroutput.hpp"
@@ -65,7 +66,6 @@ class Window
Gtk::Box* automoveBox;
Gtk::HBox* bottomWidgetBox;
Gtk::Box* masterClipSelectorBox;
- Gtk::EventBox* masterClipEventBox;
Gtk::EventBox* trackEffectEventBox;
Gtk::Viewport* fileChooserViewport;
@@ -108,6 +108,7 @@ class Window
GAutoMove automove;
+ GMasterSource masterSource;
GMasterOutput masterOutput;
GMasterProgress masterProgress;
ClipSelector* masterClipSelector;
View
@@ -92,6 +92,7 @@ def build(ctx):
'src/g_limiter.cpp',
'src/g_compressor.cpp',
'src/g_audiosource.cpp',
+ 'src/g_mastersource.cpp',
'src/g_frequencygraph.cpp',
'src/g_titlebar.cpp',
'src/g_block.cpp',

0 comments on commit 9cfa4b2

Please sign in to comment.