Skip to content

Commit

Permalink
Extended track play/pause mouse discovery for entire track row.
Browse files Browse the repository at this point in the history
Re-worded manual test for play/pause music track.. Fixes: https://bugs.launchpad.net/bugs/1043997. Approved by Michal Hruby.
  • Loading branch information
nickdedekind authored and Tarmac committed Sep 11, 2012
2 parents e14e2da + 038dcc4 commit 6699f0b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 17 deletions.
39 changes: 27 additions & 12 deletions dash/previews/Track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,19 +194,16 @@ void Track::SetupViews()
nux::BaseTexture* tex_play = style.GetPlayIcon();
IconTexture* status_play = new IconTexture(tex_play, style.GetStatusIconSize(), style.GetStatusIconSize());
status_play->SetDrawMode(IconTexture::DrawMode::STRETCH_WITH_ASPECT);
status_play->SetInputEventSensitivity(false);

nux::BaseTexture* tex_pause = style.GetPauseIcon();
IconTexture* status_pause = new IconTexture(tex_pause, style.GetStatusIconSize(), style.GetStatusIconSize());
status_pause->SetDrawMode(IconTexture::DrawMode::STRETCH_WITH_ASPECT);
status_pause->SetInputEventSensitivity(false);

track_number_ = new nux::StaticCairoText("", NUX_TRACKER_LOCATION);
track_number_->SetTextAlignment(nux::StaticCairoText::NUX_ALIGN_CENTRE);
track_number_->SetTextVerticalAlignment(nux::StaticCairoText::NUX_ALIGN_CENTRE);
track_number_->SetLines(-1);
track_number_->SetFont(style.track_font());
track_number_->SetInputEventSensitivity(false);

title_ = new nux::StaticCairoText("", NUX_TRACKER_LOCATION);
title_->SetTextAlignment(nux::StaticCairoText::NUX_ALIGN_LEFT);
Expand All @@ -229,26 +226,18 @@ void Track::SetupViews()
status_play_layout_->GetLayout()->AddSpace(0, 1);
status_play_layout_->GetLayout()->AddView(status_play, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
status_play_layout_->GetLayout()->AddSpace(0, 1);
status_play_layout_->mouse_click.connect([&](int, int, unsigned long, unsigned long) { play.emit(uri_); });
status_play_layout_->mouse_enter.connect(sigc::mem_fun(this, &Track::OnTrackControlMouseEnter));
status_play_layout_->mouse_leave.connect(sigc::mem_fun(this, &Track::OnTrackControlMouseLeave));

status_pause_layout_ = new TmpView();
status_pause_layout_->SetLayout(new nux::HLayout());
status_pause_layout_->GetLayout()->AddSpace(0, 1);
status_pause_layout_->GetLayout()->AddView(status_pause, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
status_pause_layout_->GetLayout()->AddSpace(0, 1);
status_pause_layout_->mouse_click.connect([&](int, int, unsigned long, unsigned long) { pause.emit(uri_); });
status_pause_layout_->mouse_enter.connect(sigc::mem_fun(this, &Track::OnTrackControlMouseEnter));
status_pause_layout_->mouse_leave.connect(sigc::mem_fun(this, &Track::OnTrackControlMouseLeave));

track_number_layout_ = new TmpView();
track_number_layout_->SetLayout(new nux::HLayout());
track_number_layout_->GetLayout()->AddSpace(0, 1);
track_number_layout_->GetLayout()->AddView(track_number_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
track_number_layout_->GetLayout()->AddSpace(0, 1);
track_number_layout_->mouse_enter.connect(sigc::mem_fun(this, &Track::OnTrackControlMouseEnter));
track_number_layout_->mouse_leave.connect(sigc::mem_fun(this, &Track::OnTrackControlMouseLeave));

track_status_layout_ = new nux::LayeredLayout();
track_status_layout_->AddLayer(status_play_layout_, true);
Expand All @@ -269,6 +258,23 @@ void Track::SetupViews()
layout->AddLayout(title_layout_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
layout->AddLayout(duration_layout_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
SetLayout(layout);

mouse_enter.connect(sigc::mem_fun(this, &Track::OnTrackControlMouseEnter));
mouse_leave.connect(sigc::mem_fun(this, &Track::OnTrackControlMouseLeave));
mouse_click.connect([&](int, int, unsigned long, unsigned long)
{
switch (play_state_)
{
case dash::PLAYING:
pause.emit(uri_);
break;
case dash::PAUSED:
case dash::STOPPED:
default:
play.emit(uri_);
break;
}
});
}

void Track::Draw(nux::GraphicsEngine& gfx_engine, bool force_draw)
Expand Down Expand Up @@ -341,9 +347,18 @@ void Track::DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw)
gfx_engine.PopClippingRectangle();
}

nux::Area* Track::FindAreaUnderMouse(const nux::Point& mouse_position, nux::NuxEventType event_type)
{
bool mouse_inside = TestMousePointerInclusionFilterMouseWheel(mouse_position, event_type);
if (mouse_inside == false)
return NULL;

return this;
}

bool Track::HasStatusFocus() const
{
return play_state_ == dash::PLAYING || play_state_ == dash::PAUSED;
return mouse_over_ || play_state_ == dash::PLAYING || play_state_ == dash::PAUSED;
}

void Track::OnTrackControlMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags)
Expand Down
1 change: 1 addition & 0 deletions dash/previews/Track.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class Track : public nux::View, public debug::Introspectable
virtual void Draw(nux::GraphicsEngine& gfx_engine, bool force_draw);
virtual void DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw);
virtual void PreLayoutManagement();
virtual nux::Area* FindAreaUnderMouse(const nux::Point& mouse_position, nux::NuxEventType event_type);

// From debug::Introspectable
std::string GetName() const;
Expand Down
14 changes: 9 additions & 5 deletions manual-tests/Preview.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Expected Result:
The Track information will contain a title and duration.


Preview Music Play
Preview Music Track Play
note: Should be automated.
------------
This tests the dash music preview track play
Expand All @@ -84,14 +84,16 @@ Setup:
#. Open a preview for a result which contains tracks.

Actions:
#. Play first track.
#. Hover over track number for the track you wish to play.
#. Click play icon.

Expected Result:
When hovering on track number, it will change to a play icon.
Music Player daemon will start playing track and update status of the track
in the preview to playing as well as update it's progress.


Preview Music Pause
Preview Music Track Pause
note: Should be automated.
------------
This tests the dash preview preview navigate right animation
Expand All @@ -100,12 +102,14 @@ Setup:
#. Open music lens (Super+M)
#. Enter arbitrary search string and ensure a result is available.
#. Open a preview for a result which contains tracks.
#. Play first track.
#. Play first track. (by hovering+click on track number.)

Actions:
#. Pause playing track.
#. Hover over pause icon for the track which is playing.
#. Click pause icon.

Expected Result:
When hovering on play icon, it will change to a pause icon.
Music Player daemon will pause the playing track and update it's status
to paused. Progress will stop incresing.

Expand Down

0 comments on commit 6699f0b

Please sign in to comment.