X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fgtkmm%2Fwidget_timeslider.cpp;h=ed5d63c4f3e970c58174154a493f75c3160101f3;hb=9459638ad6797b8139f1e9f0715c96076dbf0890;hp=e15e2e79925c72c5f29b18d6644a4aa8a1dbbf0d;hpb=59fbbc9b2d99809f56f9812c07fadf395efbba82;p=synfig.git diff --git a/synfig-studio/trunk/src/gtkmm/widget_timeslider.cpp b/synfig-studio/trunk/src/gtkmm/widget_timeslider.cpp index e15e2e7..ed5d63c 100644 --- a/synfig-studio/trunk/src/gtkmm/widget_timeslider.cpp +++ b/synfig-studio/trunk/src/gtkmm/widget_timeslider.cpp @@ -505,12 +505,29 @@ bool Widget_Timeslider::redraw(bool /*doublebuffer*/) iter = next; scale = *iter; - if (iter != ranges.begin()) iter--; - if (iter != ranges.begin()) iter--; - if (iter != ranges.begin()) iter--; // subdivide into this many tick marks (8 or less) - const int subdiv = round_to_int(scale / *iter); + int subdiv = round_to_int(scale * ifps); + + if (subdiv > 8) + { + const int ideal = subdiv; + + // find a number of tick marks that nicely divides the scale + // (5 minutes divided by 6 is 50s, but that's not 'nice' - + // 5 ticks of 1m each is much simpler than 6 ticks of 50s) + for (subdiv = 8; subdiv > 0; subdiv--) + if ((ideal <= ifps*2 && (ideal % (subdiv )) == 0) || + (ideal <= ifps*2*60 && (ideal % (subdiv*ifps )) == 0) || + (ideal <= ifps*2*60*60 && (ideal % (subdiv*ifps*60 )) == 0) || + (true && (ideal % (subdiv*ifps*60*60)) == 0)) + break; + + // if we didn't find anything, use 4 ticks + if (!subdiv) + subdiv = 4; + } + time_per_tickmark = scale / subdiv; //get first valid line and its position in pixel space @@ -532,6 +549,7 @@ bool Widget_Timeslider::redraw(bool /*doublebuffer*/) double t = (time/scale - floor(time/scale))*subdiv; // the difference from the big mark in 0:1 //sdindex = (int)floor(t + 0.5); //get how far through the range it is... sdindex = round_to_int(t); //get how far through the range it is... + if (sdindex == subdiv) sdindex = 0; //synfig::info("Extracted fr %.2lf -> %d", t, sdindex); } @@ -558,7 +576,17 @@ bool Widget_Timeslider::redraw(bool /*doublebuffer*/) //gc->set_rgb_fg_color(Gdk::Color("#000000")); layout->set_text(timecode); - window->draw_layout(gc,xpx+2,heightsmall,layout); + Pango::AttrList attr_list; + // Aproximately a font size of 8 pixels. + // Pango::SCALE = 1024 + // create_attr_size waits a number in 1000th of pixels. + // Should be user customizable in the future. Now it is fixed to 10 + Pango::AttrInt pango_size(Pango::Attribute::create_attr_size(Pango::SCALE*10)); + pango_size.set_start_index(0); + pango_size.set_end_index(64); + attr_list.change(pango_size); + layout->set_attributes(attr_list); + window->draw_layout(gc,xpx+2,0,layout); }else { window->draw_line(gc,xpx,0,xpx,heightsmall); @@ -775,7 +803,7 @@ bool Widget_Timeslider::on_scroll_event(GdkEventScroll* event) //for zooming else { adj_timescale->set_lower(start - (orig_t-t)); - adj_timescale->set_upper(start - (orig_t-t) + (end-start)); + adj_timescale->set_upper(start - (orig_t-t) + (end-start)); } } }