Fix toggle timeline thumbnails command (fix #1518)

This commit is contained in:
David Capello 2017-11-21 14:30:30 -03:00
parent 27f0182bdb
commit c80d914e1a
7 changed files with 47 additions and 43 deletions

View File

@ -234,9 +234,6 @@
<section id="symmetry_mode">
<option id="enabled" type="bool" default="false" />
</section>
<section id="thumbnails">
<option id="visible_options" type="bool" default="false" />
</section>
<section id="perf">
<option id="show_render_time" type="bool" default="false" />
</section>

View File

@ -867,10 +867,8 @@ bottom = &Bottom
frame_header = Frame Header:
first_frame = First Frame:
thumbnails = Thumbnails
force = Force
zoom = Zoom:
overlay = Overlay
size = Size:
thumbnail_size = Thumbnail Size:
overlay_size = Overlay Size:
onion_skin = Onion Skin:
merge_frames = Merge Frames
red_blue_tint = Red/Blue Tint

View File

@ -21,16 +21,14 @@
</hbox>
<hbox>
<check id="thumb_check" text="@.thumbnails" horizontal="true" />
<check id="thumb_enabled" text="@.thumbnails" horizontal="true" />
<separator id="thumb_h_separator" horizontal="true" expansive="true" />
</hbox>
<grid columns="3" id="thumb_box">
<check id="thumb_enabled" text="@.force" />
<label text="@.zoom" />
<grid columns="2" id="thumb_box">
<label text="@.thumbnail_size" />
<slider min="1" max="10" id="zoom" cell_align="horizontal" width="128" />
<check id="thumb_overlay_enabled" text="@.overlay"/>
<label text="@.size" />
<check id="thumb_overlay_enabled" text="@.overlay_size"/>
<slider min="2" max="10" id="thumb_overlay_size" cell_align="horizontal" width="128" />
</grid>
</vbox>

View File

@ -64,14 +64,13 @@ ConfigureTimelinePopup::ConfigureTimelinePopup()
m_box->infront()->Click.connect(base::Bind<void>(&ConfigureTimelinePopup::onPositionChange, this));
m_box->zoom()->Change.connect(base::Bind<void>(&ConfigureTimelinePopup::onZoomChange, this));
m_box->thumbCheck()->Click.connect(base::Bind<void>(&ConfigureTimelinePopup::onThumbBoxChange, this));
m_box->thumbEnabled()->Click.connect(base::Bind<void>(&ConfigureTimelinePopup::onThumbEnabledChange, this));
m_box->thumbOverlayEnabled()->Click.connect(base::Bind<void>(&ConfigureTimelinePopup::onThumbOverlayEnabledChange, this));
m_box->thumbOverlaySize()->Change.connect(base::Bind<void>(&ConfigureTimelinePopup::onThumbOverlaySizeChange, this));
bool visibleThumbBox = Preferences::instance().thumbnails.visibleOptions();
m_box->thumbHSeparator()->setVisible(visibleThumbBox);
m_box->thumbBox()->setVisible(visibleThumbBox);
const bool visibleThumb = docPref().thumbnails.enabled();
m_box->thumbHSeparator()->setVisible(visibleThumb);
m_box->thumbBox()->setVisible(visibleThumb);
}
app::Document* ConfigureTimelinePopup::doc()
@ -132,13 +131,12 @@ void ConfigureTimelinePopup::updateWidgetsFromCurrentSettings()
break;
}
bool visibleThumbBox = Preferences::instance().thumbnails.visibleOptions();
const bool visibleThumb = docPref.thumbnails.enabled();
m_box->zoom()->setValue(int(docPref.thumbnails.zoom())); // TODO add a slider for floating points
m_box->thumbCheck()->setSelected(visibleThumbBox);
m_box->thumbHSeparator()->setVisible(visibleThumbBox);
m_box->thumbBox()->setVisible(visibleThumbBox);
m_box->thumbEnabled()->setSelected(docPref.thumbnails.enabled());
m_box->thumbEnabled()->setSelected(visibleThumb);
m_box->thumbHSeparator()->setVisible(visibleThumb);
m_box->thumbBox()->setVisible(visibleThumb);
m_box->thumbOverlayEnabled()->setSelected(docPref.thumbnails.overlayEnabled());
m_box->thumbOverlaySize()->setValue(docPref.thumbnails.overlaySize());
@ -242,17 +240,10 @@ void ConfigureTimelinePopup::onZoomChange()
docPref().thumbnails.zoom(m_box->zoom()->getValue());
}
void ConfigureTimelinePopup::onThumbBoxChange()
{
auto& option = Preferences::instance().thumbnails.visibleOptions;
option(!option());
updateWidgetsFromCurrentSettings();
}
void ConfigureTimelinePopup::onThumbEnabledChange()
{
docPref().thumbnails.enabled(m_box->thumbEnabled()->isSelected());
updateWidgetsFromCurrentSettings();
}
void ConfigureTimelinePopup::onThumbOverlayEnabledChange()

View File

@ -43,7 +43,6 @@ namespace app {
void onPositionChange();
void onZoomChange();
void onThumbBoxChange();
void onThumbEnabledChange();
void onThumbOverlayEnabledChange();
void onThumbOverlaySizeChange();

View File

@ -238,29 +238,35 @@ Timeline::~Timeline()
delete m_confPopup;
}
void Timeline::setZoom(double zoom)
void Timeline::setZoom(const double zoom)
{
m_zoom = MID(1.0, zoom, 10.0);
m_thumbnailsOverlayDirection = gfx::Point(int(frameBoxWidth()*1.0), int(frameBoxWidth()*0.5));
m_thumbnailsOverlayVisible = false;
}
void Timeline::setZoomAndUpdate(double zoom)
void Timeline::setZoomAndUpdate(const double zoom,
const bool updatePref)
{
if (zoom != m_zoom) {
setZoom(zoom);
regenerateTagBands();
updateScrollBars();
setViewScroll(viewScroll());
invalidate();
}
if (zoom != docPref().thumbnails.zoom()) {
if (updatePref && zoom != docPref().thumbnails.zoom()) {
docPref().thumbnails.zoom(zoom);
docPref().thumbnails.enabled(zoom > 1);
}
}
void Timeline::onThumbnailsPrefChange()
{
setZoomAndUpdate(docPref().thumbnails.zoom());
setZoomAndUpdate(
docPref().thumbnails.enabled() ?
docPref().thumbnails.zoom(): 1.0,
false);
}
void Timeline::updateUsingEditor(Editor* editor)
@ -304,7 +310,9 @@ void Timeline::updateUsingEditor(Editor* editor)
m_thumbnailsPrefConn = docPref.thumbnails.AfterChange.connect(
base::Bind<void>(&Timeline::onThumbnailsPrefChange, this));
setZoom(docPref.thumbnails.zoom());
setZoom(
docPref.thumbnails.enabled() ?
docPref.thumbnails.zoom(): 1.0);
// If we are already in the same position as the "editor", we don't
// need to update the at all timeline.
@ -1217,7 +1225,7 @@ bool Timeline::onProcessMessage(Message* msg)
else if (dz > 1.0) dz = 1.0;
}
setZoomAndUpdate(m_zoom - dz);
setZoomAndUpdate(m_zoom - dz, true);
}
else {
if (!precise) {
@ -1248,7 +1256,9 @@ bool Timeline::onProcessMessage(Message* msg)
break;
case kTouchMagnifyMessage:
setZoomAndUpdate(m_zoom + m_zoom * static_cast<ui::TouchMessage*>(msg)->magnification());
setZoomAndUpdate(
m_zoom + m_zoom * static_cast<ui::TouchMessage*>(msg)->magnification(),
true);
break;
}
@ -1996,7 +2006,7 @@ void Timeline::drawCel(ui::Graphics* g, layer_t layerIndex, frame_t frame, Cel*
drawPart(g, bounds, nullptr, style, is_active, is_hover);
// Draw thumbnail
if ((docPref().thumbnails.enabled() || m_zoom > 1) && image) {
if ((docPref().thumbnails.enabled() && m_zoom > 1) && image) {
gfx::Rect thumb_bounds =
gfx::Rect(bounds).shrink(
skinTheme()->calcBorder(this, style));
@ -3473,12 +3483,12 @@ int Timeline::headerBoxHeight() const
int Timeline::layerBoxHeight() const
{
return int(m_zoom*skinTheme()->dimensions.timelineBaseSize() + int(m_zoom > 1) * headerBoxHeight());
return int(zoom()*skinTheme()->dimensions.timelineBaseSize());
}
int Timeline::frameBoxWidth() const
{
return int(m_zoom*skinTheme()->dimensions.timelineBaseSize());
return int(zoom()*skinTheme()->dimensions.timelineBaseSize());
}
int Timeline::outlineWidth() const
@ -3494,6 +3504,14 @@ int Timeline::oneTagHeight() const
skinTheme()->dimensions.timelineTagsAreaHeight();
}
double Timeline::zoom() const
{
if (docPref().thumbnails.enabled())
return m_zoom;
else
return 1.0;
}
// Returns the last frame where the frame tag (or frame tag label)
// is visible in the timeline.
int Timeline::calcTagVisibleToFrame(FrameTag* frameTag) const

View File

@ -311,8 +311,11 @@ namespace app {
void updateCelOverlayBounds(const Hit& hit);
void drawCelOverlay(ui::Graphics* g);
void onThumbnailsPrefChange();
void setZoom(double zoom);
void setZoomAndUpdate(double zoom);
void setZoom(const double zoom);
void setZoomAndUpdate(const double zoom,
const bool updatePref);
double zoom() const;
ui::ScrollBar m_hbar;
ui::ScrollBar m_vbar;