// Setup UI
DataFile::load(ui_res, "marklin.res");
root = new GLtk::Root(ui_res, window);
-
- lbl_tooltip = new GLtk::Label(ui_res);
- lbl_tooltip->set_style("tooltip");
- root->add(*lbl_tooltip);
- lbl_tooltip->set_visible(false);
+ root->signal_tooltip.connect(sigc::mem_fun(this, &Designer::tooltip));
toolbar = new Toolbar(*this);
root->add(*toolbar);
toolbar->set_position(0, window.get_height()-toolbar->get_geometry().h);
toolbar->set_visible(true);
+ GLtk::Panel *statusbar = new GLtk::Panel(ui_res);
+ root->add(*statusbar);
+ statusbar->set_size(window.get_width(), 20);
+ statusbar->set_visible(true);
+
+ lbl_status = new GLtk::Label(ui_res);
+ statusbar->add(*lbl_status);
+ lbl_status->set_geometry(GLtk::Geometry(20, 2, 300, 16));
+
overlay = new Overlay3D(window, camera, ui_res.get_default_font());
const list<Track3D *> &tracks = layout_3d->get_tracks();
last_tick = t;
window.get_display().tick();
+ root->tick();
camera_ctl.tick(dt);
- if(tooltip_timeout && t>tooltip_timeout)
- {
- Track3D *t3d = 0;
-
- if(mode==CATALOGUE)
- t3d = pick_track(pointer_x, pointer_y);
- else
- t3d = pick_track(pointer_x, pointer_y);
-
- if(t3d)
- {
- const Track &track = t3d->get_track();
- const TrackType &ttype = track.get_type();
- string info = format("%d %s", ttype.get_article_number(), ttype.get_description());
- if(mode!=CATALOGUE && abs(track.get_slope())>1e-4)
- info += format(" (slope %.1f%%)", abs(track.get_slope()/ttype.get_total_length()*100));
- if(track.get_turnout_id())
- info += format(" (turnout %d)", track.get_turnout_id());
- else if(track.get_sensor_id())
- info += format(" (sensor %d)", track.get_sensor_id());
-
- set_tooltip(pointer_x, pointer_y, info);
- }
- else
- clear_tooltip();
-
- tooltip_timeout = Msp::Time::TimeStamp();
- }
-
render();
window.swap_buffers();
{
y = window.get_height()-y-1;
- pointer_x = x;
- pointer_y = y;
-
- if(mode==SELECT || mode==CATALOGUE)
- tooltip_timeout = Msp::Time::now()+100*Msp::Time::msec;
-
- clear_tooltip();
-
if(mode!=INPUT)
{
Point ground = map_pointer_coords(x, y);
void Designer::manipulation_status(const string &status)
{
- set_tooltip(pointer_x, pointer_y, status);
+ lbl_status->set_text(status);
}
void Designer::manipulation_done(bool)
{
+ lbl_status->set_text(string());
mode = SELECT;
}
float d = sqrt(pard*pard+perpd*perpd);
float adiff = measure.get_angle_difference()*180/M_PI;
string info = format("Par %.1fmm - Perp %.1fmm - Total %.1fmm - Angle %.1f°", pard, perpd, d, adiff);
- set_tooltip(pointer_x, pointer_y, info);
+ lbl_status->set_text(info);
}
void Designer::measure_done()
{
+ lbl_status->set_text(string());
mode = SELECT;
}
-void Designer::set_tooltip(int x, int y, const std::string &text)
-{
- int fontsize = ui_res.get_default_font().get_default_size();
- int h = fontsize+6;
- int w = static_cast<int>(ui_res.get_default_font().get_string_width(text)*fontsize)+6;
- x = max(min(static_cast<int>(window.get_width())-w, x), 0);
- y = max(min(static_cast<int>(window.get_height())-h, y), 0);
- lbl_tooltip->set_text(text);
- lbl_tooltip->set_geometry(GLtk::Geometry(x, y, w, h));
- lbl_tooltip->set_visible(true);
-}
-
-void Designer::clear_tooltip()
-{
- lbl_tooltip->set_visible(false);
-}
-
void Designer::save_accept()
{
layout->save(input->get_text());
camera.set_position(GL::Vector3(center.x, center.y-cam_dist*0.5, cam_dist*0.866));
camera.set_look_direction(GL::Vector3(0, 0.5, -0.866));
}
+
+string Designer::tooltip(int x, int y)
+{
+ if(Track3D *t3d = pick_track(x, y))
+ {
+ const Track &track = t3d->get_track();
+ const TrackType &ttype = track.get_type();
+ string info = format("%d %s", ttype.get_article_number(), ttype.get_description());
+ if(mode!=CATALOGUE && abs(track.get_slope())>1e-4)
+ info += format(" (slope %.1f%%)", abs(track.get_slope()/ttype.get_total_length()*100));
+ if(track.get_turnout_id())
+ info += format(" (turnout %d)", track.get_turnout_id());
+ else if(track.get_sensor_id())
+ info += format(" (sensor %d)", track.get_sensor_id());
+
+ return info;
+ }
+
+ return string();
+}