Misc fixes to colour dropper.

Originally committed to SVN as r1361.
This commit is contained in:
Niels Martin Hansen 2007-07-04 23:47:20 +00:00
parent 6087d6ec22
commit 964e3b3c8e
2 changed files with 18 additions and 19 deletions

View file

@ -485,7 +485,7 @@ DialogColorPicker::DialogColorPicker(wxWindow *parent, wxColour initial_color)
eyedropper_bitmap = wxBITMAP(eyedropper_tool); eyedropper_bitmap = wxBITMAP(eyedropper_tool);
eyedropper_bitmap.SetMask(new wxMask(eyedropper_bitmap, wxColour(255, 0, 255))); eyedropper_bitmap.SetMask(new wxMask(eyedropper_bitmap, wxColour(255, 0, 255)));
screen_dropper_icon = new wxStaticBitmap(this, SELECTOR_DROPPER, eyedropper_bitmap); screen_dropper_icon = new wxStaticBitmap(this, SELECTOR_DROPPER, eyedropper_bitmap, wxDefaultPosition, wxDefaultSize, wxRAISED_BORDER);
screen_dropper = new ColorPickerScreenDropper(this, SELECTOR_DROPPER_PICK, 7, 7, 8, false); screen_dropper = new ColorPickerScreenDropper(this, SELECTOR_DROPPER_PICK, 7, 7, 8, false);
// Arrange the controls in a nice way // Arrange the controls in a nice way
@ -1139,32 +1139,30 @@ void DialogColorPicker::OnRecentSelect(wxCommandEvent &evt)
void DialogColorPicker::OnDropperMouse(wxMouseEvent &evt) void DialogColorPicker::OnDropperMouse(wxMouseEvent &evt)
{ {
if (evt.LeftDown()) { if (evt.LeftDown() && !screen_dropper_icon->HasCapture()) {
if (screen_dropper_icon->HasCapture()) { screen_dropper_icon->CaptureMouse();
release_capture: eyedropper_grab_point = evt.GetPosition();
screen_dropper_icon->ReleaseMouse(); eyedropper_is_grabbed = false;
screen_dropper_icon->SetCursor(wxNullCursor);
screen_dropper_icon->SetBitmap(eyedropper_bitmap);
return;
} else {
screen_dropper_icon->CaptureMouse();
eyedropper_grab_point = evt.GetPosition();
#ifdef WIN32 #ifdef WIN32
screen_dropper_icon->SetCursor(wxCursor(_T("eyedropper_cursor"))); screen_dropper_icon->SetCursor(wxCursor(_T("eyedropper_cursor")));
#else #else
screen_dropper_icon->SetCursor(*wxCROSS_CURSOR); screen_dropper_icon->SetCursor(*wxCROSS_CURSOR);
#endif #endif
screen_dropper_icon->SetBitmap(wxNullBitmap); screen_dropper_icon->SetBitmap(wxNullBitmap);
}
} }
if (evt.LeftUp()) { if (evt.LeftUp()) {
#define ABS(x) (x < 0 ? -x : x) #define ABS(x) (x < 0 ? -x : x)
wxPoint ptdiff = evt.GetPosition() - eyedropper_grab_point; wxPoint ptdiff = evt.GetPosition() - eyedropper_grab_point;
if (ABS(ptdiff.x) + ABS(ptdiff.y) > 7) bool release_now = eyedropper_is_grabbed || ABS(ptdiff.x) + ABS(ptdiff.y) > 7;
goto release_capture; if (release_now) {
// test failed, didn't move enough distance to "drag-grab" the tool screen_dropper_icon->ReleaseMouse();
// treat this as a click eyedropper_is_grabbed = false;
screen_dropper_icon->SetCursor(wxNullCursor);
screen_dropper_icon->SetBitmap(eyedropper_bitmap);
} else {
eyedropper_is_grabbed = true;
}
} }
if (screen_dropper_icon->HasCapture()) { if (screen_dropper_icon->HasCapture()) {

View file

@ -151,6 +151,7 @@ private:
wxBitmap eyedropper_bitmap; wxBitmap eyedropper_bitmap;
wxPoint eyedropper_grab_point; wxPoint eyedropper_grab_point;
bool eyedropper_is_grabbed;
wxTextCtrl *ass_input; // ASS hex format input wxTextCtrl *ass_input; // ASS hex format input
wxTextCtrl *html_input; // HTML hex format input wxTextCtrl *html_input; // HTML hex format input