MediaPlayer: Improvements to time tooltip.
* Make PositionToolTip update even when not attached to a window. * Always use the "hover" message to update the tooltip, never SetPosition. * Use BControl::Invoke so that hover messages are sent instantly. * Position the tooltip above the slider always. Combined with the fixes to the Interface Kit, this provides a much nicer experience for slider time tooltips. Change-Id: Ib7f884ca91c253ed7e6639946fd2378166137d80 Reviewed-on: https://review.haiku-os.org/c/haiku/+/9122 Haiku-Format: Haiku-format Bot <[email protected]> Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
1725765ef7
commit
c97ebaf1c7
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <Autolock.h>
|
||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
|
|
||||||
#include "DurationToString.h"
|
#include "DurationToString.h"
|
||||||
@@ -36,16 +37,15 @@ public:
|
|||||||
|
|
||||||
void Update(bigtime_t position, bigtime_t duration)
|
void Update(bigtime_t position, bigtime_t duration)
|
||||||
{
|
{
|
||||||
if (!LockLooper())
|
BAutolock locker(Looper());
|
||||||
|
if (Looper() != NULL && !locker.IsLocked())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (position != -1) {
|
if (position != -1) {
|
||||||
position /= 1000000L;
|
position /= 1000000L;
|
||||||
duration /= 1000000L;
|
duration /= 1000000L;
|
||||||
if (position == fPosition && duration == fDuration) {
|
if (position == fPosition && duration == fDuration)
|
||||||
UnlockLooper();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
fPosition = position;
|
fPosition = position;
|
||||||
fDuration = duration;
|
fDuration = duration;
|
||||||
@@ -60,8 +60,6 @@ public:
|
|||||||
char text[66];
|
char text[66];
|
||||||
snprintf(text, sizeof(text), "%s / %s", positionText, durationText);
|
snprintf(text, sizeof(text), "%s / %s", positionText, durationText);
|
||||||
SetText(text);
|
SetText(text);
|
||||||
|
|
||||||
UnlockLooper();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -124,9 +124,9 @@ SeekSlider::MouseUp(BPoint where)
|
|||||||
void
|
void
|
||||||
SeekSlider::MouseMoved(BPoint point, uint32 transit, const BMessage* dragMessage)
|
SeekSlider::MouseMoved(BPoint point, uint32 transit, const BMessage* dragMessage)
|
||||||
{
|
{
|
||||||
if (!IsTracking()) {
|
if (fHoverMessage != NULL) {
|
||||||
fHoverMessage->SetInt32("value", ValueForPoint(point));
|
fHoverMessage->SetInt32("value", ValueForPoint(point));
|
||||||
Invoke(fHoverMessage);
|
BControl::Invoke(fHoverMessage);
|
||||||
}
|
}
|
||||||
BSlider::MouseMoved(point, transit, dragMessage);
|
BSlider::MouseMoved(point, transit, dragMessage);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,6 +88,8 @@ TransportControlGroup::TransportControlGroup(BRect frame, bool useSkipButtons,
|
|||||||
fSeekLayout->AddView(fSeekSlider);
|
fSeekLayout->AddView(fSeekSlider);
|
||||||
|
|
||||||
fPositionToolTip = new PositionToolTip();
|
fPositionToolTip = new PositionToolTip();
|
||||||
|
fPositionToolTip->SetAlignment(BAlignment(B_ALIGN_CENTER, B_ALIGN_TOP));
|
||||||
|
fPositionToolTip->SetMouseRelativeLocation(BPoint(0, 0));
|
||||||
fSeekSlider->SetToolTip(fPositionToolTip);
|
fSeekSlider->SetToolTip(fPositionToolTip);
|
||||||
|
|
||||||
// Duration view
|
// Duration view
|
||||||
@@ -278,10 +280,11 @@ TransportControlGroup::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
case MSG_DURATION_TOOLTIP:
|
case MSG_DURATION_TOOLTIP:
|
||||||
{
|
{
|
||||||
BToolTipManager* manager = BToolTipManager::Manager();
|
|
||||||
BPoint tipPoint;
|
BPoint tipPoint;
|
||||||
GetMouse(&tipPoint, NULL, false);
|
fSeekSlider->GetMouse(&tipPoint, NULL, false);
|
||||||
manager->ShowTip(fPositionToolTip, tipPoint, this);
|
tipPoint.y = 0;
|
||||||
|
fSeekSlider->ConvertToScreen(&tipPoint);
|
||||||
|
BToolTipManager::Manager()->ShowTip(fPositionToolTip, tipPoint, this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,6 +294,7 @@ TransportControlGroup::MessageReceived(BMessage* message)
|
|||||||
if (message->FindInt32("value", &value) == B_OK) {
|
if (message->FindInt32("value", &value) == B_OK) {
|
||||||
bigtime_t position = TimePositionFor(value / (float)kPositionFactor);
|
bigtime_t position = TimePositionFor(value / (float)kPositionFactor);
|
||||||
fPositionToolTip->Update(position, fDurationView->TimeDuration());
|
fPositionToolTip->Update(position, fDurationView->TimeDuration());
|
||||||
|
Looper()->PostMessage(MSG_DURATION_TOOLTIP, this);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -505,11 +509,8 @@ TransportControlGroup::SetPosition(float value, bigtime_t position,
|
|||||||
{
|
{
|
||||||
fDurationView->Update(position, duration);
|
fDurationView->Update(position, duration);
|
||||||
|
|
||||||
if (fSeekSlider->IsTracking()) {
|
if (fSeekSlider->IsTracking())
|
||||||
fPositionToolTip->Update(position, duration);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
fSeekSlider->SetPosition(value);
|
fSeekSlider->SetPosition(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user