Set useful titles to all the windows. Also fix a nasty spurious drag caused by creating a

window with the left mouse button held down.
This commit is contained in:
David Given
2022-08-07 18:12:57 +02:00
parent 03d2a3a685
commit 6f7054c4b2
5 changed files with 37 additions and 21 deletions

View File

@@ -365,9 +365,10 @@ void FluxViewerControl::OnMouseMotion(wxMouseEvent& event)
}
else if (event.ButtonUp(wxMOUSE_BTN_LEFT))
{
/* end drag, do nothing */
_dragStartX = -1;
_dragStartPosition = -1;
}
else if (event.Dragging() && event.LeftIsDown())
else if (event.Dragging() && event.LeftIsDown() && (_dragStartX != -1))
{
int dx = _dragStartX - event.GetX();
nanoseconds_t dt = dx * _nanosecondsPerPixel;
@@ -434,22 +435,24 @@ void FluxViewerControl::DisplayDecodedData(std::shared_ptr<const Sector> sector)
{
std::stringstream s;
s << fmt::format("Decoded user data for c{}.h{}.s{}\n",
auto title = fmt::format("User data for c{}.h{}.s{}",
sector->logicalTrack, sector->logicalSide, sector->logicalSector);
s << title << '\n';
dumpSectorMetadata(s, sector);
s << '\n';
hexdump(s, sector->data);
(new HexViewerWindow(this, s.str()))->Show(true);
HexViewerWindow::Create(this, title, s.str());
}
void FluxViewerControl::DisplayRawData(std::shared_ptr<const Sector> sector)
{
std::stringstream s;
s << fmt::format("Raw undecoded data for c{}.h{}.s{}\n",
auto title = fmt::format("Raw data for c{}.h{}.s{}",
sector->logicalTrack, sector->logicalSide, sector->logicalSector);
s << title << '\n';
dumpSectorMetadata(s, sector);
s << fmt::format("Number of records: {}\n", sector->records.size());
@@ -459,18 +462,17 @@ void FluxViewerControl::DisplayRawData(std::shared_ptr<const Sector> sector)
hexdump(s, record->rawData);
}
(new HexViewerWindow(this, s.str()))->Show(true);
HexViewerWindow::Create(this, title, s.str());
}
void FluxViewerControl::DisplayRawData(const Location& location, std::shared_ptr<const Record> record)
{
std::stringstream s;
s << fmt::format("Raw undecoded data for record c{}.h{} + {:.3f}ms\n",
location.physicalTrack, location.head, record->startTime / 1e6)
<< '\n';
auto title = fmt::format("Raw data for record c{}.h{} + {:.3f}ms",
location.physicalTrack, location.head, record->startTime / 1e6);
s << title << "\n\n";
hexdump(s, record->rawData);
(new HexViewerWindow(this, s.str()))->Show(true);
HexViewerWindow::Create(this, title, s.str());
}

View File

@@ -41,15 +41,15 @@ private:
private:
wxScrollBar* _scrollbar;
std::shared_ptr<const TrackFlux> _flux;
nanoseconds_t _scrollPosition;
nanoseconds_t _totalDuration;
double _nanosecondsPerPixel;
nanoseconds_t _scrollPosition = 0;
nanoseconds_t _totalDuration = 0;
double _nanosecondsPerPixel = 0;
std::vector<float> _densityMap;
int _dragStartX;
nanoseconds_t _dragStartPosition;
int _mouseX;
int _mouseY;
bool _rightClicked;
int _dragStartX = -1;
nanoseconds_t _dragStartPosition = -1;
int _mouseX = -1;
int _mouseY = -1;
bool _rightClicked = false;
wxDECLARE_EVENT_TABLE();
};

View File

@@ -3,6 +3,8 @@
#include "layout.h"
#include "fluxviewerwindow.h"
#include "fluxviewercontrol.h"
#include "lib/flux.h"
#include "fmt/format.h"
FluxViewerWindow::FluxViewerWindow(wxWindow* parent, std::shared_ptr<const TrackFlux> flux):
FluxViewerWindowGen(parent),
@@ -10,6 +12,9 @@ FluxViewerWindow::FluxViewerWindow(wxWindow* parent, std::shared_ptr<const Track
{
fluxviewer->SetScrollbar(scrollbar);
fluxviewer->SetFlux(flux);
SetTitle(
fmt::format("Flux for c{} h{}",
flux->location.physicalTrack, flux->location.head));
}
void FluxViewerWindow::OnExit(wxCommandEvent& event)

View File

@@ -4,14 +4,21 @@
#include "hexviewerwindow.h"
#include "fmt/format.h"
HexViewerWindow::HexViewerWindow(wxWindow* parent, const std::string& text):
HexViewerWindow::HexViewerWindow(wxWindow* parent,
const std::string& title, const std::string& text):
HexViewerWindowGen(parent)
{
auto size = hexEntry->GetTextExtent("M");
SetSize(size.Scale(85, 25));
SetTitle(title);
hexEntry->SetValue(text);
}
void HexViewerWindow::Create(wxWindow* parent, const std::string& title, const std::string& text)
{
(new HexViewerWindow(parent, title, text))->Show(true);
}
void HexViewerWindow::OnExit(wxCommandEvent& event)
{
Close(true);

View File

@@ -6,7 +6,9 @@
class HexViewerWindow : public HexViewerWindowGen
{
public:
HexViewerWindow(wxWindow* parent, const std::string& text);
HexViewerWindow(wxWindow* parent, const std::string& title, const std::string& text);
static void Create(wxWindow* parent, const std::string& title, const std::string& text);
private:
void OnExit(wxCommandEvent& event);