1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-14 17:14:07 +01:00

Highlighting of label text boxes

This commit is contained in:
Paul Licameli
2017-06-22 10:06:50 -04:00
parent ecebf7656e
commit a4d53b43da
2 changed files with 32 additions and 8 deletions

View File

@@ -30,6 +30,7 @@ for drawing different aspects of the label and its text box.
#include "Audacity.h"
#include "LabelTrack.h"
#include "Experimental.h"
#include "TrackPanel.h"
#include <stdio.h>
@@ -774,6 +775,7 @@ namespace {
}
#include "TrackPanelDrawingContext.h"
#include "tracks/labeltrack/ui/LabelTextHandle.h"
/// Draw calls other functions to draw the LabelTrack.
/// @param dc the device context
@@ -840,13 +842,30 @@ void LabelTrack::Draw
}}
// Draw the label boxes.
{ int i = -1; for (auto &labelStruct : mLabels) { ++i;
if( mSelIndex==i)
dc.SetBrush(AColor::labelTextEditBrush);
{
bool highlightTrack = false;
#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
auto target = dynamic_cast<LabelTextHandle*>(context.target.get());
highlightTrack = target && target->GetTrack().get() == this;
#endif
int i = -1; for (auto &labelStruct : mLabels) { ++i;
bool highlight = false;
#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
highlight = highlightTrack && target->GetLabelNum() == i;
#endif
bool selected = mSelIndex == i;
const wxBrush &brush = dc.GetBrush();
if( selected )
dc.SetBrush( AColor::labelTextEditBrush );
else if ( highlight )
dc.SetBrush( AColor::uglyBrush );
labelStruct.DrawTextBox( dc, r );
if( mSelIndex==i)
dc.SetBrush(AColor::labelTextNormalBrush);
}}
if (highlight || selected)
dc.SetBrush( brush );
}
}
// Draw highlights
if ((mInitialCursorPos != mCurrentCursorPos) && (mSelIndex >= 0 ))

View File

@@ -10,6 +10,7 @@ Paul Licameli split from TrackPanel.cpp
#include "../../../Audacity.h"
#include "LabelTextHandle.h"
#include "../../Experimental.h"
#include "../../../HitTestResult.h"
#include "../../../LabelTrack.h"
#include "../../../Project.h"
@@ -22,7 +23,11 @@ LabelTextHandle::LabelTextHandle
( const std::shared_ptr<LabelTrack> &pLT, int labelNum )
: mpLT{ pLT }
, mLabelNum{ labelNum }
{}
{
#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
mChangeHighlight = RefreshCode::RefreshCell;
#endif
}
HitTestPreview LabelTextHandle::HitPreview()
{