Neaten up foobars movement when dragged from different spots

This commit is contained in:
Mark Watkins 2011-06-09 00:35:56 +10:00
parent 65402ed566
commit 2b635d111c
4 changed files with 26 additions and 42 deletions

View File

@ -8300,11 +8300,11 @@
<map> <map>
"tinyxml/tinyxml.h" "tinyxml/tinyxml.h"
1307539764 /home/mark/projects/git/sleepyhead/src/graphs/graph.h 1307543245 /home/mark/projects/git/sleepyhead/src/graphs/graph.h
<sleeplib/machine.h> <sleeplib/machine.h>
<list> <list>
1307541836 /home/mark/projects/git/sleepyhead/src/version.h 1307543626 /home/mark/projects/git/sleepyhead/src/version.h
1307418393 /home/mark/projects/git/sleepyhead/src/libs/sleeplib/prs1_loader.h 1307418393 /home/mark/projects/git/sleepyhead/src/libs/sleeplib/prs1_loader.h
"machine.h" "machine.h"
@ -8341,7 +8341,7 @@
"sleeplib/profiles.h" "sleeplib/profiles.h"
"sleeplib/machine_loader.h" "sleeplib/machine_loader.h"
1307541170 source:/home/mark/projects/git/sleepyhead/src/graphs/graph.cpp 1307543431 source:/home/mark/projects/git/sleepyhead/src/graphs/graph.cpp
<wx/settings.h> <wx/settings.h>
<wx/dcbuffer.h> <wx/dcbuffer.h>
<wx/log.h> <wx/log.h>

View File

@ -140,7 +140,7 @@ gGraphWindow::gGraphWindow(wxWindow *parent, wxWindowID id,const wxString & titl
m_block_move=false; m_block_move=false;
m_block_zoom=false; m_block_zoom=false;
m_drag_foobar=false; m_drag_foobar=false;
m_foobar_pos=0;
} }
gGraphWindow::~gGraphWindow() gGraphWindow::~gGraphWindow()
{ {
@ -295,7 +295,10 @@ void gGraphWindow::OnMouseMove(wxMouseEvent &event)
// qx is centerpoint of new zoom area. // qx is centerpoint of new zoom area.
double dx=MaxX()-MinX(); // zoom rect width; double dx=MaxX()-MinX(); // zoom rect width;
double gx=dx/2.0;
// Could smarten this up by remembering where the mouse was clicked on the foobar
double gx=dx*m_foobar_pos;
qx-=gx; qx-=gx;
if (qx<rminx) qx=rminx; if (qx<rminx) qx=rminx;
@ -384,13 +387,12 @@ void gGraphWindow::OnMouseLeftDown(wxMouseEvent &event)
int width=m_scrX-GetRightMargin()-GetLeftMargin(); int width=m_scrX-GetRightMargin()-GetLeftMargin();
int height=m_scrY-GetBottomMargin()-GetTopMargin(); int height=m_scrY-GetBottomMargin()-GetTopMargin();
wxRect hot1(GetLeftMargin(),GetTopMargin(),width,height); // Graph data area. wxRect hot1(GetLeftMargin(),GetTopMargin(),width,height); // Graph data area.
// if (HasFoobar()) {
if (hot1.Contains(x,y)) { if (hot1.Contains(x,y)) {
m_mouseLClick.x = x; m_mouseLClick.x = x;
m_mouseLClick.y = y; m_mouseLClick.y = y;
m_mouseLDown=true; m_mouseLDown=true;
} else if ((y>(m_scrY-GetBottomMargin())+5) && (y<(m_scrY-GetBottomMargin())+15)) { } else if ((y>(m_scrY-GetBottomMargin())+5) && (y<(m_scrY-GetBottomMargin())+20)) {
double rx=RealMaxX()-RealMinX(); double rx=RealMaxX()-RealMinX();
double qx=double(width)/rx; double qx=double(width)/rx;
double minx=MinX()-RealMinX(); double minx=MinX()-RealMinX();
@ -398,11 +400,13 @@ void gGraphWindow::OnMouseLeftDown(wxMouseEvent &event)
int x1=(qx*minx); int x1=(qx*minx);
int x2=(qx*maxx); // length in pixels int x2=(qx*maxx); // length in pixels
int xw=x2-x1;
x1+=GetLeftMargin(); x1+=GetLeftMargin();
x2+=GetLeftMargin(); x2+=GetLeftMargin();
if ((x>x1) && (x<x2)) { if ((x>x1) && (x<x2)) {
x-=x1;
m_foobar_pos=(1.0/double(xw))*double(x); // where along the foobar the user clicked.
m_drag_foobar=true; m_drag_foobar=true;
// wxLogMessage("Foobar Area Pushed"); // wxLogMessage("Foobar Area Pushed");
} }
@ -413,30 +417,12 @@ void gGraphWindow::OnMouseLeftDown(wxMouseEvent &event)
} }
void gGraphWindow::OnMouseLeftRelease(wxMouseEvent &event) void gGraphWindow::OnMouseLeftRelease(wxMouseEvent &event)
{ {
int y=event.GetY(); /* int y=event.GetY();
int x=event.GetX(); int x=event.GetX();
int width=m_scrX-GetRightMargin()-GetLeftMargin(); int width=m_scrX-GetRightMargin()-GetLeftMargin();
int height=m_scrY-GetBottomMargin()-GetTopMargin(); int height=m_scrY-GetBottomMargin()-GetTopMargin();
wxRect hot1(GetLeftMargin(),GetTopMargin(),width,height); // Graph data area. wxRect hot1(GetLeftMargin(),GetTopMargin(),width,height); // Graph data area. */
/*double rx=RealMaxX()-RealMinX();
double qx=double(width)/rx;
double minx=MinX()-RealMinX();
double maxx=MaxX()-RealMinX();;
int x1=(qx*minx);
int x2=(qx*maxx); // length in pixels
x1+=GetLeftMargin();
x2+=GetLeftMargin();
if ((x>x1) && (x<x2)) {
// wxLogMessage("Foobar Area Pushed");
}
} */
if (m_drag_foobar) { if (m_drag_foobar) {
// wxLogMessage("Foobar Released"); // wxLogMessage("Foobar Released");
double min=MinX(); double min=MinX();
@ -446,17 +432,17 @@ void gGraphWindow::OnMouseLeftRelease(wxMouseEvent &event)
} }
m_drag_foobar=false; m_drag_foobar=false;
} else if (hot1.Contains(x,y)) { } else {
wxPoint release(event.GetX(), m_scrY-m_marginBottom); wxPoint release(event.GetX(), m_scrY-m_marginBottom);
wxPoint press(m_mouseLClick.x, m_marginTop); wxPoint press(m_mouseLClick.x, m_marginTop);
m_mouseLDown=false; //wxDateTime a,b;
wxDateTime a,b;
int x1=m_mouseRBrect.x; int x1=m_mouseRBrect.x;
int x2=x1+m_mouseRBrect.width; int x2=x1+m_mouseRBrect.width;
int t1=MIN(x1,x2); int t1=MIN(x1,x2);
int t2=MAX(x1,x2); int t2=MAX(x1,x2);
wxRect r; m_mouseLDown=false;
m_mouseRBrect=wxRect(0, 0, 0, 0);
if ((t2-t1)>3) { if ((t2-t1)>3) {
ZoomXPixels(t1,t2); ZoomXPixels(t1,t2);
} else { } else {
@ -470,11 +456,8 @@ void gGraphWindow::OnMouseLeftRelease(wxMouseEvent &event)
} }
} }
r=wxRect(0, 0, 0, 0);
m_mouseRBrect=r;
} }
event.Skip(); event.Skip();
} }

View File

@ -218,6 +218,7 @@ class gGraphWindow:public wxWindow // rename to gGraphWindow
bool m_block_move; bool m_block_move;
bool m_block_zoom; bool m_block_zoom;
bool m_drag_foobar; bool m_drag_foobar;
double m_foobar_pos;
std::list<gLayer *> layers; std::list<gLayer *> layers;
wxColour m_bgColour; //!< Background Colour wxColour m_bgColour; //!< Background Colour
wxColour m_fgColour; //!< Foreground Colour wxColour m_fgColour; //!< Foreground Colour

View File

@ -16,14 +16,14 @@ namespace AutoVersion{
//Standard Version Type //Standard Version Type
static const long MAJOR = 0; static const long MAJOR = 0;
static const long MINOR = 7; static const long MINOR = 7;
static const long BUILD = 3797; static const long BUILD = 3815;
static const long REVISION = 3939; static const long REVISION = 4044;
//Miscellaneous Version Types //Miscellaneous Version Types
static const long BUILDS_COUNT = 1739; static const long BUILDS_COUNT = 1780;
#define RC_FILEVERSION 0,7,3797,3939 #define RC_FILEVERSION 0,7,3815,4044
#define RC_FILEVERSION_STRING "0, 7, 3797, 3939\0" #define RC_FILEVERSION_STRING "0, 7, 3815, 4044\0"
static const char FULLVERSION_STRING[] = "0.7.3797.3939"; static const char FULLVERSION_STRING[] = "0.7.3815.4044";
//These values are to keep track of your versioning state, don't modify them. //These values are to keep track of your versioning state, don't modify them.
static const long BUILD_HISTORY = 0; static const long BUILD_HISTORY = 0;