{
source "source/designer";
require "mspstrings";
- require "sdl";
+ require "mspgbase";
build_info
{
incpath "source";
+++ /dev/null
-/* $Id$ */
-
-default_font "dejavu-12.font";
-
-graphic "greybutton"
-{
- texture "gui.png";
- slice 0 54 21 10;
- border { top 2; right 3; bottom 4; left 2; };
- shadow { top 0; right 1; bottom 2; left 0; };
-};
-
-graphic "greybuttondown"
-{
- texture "gui.png";
- slice 24 54 21 10;
- border { top 2; right 3; bottom 4; left 2; };
- shadow { top 0; right 1; bottom 2; left 0; };
-};
-
-graphic "greenbutton"
-{
- texture "gui.png";
- slice 0 42 21 10;
- border { top 2; right 3; bottom 4; left 2; };
- shadow { top 0; right 1; bottom 2; left 0; };
-};
-
-graphic "greenbuttondown"
-{
- texture "gui.png";
- slice 24 42 21 10;
- border { top 2; right 3; bottom 4; left 2; };
- shadow { top 0; right 1; bottom 2; left 0; };
-};
-
-graphic "redbutton"
-{
- texture "gui.png";
- slice 0 30 21 10;
- border { top 2; right 3; bottom 4; left 2; };
- shadow { top 0; right 1; bottom 2; left 0; };
-};
-
-graphic "redbuttondown"
-{
- texture "gui.png";
- slice 24 30 21 10;
- border { top 2; right 3; bottom 4; left 2; };
- shadow { top 0; right 1; bottom 2; left 0; };
-};
-
-graphic "panelbg"
-{
- texture "gui.png";
- slice 0 68 30 20;
- border { top 2; right 2; bottom 2; left 2; };
-};
-
-graphic "entrybg"
-{
- texture "gui.png";
- slice 32 72 20 16;
- border { top 2; right 2; bottom 2; left 2; };
-};
-
-graphic "entrycursor"
-{
- texture "gui.png";
- slice 54 74 2 12;
-};
-
-graphic "dropdownbg"
-{
- texture "gui.png";
- slice 58 72 30 16;
- border { top 4; right 20; bottom 4; left 2; };
-};
-
-graphic "dropdownarrow"
-{
- texture "gui.png";
- slice 90 75 10 8;
-};
-
-graphic "yellowlamp"
-{
- texture "gui.png";
- slice 30 102 12 12;
-};
-
-graphic "yellowlamplit"
-{
- texture "gui.png";
- slice 30 116 12 12;
-};
-
-graphic "greenlamp"
-{
- texture "gui.png";
- slice 44 102 12 12;
-};
-
-graphic "greenlamplit"
-{
- texture "gui.png";
- slice 44 116 12 12;
-};
-
-graphic "redlamp"
-{
- texture "gui.png";
- slice 58 102 12 12;
-};
-
-graphic "redlamplit"
-{
- texture "gui.png";
- slice 58 116 12 12;
-};
-
-graphic "digidisplay"
-{
- texture "gui.png";
- slice 0 108 28 20;
- border { top 5; right 5; bottom 5; left 5; };
-};
-
-graphic "hsliderslot"
-{
- texture "gui.png";
- slice 0 90 60 10;
- border { top 0; right 5; bottom 0; left 5; };
-};
-
-graphic "hsliderknob"
-{
- texture "gui.png";
- slice 0 15 32 13;
- shadow { top 0; right 2; bottom 3; left 0; };
-};
-
-style "button"
-{
- font_color 0 0 0;
-
- part
- {
- graphic NORMAL "greybutton";
- graphic ACTIVE "greybuttondown";
- align 0.5 0.0;
- fill 0.0 0.0;
- };
-
- special "text"
- {
- align 0.5 1.0;
- fill 0.0 0.0;
- };
-};
-
-style "button-green"
-{
- font_color 0 0 0;
-
- part
- {
- graphic NORMAL "greenbutton";
- graphic ACTIVE "greenbuttondown";
- align 0.5 0.0;
- fill 0.0 0.0;
- };
-
- special "text"
- {
- align 0.5 1.0;
- fill 0.0 0.0;
- };
-};
-
-style "button-red"
-{
- font_color 0 0 0;
-
- part
- {
- graphic NORMAL "redbutton";
- graphic ACTIVE "redbuttondown";
- align 0.5 0.0;
- fill 0.0 0.0;
- };
-
- special "text"
- {
- align 0.5 1.0;
- fill 0.0 0.0;
- };
-};
-
-style "panel"
-{
- part
- {
- graphic NORMAL "panelbg";
- };
- special "children";
-};
-
-style "indicator"
-{
- part
- {
- graphic NORMAL "yellowlamp";
- graphic ACTIVE "yellowlamplit";
- align 0.5 0.5;
- fill 0.0 0.0;
- };
-};
-
-style "indicator-green"
-{
- part
- {
- graphic NORMAL "greenlamp";
- graphic ACTIVE "greenlamplit";
- align 0.5 0.5;
- fill 0.0 0.0;
- };
-};
-
-style "indicator-red"
-{
- part
- {
- graphic NORMAL "redlamp";
- graphic ACTIVE "redlamplit";
- align 0.5 0.5;
- fill 0.0 0.0;
- };
-};
-
-style "label"
-{
- font_color 0 0 0;
- special "text";
-};
-
-style "label-digital"
-{
- font "digitalreadout-16.font";
- font_color 0.3 1 0.3;
-
- part
- {
- graphic NORMAL "digidisplay";
- };
-
- special "text"
- {
- fill 0.0 0.0;
- align 0.5 0.5;
- };
-};
-
-style "hslider"
-{
- part
- {
- graphic NORMAL "hsliderslot";
- fill 1.0 0.0;
- };
-
- special "slider"
- {
- graphic NORMAL "hsliderknob";
- fill 0.0 0.0;
- };
-};
-
-style "entry"
-{
- font_color 0 0 0;
-
- part
- {
- graphic NORMAL "entrybg";
- };
-
- special "text"
- {
- align 0.0 0.5;
- fill 0.0 0.0;
- margin { left 3; right 3; };
- };
-
- special "cursor"
- {
- graphic FOCUS "entrycursor";
- align 0.0 0.5;
- fill 0.0 0.0;
- margin { left 3; right 3; };
- };
-};
-
-style "root"
-{
- special "children";
-};
-
-style "dropdown"
-{
- font_color 0.0 0.0 0.0;
-
- part
- {
- graphic NORMAL "dropdownbg";
- };
-
- part
- {
- graphic NORMAL "dropdownarrow";
- align 1.0 0.5;
- fill 0.0 0.0;
- margin { right 2; };
- };
-
- special "text"
- {
- align 0.0 0.5;
- fill 0.0 0.0;
- margin { left 2; };
- };
-
- special "list";
-};
-
-style "list"
-{
- font_color 0.0 0.0 0.0;
-
- part
- {
- graphic NORMAL "entrybg";
- };
-
- special "items"
- {
- margin { top 2; right 2; bottom 2; left 2; };
- };
-};
-
-style "vslider";
--- /dev/null
+/* $Id$ */
+
+default_font "dejavu-12.font";
+
+graphic "greybutton"
+{
+ texture "gui.png";
+ slice 0 54 21 10;
+ border { top 2; right 3; bottom 4; left 2; };
+ shadow { top 0; right 1; bottom 2; left 0; };
+};
+
+graphic "greybuttondown"
+{
+ texture "gui.png";
+ slice 24 54 21 10;
+ border { top 2; right 3; bottom 4; left 2; };
+ shadow { top 0; right 1; bottom 2; left 0; };
+};
+
+graphic "greenbutton"
+{
+ texture "gui.png";
+ slice 0 42 21 10;
+ border { top 2; right 3; bottom 4; left 2; };
+ shadow { top 0; right 1; bottom 2; left 0; };
+};
+
+graphic "greenbuttondown"
+{
+ texture "gui.png";
+ slice 24 42 21 10;
+ border { top 2; right 3; bottom 4; left 2; };
+ shadow { top 0; right 1; bottom 2; left 0; };
+};
+
+graphic "redbutton"
+{
+ texture "gui.png";
+ slice 0 30 21 10;
+ border { top 2; right 3; bottom 4; left 2; };
+ shadow { top 0; right 1; bottom 2; left 0; };
+};
+
+graphic "redbuttondown"
+{
+ texture "gui.png";
+ slice 24 30 21 10;
+ border { top 2; right 3; bottom 4; left 2; };
+ shadow { top 0; right 1; bottom 2; left 0; };
+};
+
+graphic "panelbg"
+{
+ texture "gui.png";
+ slice 0 68 30 20;
+ border { top 2; right 2; bottom 2; left 2; };
+};
+
+graphic "entrybg"
+{
+ texture "gui.png";
+ slice 32 72 20 16;
+ border { top 2; right 2; bottom 2; left 2; };
+};
+
+graphic "entrycursor"
+{
+ texture "gui.png";
+ slice 54 74 2 12;
+};
+
+graphic "dropdownbg"
+{
+ texture "gui.png";
+ slice 58 72 30 16;
+ border { top 4; right 20; bottom 4; left 2; };
+};
+
+graphic "dropdownarrow"
+{
+ texture "gui.png";
+ slice 90 75 10 8;
+};
+
+graphic "yellowlamp"
+{
+ texture "gui.png";
+ slice 30 102 12 12;
+};
+
+graphic "yellowlamplit"
+{
+ texture "gui.png";
+ slice 30 116 12 12;
+};
+
+graphic "greenlamp"
+{
+ texture "gui.png";
+ slice 44 102 12 12;
+};
+
+graphic "greenlamplit"
+{
+ texture "gui.png";
+ slice 44 116 12 12;
+};
+
+graphic "redlamp"
+{
+ texture "gui.png";
+ slice 58 102 12 12;
+};
+
+graphic "redlamplit"
+{
+ texture "gui.png";
+ slice 58 116 12 12;
+};
+
+graphic "digidisplay"
+{
+ texture "gui.png";
+ slice 0 108 28 20;
+ border { top 5; right 5; bottom 5; left 5; };
+};
+
+graphic "hsliderslot"
+{
+ texture "gui.png";
+ slice 0 90 60 10;
+ border { top 0; right 5; bottom 0; left 5; };
+};
+
+graphic "hsliderknob"
+{
+ texture "gui.png";
+ slice 0 15 32 13;
+ shadow { top 0; right 2; bottom 3; left 0; };
+};
+
+style "button"
+{
+ font_color 0 0 0;
+
+ part
+ {
+ graphic NORMAL "greybutton";
+ graphic ACTIVE "greybuttondown";
+ align 0.5 0.0;
+ fill 0.0 0.0;
+ };
+
+ special "text"
+ {
+ align 0.5 1.0;
+ fill 0.0 0.0;
+ };
+};
+
+style "button-green"
+{
+ font_color 0 0 0;
+
+ part
+ {
+ graphic NORMAL "greenbutton";
+ graphic ACTIVE "greenbuttondown";
+ align 0.5 0.0;
+ fill 0.0 0.0;
+ };
+
+ special "text"
+ {
+ align 0.5 1.0;
+ fill 0.0 0.0;
+ };
+};
+
+style "button-red"
+{
+ font_color 0 0 0;
+
+ part
+ {
+ graphic NORMAL "redbutton";
+ graphic ACTIVE "redbuttondown";
+ align 0.5 0.0;
+ fill 0.0 0.0;
+ };
+
+ special "text"
+ {
+ align 0.5 1.0;
+ fill 0.0 0.0;
+ };
+};
+
+style "panel"
+{
+ part
+ {
+ graphic NORMAL "panelbg";
+ };
+ special "children";
+};
+
+style "indicator"
+{
+ part
+ {
+ graphic NORMAL "yellowlamp";
+ graphic ACTIVE "yellowlamplit";
+ align 0.5 0.5;
+ fill 0.0 0.0;
+ };
+};
+
+style "indicator-green"
+{
+ part
+ {
+ graphic NORMAL "greenlamp";
+ graphic ACTIVE "greenlamplit";
+ align 0.5 0.5;
+ fill 0.0 0.0;
+ };
+};
+
+style "indicator-red"
+{
+ part
+ {
+ graphic NORMAL "redlamp";
+ graphic ACTIVE "redlamplit";
+ align 0.5 0.5;
+ fill 0.0 0.0;
+ };
+};
+
+style "label"
+{
+ font_color 0 0 0;
+ special "text";
+};
+
+style "label-digital"
+{
+ font "digitalreadout-16.font";
+ font_color 0.3 1 0.3;
+
+ part
+ {
+ graphic NORMAL "digidisplay";
+ };
+
+ special "text"
+ {
+ fill 0.0 0.0;
+ align 0.5 0.5;
+ };
+};
+
+style "hslider"
+{
+ part
+ {
+ graphic NORMAL "hsliderslot";
+ fill 1.0 0.0;
+ };
+
+ special "slider"
+ {
+ graphic NORMAL "hsliderknob";
+ fill 0.0 0.0;
+ };
+};
+
+style "entry"
+{
+ font_color 0 0 0;
+
+ part
+ {
+ graphic NORMAL "entrybg";
+ };
+
+ special "text"
+ {
+ align 0.0 0.5;
+ fill 0.0 0.0;
+ margin { left 3; right 3; };
+ };
+
+ special "cursor"
+ {
+ graphic FOCUS "entrycursor";
+ align 0.0 0.5;
+ fill 0.0 0.0;
+ margin { left 3; right 3; };
+ };
+};
+
+style "root"
+{
+ special "children";
+};
+
+style "dropdown"
+{
+ font_color 0.0 0.0 0.0;
+
+ part
+ {
+ graphic NORMAL "dropdownbg";
+ };
+
+ part
+ {
+ graphic NORMAL "dropdownarrow";
+ align 1.0 0.5;
+ fill 0.0 0.0;
+ margin { right 2; };
+ };
+
+ special "text"
+ {
+ align 0.0 0.5;
+ fill 0.0 0.0;
+ margin { left 2; };
+ };
+
+ special "list";
+};
+
+style "list"
+{
+ font_color 0.0 0.0 0.0;
+
+ part
+ {
+ graphic NORMAL "entrybg";
+ };
+
+ special "items"
+ {
+ margin { top 2; right 2; bottom 2; left 2; };
+ };
+};
+
+style "vslider";
void Track3D::build_object()
{
varray.clear();
- RefPtr<GL::VertexArrayBuilder> builder=varray.modify();
+ GL::VertexArrayBuilder builder(varray);
base_seq.clear();
rail_seq.clear();
const vector<TrackPart> &parts=track.get_type().get_parts();
unsigned index=0;
for(vector<TrackPart>::const_iterator i=parts.begin(); i!=parts.end(); ++i)
- build_part(*i, *builder, index);
+ build_part(*i, builder, index);
}
void Track3D::build_part(const TrackPart &part, GL::VertexArrayBuilder &va_builder, unsigned &base_index)
#include <cmath>
#include <iostream>
#include <GL/gl.h>
-#include <SDL.h>
#include <msp/gl/rendermode.h>
#include <msp/gl/select.h>
#include <msp/gl/texture2d.h>
+#include <msp/input/keys.h>
#include <msp/strings/codec.h>
#include <msp/strings/lexicalcast.h>
#include <msp/strings/utf8.h>
int Designer::main()
{
- setenv("__GL_SYNC_TO_VBLANK", "1", 0);
- SDL_Init(SDL_INIT_VIDEO);
- SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
- SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);
- SDL_SetVideoMode(screen_w, screen_h, 32, SDL_OPENGL);
- SDL_EnableUNICODE(1);
+ dpy=new Graphics::Display;
+ wnd=new Graphics::Window(*dpy, screen_w, screen_h);
+ glc=new Graphics::GLContext(*wnd);
+
+ wnd->signal_close.connect(sigc::bind(sigc::mem_fun(this, &Designer::exit), 0));
+ wnd->signal_key_press.connect(sigc::mem_fun(this, &Designer::key_press));
+ wnd->signal_key_release.connect(sigc::mem_fun(this, &Designer::key_release));
+ wnd->signal_button_press.connect(sigc::mem_fun(this, &Designer::button_press));
+ wnd->signal_pointer_motion.connect(sigc::mem_fun(this, &Designer::pointer_motion));
+
+ wnd->show();
glEnableClientState(GL_VERTEX_ARRAY);
glEnable(GL_DEPTH_TEST);
delete font_tex;
delete input;
- SDL_Quit();
+ delete glc;
+ delete wnd;
+ delete dpy;
return exit_code;
}
void Designer::tick()
{
- SDL_Event event;
- while(SDL_PollEvent(&event))
- {
- float gx, gy;
- switch(event.type)
- {
- case SDL_MOUSEBUTTONDOWN:
- map_pointer_coords(event.button.x, event.button.y, gx, gy);
- button_press(event.button.x, screen_h-1-event.button.y, gx, gy, event.button.button);
- break;
- case SDL_MOUSEMOTION:
- map_pointer_coords(event.motion.x, event.motion.y, gx, gy);
- pointer_motion(event.motion.x, screen_h-1-event.motion.y, gx, gy);
- break;
- case SDL_KEYDOWN:
- key_press(event.key.keysym.sym, event.key.keysym.mod, event.key.keysym.unicode);
- break;
- case SDL_KEYUP:
- key_release(event.key.keysym.sym, event.key.keysym.mod);
- break;
- case SDL_QUIT:
- exit(0);
- break;
- }
- }
-
- const Time::TimeStamp t=Time::now();
- float dt=(t-last_tick)/Time::sec;
+ const Msp::Time::TimeStamp t=Msp::Time::now();
+ float dt=(t-last_tick)/Msp::Time::sec;
last_tick=t;
+ dpy->tick();
+
if(move_y)
{
cam_pos.x+=cos(cam_yaw)*dt*move_y;
else
tooltip="";
- tooltip_timeout=Time::TimeStamp();
+ tooltip_timeout=Msp::Time::TimeStamp();
}
render();
- SDL_GL_SwapBuffers();
+ glc->swap_buffers();
}
/*** private ***/
-void Designer::key_press(unsigned key, unsigned mod, wchar_t ch)
+void Designer::key_press(unsigned code, unsigned mod, wchar_t ch)
{
+ unsigned key=Msp::Input::key_from_sys(code);
+
if(mode==INPUT)
{
input->key_press(key, mod, ch);
return;
}
- if(key==SDLK_RSHIFT || key==SDLK_LSHIFT)
+ if(key==Msp::Input::KEY_SHIFT_L || key==Msp::Input::KEY_SHIFT_R)
shift=true;
- if(key==SDLK_n)
+ if(key==Msp::Input::KEY_N)
mode=CATALOGUE;
- else if(key==SDLK_g)
+ else if(key==Msp::Input::KEY_G)
{
manipulator->start_move();
mode=MANIPULATE;
}
- else if(key==SDLK_r)
+ else if(key==Msp::Input::KEY_R)
{
manipulator->start_rotate();
mode=MANIPULATE;
}
- else if(key==SDLK_d)
+ else if(key==Msp::Input::KEY_D)
{
manipulator->duplicate();
manipulator->start_move();
mode=MANIPULATE;
}
- else if(key==SDLK_w)
+ else if(key==Msp::Input::KEY_W)
{
- input=new Input(*this, "Filename");
+ input=new ::Input(*this, "Filename");
input->signal_cancel.connect(sigc::mem_fun(this, &Designer::input_dismiss));
input->signal_accept.connect(sigc::mem_fun(this, &Designer::save_accept));
mode=INPUT;
}
- else if(key==SDLK_PLUS)
+ else if(key==Msp::Input::KEY_PLUS)
selection->select_more();
- else if(key==SDLK_l && (mod&KMOD_SHIFT))
+ else if(key==Msp::Input::KEY_L && (mod&1))
{
const set<Track *> &tracks=layout->get_tracks();
float len=0;
len+=(*i)->get_type().get_total_length();
cout<<"Total length: "<<len<<"m\n";
}
- else if(key==SDLK_l)
+ else if(key==Msp::Input::KEY_L)
selection->select_linked();
- else if(key==SDLK_m)
+ else if(key==Msp::Input::KEY_M)
{
measure->start();
mode=MEASURE;
}
- else if(key==SDLK_z)
+ else if(key==Msp::Input::KEY_Z)
{
manipulator->start_elevate();
mode=MANIPULATE;
}
- else if(key==SDLK_ESCAPE)
+ else if(key==Msp::Input::KEY_ESC)
{
if(mode==MANIPULATE)
manipulator->cancel();
else
selection->clear();
}
- else if(key==SDLK_x)
+ else if(key==Msp::Input::KEY_X)
{
set<Track *> tracks=selection->get_tracks();
selection->clear();
delete *i;
}
}
- else if(key==SDLK_f && (mod&KMOD_SHIFT))
+ else if(key==Msp::Input::KEY_F && (mod&1))
{
const set<Track *> &tracks=selection->get_tracks();
const set<Track *> <racks=layout->get_tracks();
t3d.set_color(GL::Color(1, 1, 1));
}
}
- else if(key==SDLK_f)
+ else if(key==Msp::Input::KEY_F)
manipulator->flatten();
- else if(key==SDLK_e && (mod&KMOD_SHIFT))
+ else if(key==Msp::Input::KEY_E && (mod&1))
manipulator->even_slope(true);
- else if(key==SDLK_e)
+ else if(key==Msp::Input::KEY_E)
manipulator->even_slope();
- else if(key==SDLK_t)
+ else if(key==Msp::Input::KEY_T)
{
Track *track=selection->get_track();
if(selection->size()==1 && track->get_type().get_n_routes()>1)
{
ostringstream ss;
ss<<track->get_turnout_id();
- input=new Input(*this, "Turnout ID", ss.str());
+ input=new ::Input(*this, "Turnout ID", ss.str());
input->signal_cancel.connect(sigc::mem_fun(this, &Designer::input_dismiss));
input->signal_accept.connect(sigc::mem_fun(this, &Designer::turnout_id_accept));
mode=INPUT;
}
}
- else if(key==SDLK_s)
+ else if(key==Msp::Input::KEY_S)
{
Track *track=selection->get_track();
if(selection->size()==1 && track->get_type().get_n_routes()==1)
{
ostringstream ss;
ss<<track->get_sensor_id();
- input=new Input(*this, "Sensor ID", ss.str());
+ input=new ::Input(*this, "Sensor ID", ss.str());
input->signal_cancel.connect(sigc::mem_fun(this, &Designer::input_dismiss));
input->signal_accept.connect(sigc::mem_fun(this, &Designer::sensor_id_accept));
mode=INPUT;
}
}
- else if(key==SDLK_RIGHT)
+ else if(key==Msp::Input::KEY_RIGHT)
rotate=-1;
- else if(key==SDLK_LEFT)
+ else if(key==Msp::Input::KEY_LEFT)
rotate=1;
- else if(key==SDLK_UP)
+ else if(key==Msp::Input::KEY_UP)
move_y=1;
- else if(key==SDLK_DOWN)
+ else if(key==Msp::Input::KEY_DOWN)
move_y=-1;
- else if(key==SDLK_INSERT)
+ else if(key==Msp::Input::KEY_INSERT)
zoom=-1;
- else if(key==SDLK_PAGEUP)
+ else if(key==Msp::Input::KEY_PGUP)
zoom=1;
- else if(key==SDLK_HOME)
+ else if(key==Msp::Input::KEY_HOME)
pitch=1;
- else if(key==SDLK_END)
+ else if(key==Msp::Input::KEY_END)
pitch=-1;
- else if(key==SDLK_DELETE)
+ else if(key==Msp::Input::KEY_DELETE)
move_x=-1;
- else if(key==SDLK_PAGEDOWN)
+ else if(key==Msp::Input::KEY_PGDN)
move_x=1;
}
-void Designer::key_release(unsigned key, unsigned)
+void Designer::key_release(unsigned code, unsigned)
{
+ unsigned key=Msp::Input::key_from_sys(code);
+
if(mode==INPUT)
return;
- if(key==SDLK_RSHIFT || key==SDLK_LSHIFT)
+ if(key==Msp::Input::KEY_SHIFT_L || key==Msp::Input::KEY_SHIFT_R)
shift=false;
- else if(key==SDLK_RIGHT || key==SDLK_LEFT)
+ else if(key==Msp::Input::KEY_RIGHT || key==Msp::Input::KEY_LEFT)
rotate=0;
- else if(key==SDLK_UP || key==SDLK_DOWN)
+ else if(key==Msp::Input::KEY_UP || key==Msp::Input::KEY_DOWN)
move_y=0;
- else if(key==SDLK_INSERT || key==SDLK_PAGEUP)
+ else if(key==Msp::Input::KEY_INSERT || key==Msp::Input::KEY_PGUP)
zoom=0;
- else if(key==SDLK_HOME || key==SDLK_END)
+ else if(key==Msp::Input::KEY_HOME || key==Msp::Input::KEY_END)
pitch=0;
- else if(key==SDLK_DELETE || key==SDLK_PAGEDOWN)
+ else if(key==Msp::Input::KEY_DELETE || key==Msp::Input::KEY_PGDN)
move_x=0;
}
-void Designer::button_press(int x, int y, float gx, float gy, unsigned btn)
+void Designer::button_press(int x, int y, unsigned btn, unsigned)
{
+ y=screen_h-y-1;
+
+ float gx, gy;
+ map_pointer_coords(x, y, gx, gy);
+
if(mode==CATALOGUE)
{
if(btn==1)
measure->button_press(x, y, gx, gy, btn);
}
-void Designer::pointer_motion(int x, int y, float gx, float gy)
+void Designer::pointer_motion(int x, int y)
{
+ y=screen_h-y-1;
+
+ float gx, gy;
+ map_pointer_coords(x, y, gx, gy);
+
if(mode==SELECT || mode==CATALOGUE)
{
pointer_x=x;
pointer_y=y;
- tooltip_timeout=Time::now()+100*Time::msec;
+ tooltip_timeout=Msp::Time::now()+100*Msp::Time::msec;
}
if(mode!=INPUT)
#include <string>
#include <msp/core/application.h>
+#include <msp/gbase/display.h>
+#include <msp/gbase/window.h>
+#include <msp/gbase/glcontext.h>
#include <msp/gl/font.h>
#include <msp/time/timestamp.h>
#include "libmarklin/catalogue.h"
INPUT
};
+ Msp::Graphics::Display *dpy;
+ Msp::Graphics::Window *wnd;
+ Msp::Graphics::GLContext *glc;
unsigned screen_w;
unsigned screen_h;
Msp::GL::Font *font;
void tick();
void key_press(unsigned, unsigned, wchar_t);
void key_release(unsigned, unsigned);
- void button_press(int, int, float, float, unsigned);
- void pointer_motion(int, int, float, float);
+ void button_press(int, int, unsigned, unsigned);
+ void pointer_motion(int, int);
void project_3d();
void apply_camera();
void render();
Distributed under the GPL
*/
-#include <SDL_keysym.h>
#include <GL/gl.h>
#include <msp/gl/texture.h>
+#include <msp/input/keys.h>
#include "designer.h"
#include "input.h"
using namespace std;
using namespace Msp;
-Input::Input(Designer &d, const string &t, const string &e):
+::Input::Input(Designer &d, const string &t, const string &e):
designer(d),
title(t),
text(e),
pos(text.size())
{ }
-void Input::key_press(unsigned key, unsigned, wchar_t ch)
+void ::Input::key_press(unsigned key, unsigned, wchar_t ch)
{
- if(key==SDLK_RETURN)
+ if(key==Msp::Input::KEY_ENTER)
signal_accept.emit();
- else if(key==SDLK_ESCAPE)
+ else if(key==Msp::Input::KEY_ESC)
signal_cancel.emit();
- else if(key==SDLK_BACKSPACE)
+ else if(key==Msp::Input::KEY_BACKSPACE)
{
if(pos>0)
{
--pos;
}
}
- else if(key==SDLK_DELETE)
+ else if(key==Msp::Input::KEY_DELETE)
{
if(pos<text.size())
text.erase(pos, 1);
}
- else if(key==SDLK_LEFT)
+ else if(key==Msp::Input::KEY_LEFT)
{
if(pos>0)
--pos;
}
- else if(key==SDLK_RIGHT)
+ else if(key==Msp::Input::KEY_RIGHT)
{
if(pos<text.size())
++pos;
}
}
-void Input::render()
+void ::Input::render()
{
glLoadIdentity();
glTranslatef(300, 450, 0);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- DataFile::load(ui_res, "engineer.res");
+ DataFile::load(ui_res, "marklin.res");
root=new GLtk::Root(ui_res, *wnd);
root->set_visible(true);
--- /dev/null
+#include "constants.h"
+
+using namespace std;
+
+namespace Marklin {
+
+ostream &operator<<(ostream &out, const Error &err)
+{
+ switch(err)
+ {
+ case ERR_NO_ERROR: out<<"ERR_NO_ERROR"; break;
+ case ERR_SYS_ERROR: out<<"ERR_SYS_ERROR"; break;
+ case ERR_BAD_PARAM: out<<"ERR_BAD_PARAM"; break;
+ case ERR_POWER_OFF: out<<"ERR_POWER_OFF"; break;
+ case ERR_NO_LOK_SPACE: out<<"ERR_NO_LOK_SPACE"; break;
+ case ERR_NO_TURNOUT_SPACE: out<<"ERR_NO_TURNOUT_SPACE"; break;
+ case ERR_NO_DATA: out<<"ERR_NO_DATA"; break;
+ case ERR_NO_SLOT: out<<"ERR_NO_SLOT"; break;
+ case ERR_BAD_LOK_ADDR: out<<"ERR_BAD_LOK_ADDR"; break;
+ case ERR_LOK_BUSY: out<<"ERR_LOK_BUSY"; break;
+ case ERR_BAD_TURNOUT_ADDR: out<<"ERR_BAD_TURNOUT_ADDR"; break;
+ case ERR_BAD_SO_VALUE: out<<"ERR_BAD_SO_VALUE"; break;
+ case ERR_NO_I2C_SPACE: out<<"ERR_NO_I2C_SPACE"; break;
+ case ERR_LOW_TURNOUT_SPACE: out<<"ERR_LOW_TURNOUT_SPACE"; break;
+ case ERR_LOK_HALTED: out<<"ERR_LOK_HALTED"; break;
+ case ERR_LOK_POWER_OFF: out<<"ERR_LOK_POWER_OFF"; break;
+ case ERR_UNKNOWN_ERROR: out<<"ERR_UNKNOWN_ERROR"; break;
+ default: out<<"Err("<<static_cast<int>(err)<<')'; break;
+ }
+
+ return out;
+}
+
+ostream &operator<<(ostream &out, const Cmd &cmd)
+{
+ switch(cmd)
+ {
+ case CMD_LOK: out<<"CMD_LOK"; break;
+ case CMD_LOK_STATUS: out<<"CMD_LOK_STATUS"; break;
+ case CMD_LOK_CONFIG: out<<"CMD_LOK_CONFIG"; break;
+ case CMD_FUNC: out<<"CMD_FUNC"; break;
+ case CMD_FUNC_STATUS: out<<"CMD_FUNC_STATUS"; break;
+ case CMD_TURNOUT: out<<"CMD_TURNOUT"; break;
+ case CMD_TURNOUT_FREE: out<<"CMD_TURNOUT_FREE"; break;
+ case CMD_TURNOUT_STATUS: out<<"CMD_TURNOUT_STATUS"; break;
+ case CMD_TURNOUT_GROUP_STATUS: out<<"CMD_TURNOUT_GROUP_STATUS"; break;
+ case CMD_SENSOR_STATUS: out<<"CMD_SENSOR_STATUS"; break;
+ case CMD_SENSOR_REPORT: out<<"CMD_SENSOR_REPORT"; break;
+ case CMD_SENSOR_PARAM_SET: out<<"CMD_SENSOR_PARAM_SET"; break;
+ case CMD_STATUS: out<<"CMD_STATUS"; break;
+ case CMD_POWER_OFF: out<<"CMD_POWER_OFF"; break;
+ case CMD_POWER_ON: out<<"CMD_POWER_ON"; break;
+ case CMD_NOP: out<<"CMD_NOP"; break;
+ case CMD_EVENT: out<<"CMD_EVENT"; break;
+ case CMD_EVENT_LOK: out<<"CMD_EVENT_LOK"; break;
+ case CMD_EVENT_TURNOUT: out<<"CMD_EVENT_TURNOUT"; break;
+ case CMD_EVENT_SENSOR: out<<"CMD_EVENT_SENSOR"; break;
+ default: out<<"Cmd("<<static_cast<int>(cmd)<<')'; break;
+ }
+
+ return out;
+}
+
+} // namespace Marklin