using gtkmm/gtkbuilder for UI
This commit is contained in:
parent
6fb3fee75c
commit
d12a5c3afe
13
SConstruct
13
SConstruct
|
@ -16,7 +16,6 @@ if win32:
|
|||
"/Ob2",
|
||||
"/fp:fast",
|
||||
"/MT",
|
||||
"/DBT_NO_PROFILE=1",
|
||||
"/DWIN32",
|
||||
],
|
||||
CPPPATH = [
|
||||
|
@ -26,10 +25,6 @@ if win32:
|
|||
"win32/lib",
|
||||
],
|
||||
LIBS = [
|
||||
'SDL',
|
||||
'opengl32',
|
||||
'glu32',
|
||||
'glut32',
|
||||
'libjack',
|
||||
],
|
||||
)
|
||||
|
@ -38,17 +33,15 @@ else:
|
|||
ENV = os.environ,
|
||||
CXXFLAGS = [
|
||||
"-g",
|
||||
"-DBT_NO_PROFILE=1",
|
||||
],
|
||||
LIBS = [
|
||||
'stdc++',
|
||||
'GL',
|
||||
'GLU',
|
||||
'glut',
|
||||
],
|
||||
)
|
||||
env.ParseConfig("pkg-config sdl --cflags --libs")
|
||||
#env.ParseConfig("pkg-config sdl --cflags --libs")
|
||||
env.ParseConfig("pkg-config jack --cflags --libs")
|
||||
env.ParseConfig("pkg-config gtkmm-2.4 --cflags --libs")
|
||||
env.ParseConfig("pkg-config sigc++-2.0 --cflags --libs")
|
||||
|
||||
env.Program('jacker',
|
||||
['main.cpp',
|
||||
|
|
2
jack.cpp
2
jack.cpp
|
@ -4,7 +4,7 @@
|
|||
#include <assert.h>
|
||||
|
||||
namespace Jack {
|
||||
|
||||
|
||||
//=============================================================================
|
||||
|
||||
static bool handle_status(int status)
|
||||
|
|
2
jack.hpp
2
jack.hpp
|
@ -28,7 +28,7 @@ public:
|
|||
unsigned long flags,
|
||||
unsigned long buffer_size);
|
||||
|
||||
~Port();
|
||||
virtual ~Port();
|
||||
|
||||
protected:
|
||||
virtual void update_buffer(jack_nframes_t nframes) = 0;
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0"?>
|
||||
<interface>
|
||||
<requires lib="gtk+" version="2.16"/>
|
||||
<!-- interface-naming-policy project-wide -->
|
||||
<object class="GtkWindow" id="main">
|
||||
<property name="title" translatable="yes">Jacker</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
35
main.cpp
35
main.cpp
|
@ -1,7 +1,9 @@
|
|||
|
||||
#include "jack.hpp"
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef max
|
||||
#undef max
|
||||
|
@ -29,19 +31,34 @@ public:
|
|||
} // namespace Jacker
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
Gtk::Main kit(argc, argv);
|
||||
|
||||
Jacker::Client client;
|
||||
|
||||
if (!client.init())
|
||||
return 0;
|
||||
printf("init client...\n");
|
||||
if (client.init()) {
|
||||
|
||||
Glib::RefPtr<Gtk::Builder> builder =
|
||||
Gtk::Builder::create_from_file("jacker.glade");
|
||||
|
||||
Gtk::Window* window = 0;
|
||||
builder->get_widget("main", window);
|
||||
|
||||
window->show_all();
|
||||
|
||||
printf("activate client...\n");
|
||||
client.activate();
|
||||
|
||||
kit.run(*window);
|
||||
|
||||
printf("deactivate...\n");
|
||||
client.deactivate();
|
||||
|
||||
printf("shutdown...\n");
|
||||
client.shutdown();
|
||||
}
|
||||
|
||||
client.activate();
|
||||
|
||||
sleep(10);
|
||||
|
||||
client.deactivate();
|
||||
|
||||
client.shutdown();
|
||||
printf("bye.\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
#include <map>
|
||||
|
||||
namespace jacker {
|
||||
namespace Jacker {
|
||||
|
||||
enum {
|
||||
FRAMES_PER_BAR = 7680,
|
||||
|
@ -49,4 +49,4 @@ struct Model {
|
|||
int end_cue;
|
||||
};
|
||||
|
||||
} // namespace jacker
|
||||
} // namespace Jacker
|
|
@ -0,0 +1,90 @@
|
|||
|
||||
#include "sdl.hpp"
|
||||
|
||||
namespace SDL {
|
||||
|
||||
static bool handle_status(int status) {
|
||||
if (status < 0) {
|
||||
fprintf(stderr, "SDL: %s\n", SDL_GetError());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static bool handle_status(T *status) {
|
||||
return handle_status((status == NULL)?-1:0);
|
||||
}
|
||||
|
||||
|
||||
GLApp::GLApp() {
|
||||
exit_main_loop = false;
|
||||
width = 800;
|
||||
height = 600;
|
||||
}
|
||||
|
||||
GLApp::~GLApp() {
|
||||
}
|
||||
|
||||
bool GLApp::init() {
|
||||
|
||||
if (handle_status(SDL_Init(SDL_INIT_VIDEO))) {
|
||||
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
|
||||
|
||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
|
||||
|
||||
//SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
|
||||
//SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);
|
||||
|
||||
Uint32 flags = SDL_OPENGL | SDL_RESIZABLE;// | SDL_FULLSCREEN;
|
||||
|
||||
if (handle_status(SDL_SetVideoMode(width, height, 24, flags))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void GLApp::quit() {
|
||||
exit_main_loop = true;
|
||||
}
|
||||
|
||||
void GLApp::main_loop() {
|
||||
SDL_Event event;
|
||||
|
||||
exit_main_loop = false;
|
||||
while(!exit_main_loop) {
|
||||
while(SDL_PollEvent(&event)) {
|
||||
switch(event.type){
|
||||
case SDL_KEYDOWN:
|
||||
on_key_down((SDL_KeyboardEvent &)event);
|
||||
break;
|
||||
case SDL_MOUSEMOTION:
|
||||
on_mouse_motion((SDL_MouseMotionEvent &)event);
|
||||
break;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
on_mouse_button_down((SDL_MouseButtonEvent &)event);
|
||||
break;
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
on_mouse_button_up((SDL_MouseButtonEvent &)event);
|
||||
break;
|
||||
case SDL_QUIT:
|
||||
quit();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (render())
|
||||
SDL_GL_SwapBuffers();
|
||||
|
||||
SDL_Delay(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace SDL
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
#include <SDL.h>
|
||||
|
||||
namespace SDL {
|
||||
|
||||
class GLApp {
|
||||
public:
|
||||
GLApp();
|
||||
virtual ~GLApp();
|
||||
|
||||
bool init();
|
||||
void quit();
|
||||
|
||||
void main_loop();
|
||||
void exit();
|
||||
|
||||
virtual bool render() { return false; }
|
||||
virtual void on_key_down(SDL_KeyboardEvent &event) {}
|
||||
virtual void on_mouse_motion(SDL_MouseMotionEvent &event) {}
|
||||
virtual void on_mouse_button_down(SDL_MouseButtonEvent &event) {}
|
||||
virtual void on_mouse_button_up(SDL_MouseButtonEvent &event) {}
|
||||
|
||||
protected:
|
||||
bool exit_main_loop;
|
||||
int width;
|
||||
int height;
|
||||
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in New Issue