diff --git a/src/gui/fluxviewercontrol.cc b/src/gui/fluxviewercontrol.cc index 75efa72f..82de04a9 100644 --- a/src/gui/fluxviewercontrol.cc +++ b/src/gui/fluxviewercontrol.cc @@ -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 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 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 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 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()); } diff --git a/src/gui/fluxviewercontrol.h b/src/gui/fluxviewercontrol.h index a997d147..a4db62fb 100644 --- a/src/gui/fluxviewercontrol.h +++ b/src/gui/fluxviewercontrol.h @@ -41,15 +41,15 @@ private: private: wxScrollBar* _scrollbar; std::shared_ptr _flux; - nanoseconds_t _scrollPosition; - nanoseconds_t _totalDuration; - double _nanosecondsPerPixel; + nanoseconds_t _scrollPosition = 0; + nanoseconds_t _totalDuration = 0; + double _nanosecondsPerPixel = 0; std::vector _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(); }; diff --git a/src/gui/fluxviewerwindow.cc b/src/gui/fluxviewerwindow.cc index b7ccad84..f9e9ce6b 100644 --- a/src/gui/fluxviewerwindow.cc +++ b/src/gui/fluxviewerwindow.cc @@ -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 flux): FluxViewerWindowGen(parent), @@ -10,6 +12,9 @@ FluxViewerWindow::FluxViewerWindow(wxWindow* parent, std::shared_ptrSetScrollbar(scrollbar); fluxviewer->SetFlux(flux); + SetTitle( + fmt::format("Flux for c{} h{}", + flux->location.physicalTrack, flux->location.head)); } void FluxViewerWindow::OnExit(wxCommandEvent& event) diff --git a/src/gui/hexviewerwindow.cc b/src/gui/hexviewerwindow.cc index b79ebfe1..d5df0ce5 100644 --- a/src/gui/hexviewerwindow.cc +++ b/src/gui/hexviewerwindow.cc @@ -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); diff --git a/src/gui/hexviewerwindow.h b/src/gui/hexviewerwindow.h index 43369d55..dcf6030b 100644 --- a/src/gui/hexviewerwindow.h +++ b/src/gui/hexviewerwindow.h @@ -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);