From 55164939d849b087240b4b27f51d0aad8a2bf857 Mon Sep 17 00:00:00 2001 From: torque Date: Fri, 27 Oct 2017 18:27:07 -0700 Subject: [PATCH] HoverTime: animate position from bottom instead of alpha. I liked the fade-in effect, but it had the problem that it would override any style-configured opacity for the hover time. Making it pop up from behind the progress bar is a significantly more straightforward solution than trying to parse the configured line style for opacity tags, so the animation has been changed. I think this will work better with the (eventually) planned chapter title hover effect. --- src/HoverTime.moon | 23 ++++++++++++----------- src/main.moon | 2 +- src/settings.moon | 9 +++++++++ 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/HoverTime.moon b/src/HoverTime.moon index 0ba3314..adfdb6b 100644 --- a/src/HoverTime.moon +++ b/src/HoverTime.moon @@ -3,6 +3,7 @@ class HoverTime extends BarAccent rightMargin = settings['hover-time-right-margin'] leftMargin = settings['hover-time-left-margin'] bottomMargin = settings['hover-time-bottom-margin'] + offScreenPos = settings['hover-time-offscreen-pos'] new: => super! @@ -10,44 +11,44 @@ class HoverTime extends BarAccent @line = { [[{%s%s\pos(]]\format settings['default-style'], settings['hover-time-style'] [[-100,0]] - [[)\alpha&H]] - [[FF]] - [[&\an2}]] + [[)\an2}]] [[????]] } @lastTime = 0 @lastX = -1 - @position = -100 - @animation = Animation 255, 0, @animationDuration, @\animate + @position = offScreenPos + @animation = Animation offScreenPos, bottomMargin, @animationDuration, @\animate, nil, 0.5 reconfigure: => super! rightMargin = settings['hover-time-right-margin'] leftMargin = settings['hover-time-left-margin'] bottomMargin = settings['hover-time-bottom-margin'] - @line[2] = ('%g,%g')\format math.min( Window.w - rightMargin, math.max( leftMargin, Mouse.x ) ), @yPos - bottomMargin + offScreenPos = settings['hover-time-offscreen-pos'] + @line[2] = ('%g,%g')\format math.min( Window.w - rightMargin, math.max( leftMargin, Mouse.x ) ), @position @line[1] = ([[{%s%s\pos(]])\format settings['default-style'], settings['hover-time-style'] - @animation = Animation 255, 0, @animationDuration, @\animate + @animation = Animation offScreenPos, bottomMargin, @animationDuration, @\animate, nil, 0.5 resize: => super! - @line[2] = ("%g,%g")\format math.min( Window.w - rightMargin, math.max( leftMargin, Mouse.x ) ), @yPos - bottomMargin + @line[2] = ("%g,%g")\format math.min( Window.w - rightMargin, math.max( leftMargin, Mouse.x ) ), @yPos - @animation.value animate: ( value ) => - @line[4] = ([[%02X]])\format value + @position = @yPos - value + @line[2] = ("%g,%g")\format math.min( Window.w - rightMargin, math.max( leftMargin, Mouse.x ) ), @position @needsUpdate = true redraw: => if @active super! if Mouse.x != @lastX - @line[2] = ("%g,%g")\format math.min( Window.w - rightMargin, math.max( leftMargin, Mouse.x ) ), @yPos - bottomMargin + @line[2] = ("%g,%g")\format math.min( Window.w - rightMargin, math.max( leftMargin, Mouse.x ) ), @position @lastX = Mouse.x hoverTime = mp.get_property_number( 'duration', 0 )*Mouse.x/Window.w if hoverTime != @lastTime - @line[6] = ([[%d:%02d:%02d]])\format math.floor( hoverTime/3600 ), math.floor( (hoverTime/60)%60 ), math.floor( hoverTime%60 ) + @line[4] = ([[%d:%02d:%02d]])\format math.floor( hoverTime/3600 ), math.floor( (hoverTime/60)%60 ), math.floor( hoverTime%60 ) @lastTime = hoverTime @needsUpdate = true diff --git a/src/main.moon b/src/main.moon index d25d5ad..675873f 100644 --- a/src/main.moon +++ b/src/main.moon @@ -65,8 +65,8 @@ if settings['enable-system-time'] -- The order of these is important, because the order that elements are added to -- eventLoop matters, because that controls how they are layered (first element -- on the bottom). -eventLoop\addZone bottomZone eventLoop\addZone hoverTimeZone +eventLoop\addZone bottomZone eventLoop\addZone topZone notFrameStepping = false diff --git a/src/settings.moon b/src/settings.moon index 75e70e3..dc61789 100644 --- a/src/settings.moon +++ b/src/settings.moon @@ -350,6 +350,15 @@ display will disappear without animating all the way off-screen. Positive values will cause the display to animate the wrong direction. ]] +settings['hover-time-offscreen-pos'] = -50 +helpText['hover-time-offscreen-pos'] = [[ +Controls how far off the bottom of the window the mouse hover time display tries +to move when it is inactive. If you use a non-default font, this value may need +to be tweaked. If this value is not far enough off-screen, the elapsed +display will disappear without animating all the way off-screen. Positive values +will cause the display to animate the wrong direction. +]] + settings['system-time-offscreen-pos'] = -100 helpText['system-time-offscreen-pos'] = [[ Controls how far off the left side of the window the system time display tries