mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-16 16:10:06 +02:00
Adding affordances to TrackPanel and TrackView
This commit is contained in:
parent
f0bbb4ecda
commit
1190041f3c
@ -1270,7 +1270,61 @@ struct VRulersAndChannels final : TrackPanelGroup {
|
|||||||
wxCoord mLeftOffset;
|
wxCoord mLeftOffset;
|
||||||
};
|
};
|
||||||
|
|
||||||
// n channels with vertical rulers, alternating with n - 1 resizers;
|
//Simply fills area using specified brush and outlines borders
|
||||||
|
class EmptyPanelRect final : public CommonTrackPanelCell
|
||||||
|
{
|
||||||
|
int mFillBrushName;
|
||||||
|
public:
|
||||||
|
explicit EmptyPanelRect(int fillBrushName)
|
||||||
|
: mFillBrushName(fillBrushName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
~EmptyPanelRect() { }
|
||||||
|
|
||||||
|
void Draw(TrackPanelDrawingContext& context, const wxRect& rect, unsigned iPass)
|
||||||
|
{
|
||||||
|
if (iPass == TrackArtist::PassBackground)
|
||||||
|
{
|
||||||
|
context.dc.SetPen(*wxTRANSPARENT_PEN);
|
||||||
|
AColor::UseThemeColour(&context.dc, mFillBrushName);
|
||||||
|
context.dc.DrawRectangle(rect);
|
||||||
|
wxRect bevel(rect.x, rect.y, rect.width - 1, rect.height - 1);
|
||||||
|
AColor::BevelTrackInfo(context.dc, true, bevel, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<Track> DoFindTrack() override
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<UIHandlePtr> HitTest(const TrackPanelMouseState& state, const AudacityProject* pProject)
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//Simply place children one after another horizontally, without any specific logic
|
||||||
|
struct HorizontalGroup final : TrackPanelGroup {
|
||||||
|
|
||||||
|
Refinement mRefinement;
|
||||||
|
|
||||||
|
HorizontalGroup(Refinement refinement)
|
||||||
|
: mRefinement(std::move(refinement))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Subdivision Children(const wxRect& /*rect*/) override
|
||||||
|
{
|
||||||
|
return { Axis::X, mRefinement };
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// optional affordance area, and n channels with vertical rulers,
|
||||||
|
// alternating with n - 1 resizers;
|
||||||
// each channel-ruler pair might be divided into multiple views
|
// each channel-ruler pair might be divided into multiple views
|
||||||
struct ChannelGroup final : TrackPanelGroup {
|
struct ChannelGroup final : TrackPanelGroup {
|
||||||
ChannelGroup( const std::shared_ptr< Track > &pTrack, wxCoord leftOffset )
|
ChannelGroup( const std::shared_ptr< Track > &pTrack, wxCoord leftOffset )
|
||||||
@ -1283,8 +1337,19 @@ struct ChannelGroup final : TrackPanelGroup {
|
|||||||
const auto channels = TrackList::Channels( mpTrack.get() );
|
const auto channels = TrackList::Channels( mpTrack.get() );
|
||||||
const auto pLast = *channels.rbegin();
|
const auto pLast = *channels.rbegin();
|
||||||
wxCoord yy = rect.GetTop();
|
wxCoord yy = rect.GetTop();
|
||||||
for ( auto channel : channels ) {
|
for ( auto channel : channels )
|
||||||
|
{
|
||||||
auto &view = TrackView::Get( *channel );
|
auto &view = TrackView::Get( *channel );
|
||||||
|
if (auto affordance = view.GetAffordanceControls())
|
||||||
|
{
|
||||||
|
Refinement hgroup {
|
||||||
|
std::make_pair(rect.GetLeft() + 1, std::make_shared<EmptyPanelRect>(channel->GetSelected() ? clrTrackInfoSelected : clrTrackInfo)),
|
||||||
|
std::make_pair(mLeftOffset, affordance)
|
||||||
|
};
|
||||||
|
refinement.emplace_back(yy, std::make_shared<HorizontalGroup>(hgroup));
|
||||||
|
yy += kAffordancesAreaHeight;
|
||||||
|
}
|
||||||
|
|
||||||
auto height = view.GetHeight();
|
auto height = view.GetHeight();
|
||||||
rect.SetTop( yy );
|
rect.SetTop( yy );
|
||||||
rect.SetHeight( height - kSeparatorThickness );
|
rect.SetHeight( height - kSeparatorThickness );
|
||||||
@ -1444,6 +1509,9 @@ struct Subgroup final : TrackPanelGroup {
|
|||||||
for ( auto channel : TrackList::Channels( leader ) ) {
|
for ( auto channel : TrackList::Channels( leader ) ) {
|
||||||
auto &view = TrackView::Get( *channel );
|
auto &view = TrackView::Get( *channel );
|
||||||
height += view.GetHeight();
|
height += view.GetHeight();
|
||||||
|
|
||||||
|
if (view.GetAffordanceControls())
|
||||||
|
height += kAffordancesAreaHeight;
|
||||||
}
|
}
|
||||||
refinement.emplace_back( yy,
|
refinement.emplace_back( yy,
|
||||||
std::make_shared< ResizingChannelGroup >(
|
std::make_shared< ResizingChannelGroup >(
|
||||||
|
@ -141,6 +141,13 @@ std::shared_ptr<const TrackVRulerControls> TrackView::GetVRulerControls() const
|
|||||||
return const_cast< TrackView* >( this )->GetVRulerControls();
|
return const_cast< TrackView* >( this )->GetVRulerControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<CommonTrackCell> TrackView::GetAffordanceControls()
|
||||||
|
{
|
||||||
|
if (!mpAffordanceCellControl)
|
||||||
|
mpAffordanceCellControl = DoGetAffordanceControls();
|
||||||
|
return mpAffordanceCellControl;
|
||||||
|
}
|
||||||
|
|
||||||
void TrackView::DoSetY(int y)
|
void TrackView::DoSetY(int y)
|
||||||
{
|
{
|
||||||
mY = y;
|
mY = y;
|
||||||
@ -165,6 +172,11 @@ void TrackView::DoSetHeight(int h)
|
|||||||
mHeight = h;
|
mHeight = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<CommonTrackCell> TrackView::DoGetAffordanceControls()
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// Attach an object to each project. It receives track list events and updates
|
// Attach an object to each project. It receives track list events and updates
|
||||||
|
@ -62,6 +62,9 @@ public:
|
|||||||
std::shared_ptr<TrackVRulerControls> GetVRulerControls();
|
std::shared_ptr<TrackVRulerControls> GetVRulerControls();
|
||||||
std::shared_ptr<const TrackVRulerControls> GetVRulerControls() const;
|
std::shared_ptr<const TrackVRulerControls> GetVRulerControls() const;
|
||||||
|
|
||||||
|
// by default returns nullptr, meaning that track has no drag controls area
|
||||||
|
std::shared_ptr<CommonTrackCell> GetAffordanceControls();
|
||||||
|
|
||||||
|
|
||||||
void WriteXMLAttributes( XMLWriter & ) const override;
|
void WriteXMLAttributes( XMLWriter & ) const override;
|
||||||
bool HandleXMLAttribute( const wxChar *attr, const wxChar *value ) override;
|
bool HandleXMLAttribute( const wxChar *attr, const wxChar *value ) override;
|
||||||
@ -88,8 +91,11 @@ protected:
|
|||||||
// Private factory to make appropriate object; class TrackView handles
|
// Private factory to make appropriate object; class TrackView handles
|
||||||
// memory management thereafter
|
// memory management thereafter
|
||||||
virtual std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() = 0;
|
virtual std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() = 0;
|
||||||
|
// May return nullptr (which is default) if track does not need affordance area
|
||||||
|
virtual std::shared_ptr<CommonTrackCell> DoGetAffordanceControls();
|
||||||
|
|
||||||
std::shared_ptr<TrackVRulerControls> mpVRulerControls;
|
std::shared_ptr<TrackVRulerControls> mpVRulerControls;
|
||||||
|
std::shared_ptr<CommonTrackCell> mpAffordanceCellControl;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool mMinimized{ false };
|
bool mMinimized{ false };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user