1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-03-06 22:45:29 +01:00

Adding affordances to TrackPanel and TrackView

This commit is contained in:
Vitaly Sverchinsky
2021-07-15 14:33:39 +03:00
committed by Paul Licameli
parent de664eb9b7
commit 0b6d5bc7f6
3 changed files with 88 additions and 2 deletions

View File

@@ -1270,7 +1270,61 @@ struct VRulersAndChannels final : TrackPanelGroup {
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
struct ChannelGroup final : TrackPanelGroup {
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 pLast = *channels.rbegin();
wxCoord yy = rect.GetTop();
for ( auto channel : channels ) {
for ( auto channel : channels )
{
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();
rect.SetTop( yy );
rect.SetHeight( height - kSeparatorThickness );
@@ -1444,6 +1509,9 @@ struct Subgroup final : TrackPanelGroup {
for ( auto channel : TrackList::Channels( leader ) ) {
auto &view = TrackView::Get( *channel );
height += view.GetHeight();
if (view.GetAffordanceControls())
height += kAffordancesAreaHeight;
}
refinement.emplace_back( yy,
std::make_shared< ResizingChannelGroup >(