When having set/removed a value or hint, you can duplicate that action (or

remove the hint for that value) by dragging the mouse over other fields with
the mouse button held.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22937 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2007-11-17 14:15:31 +00:00
parent 5524595645
commit 91adcde60f
2 changed files with 30 additions and 4 deletions

View File

@ -437,7 +437,7 @@ SudokuView::MouseDown(BPoint where)
if (clicks == 2 && fLastHintValue == value && fLastField == field
|| (buttons & (B_SECONDARY_MOUSE_BUTTON
| B_TERTIARY_MOUSE_BUTTON)) != 0) {
// double click
// double click or other buttons set a value
if ((fField->FlagsAt(x, y) & kInitialValue) == 0) {
if (fField->ValueAt(x, y) > 0) {
fField->SetValueAt(x, y, 0);
@ -449,16 +449,22 @@ SudokuView::MouseDown(BPoint where)
}
_InvalidateField(x, y);
// allow dragging to remove the hint from other fields
fLastHintValueSet = false;
fLastHintValue = value;
}
return;
}
uint32 hintMask = fField->HintMaskAt(x, y);
uint32 valueMask = 1UL << value;
if (hintMask & valueMask)
hintMask &= ~valueMask;
else
fLastHintValueSet = (hintMask & valueMask) == 0;
if (fLastHintValueSet)
hintMask |= valueMask;
else
hintMask &= ~valueMask;
fField->SetHintMaskAt(x, y, hintMask);
_InvalidateHintField(x, y, hintX, hintY);
@ -493,6 +499,25 @@ SudokuView::MouseMoved(BPoint where, uint32 transit,
if (fShowHintX == x && fShowHintY == y)
return;
int32 buttons = 0;
if (Looper() != NULL && Looper()->CurrentMessage() != NULL)
Looper()->CurrentMessage()->FindInt32("buttons", &buttons);
uint32 field = x + y * fField->Size();
if (buttons != 0 && field != fLastField) {
// if a button is pressed, we drag the last hint selection
// (either set or removal) to the field under the mouse
uint32 hintMask = fField->HintMaskAt(x, y);
uint32 valueMask = 1UL << fLastHintValue;
if (fLastHintValueSet)
hintMask |= valueMask;
else
hintMask &= ~valueMask;
fField->SetHintMaskAt(x, y, hintMask);
}
_RemoveHint();
fShowHintX = x;
fShowHintY = y;

View File

@ -85,6 +85,7 @@ private:
float fHintHeight, fHintWidth, fHintBaseline;
uint32 fShowHintX, fShowHintY;
uint32 fLastHintValue;
bool fLastHintValueSet;
uint32 fLastField;
uint32 fKeyboardX, fKeyboardY;
uint32 fHintFlags;