- Add option to stick Magnify to a certain coordinate.

- Keep updating on this area
- Fixes #2831



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28272 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Maurice Kalinowski
2008-10-21 21:37:31 +00:00
parent d4dcbf95f6
commit 65b27c0e43
2 changed files with 26 additions and 3 deletions
+22 -3
View File
@@ -49,6 +49,7 @@ const int32 msg_toggle_ruler = 'rulr';
const int32 msg_copy_image = 'copy';
const int32 msg_track_color = 'trak';
const int32 msg_freeze = 'frez';
const int32 msg_stick = 'stic';
const int32 msg_dump = 'dump';
const int32 msg_add_cross_hair = 'acrs';
const int32 msg_remove_cross_hair = 'rcrs';
@@ -165,6 +166,8 @@ BuildInfoMenu(BMenu *menu)
menuItem = new BMenuItem("Freeze/Unfreeze image", new BMessage(msg_freeze),'F');
menu->AddItem(menuItem);
menuItem = new BMenuItem("Stick Coordinates", new BMessage(msg_stick), 'I');
menu->AddItem(menuItem);
menu->AddSeparatorItem();
menuItem = new BMenuItem("Make Square", new BMessage(msg_make_square),'/');
@@ -258,6 +261,7 @@ TWindow::TWindow(int32 pixelCount)
AddShortcut('H', B_SHIFT_KEY, new BMessage(msg_remove_cross_hair));
AddShortcut('G', B_COMMAND_KEY, new BMessage(msg_toggle_grid));
AddShortcut('F', B_COMMAND_KEY, new BMessage(msg_freeze));
AddShortcut('I', B_COMMAND_KEY, new BMessage(msg_stick));
AddShortcut('-', B_COMMAND_KEY, new BMessage(msg_shrink));
AddShortcut('=', B_COMMAND_KEY, new BMessage(msg_grow));
AddShortcut('/', B_COMMAND_KEY, new BMessage(msg_make_square));
@@ -339,6 +343,10 @@ TWindow::MessageReceived(BMessage* m)
fFatBits->MakeActive(!fFatBits->Active());
break;
case msg_stick:
fFatBits->MakeSticked(!fFatBits->Sticked());
break;
case msg_save: {
// freeze the image here, unfreeze after dump or cancel
fFatBits->StartSave();
@@ -1068,7 +1076,8 @@ TMagnify::TMagnify(BRect r, TWindow* parent)
fCrossHair1(-1, -1),
fShowCrossHair2(false),
fCrossHair2(-1, -1),
fParent(parent)
fParent(parent),
fStickCoordinates(false)
{
SetViewColor(B_TRANSPARENT_32_BIT);
}
@@ -1482,9 +1491,12 @@ TMagnify::Update(bool force)
ulong button;
static long counter = 0;
GetMouse(&loc, &button);
if (!fStickCoordinates) {
GetMouse(&loc, &button);
ConvertToScreen(&loc);
} else
loc = fLastLoc;
ConvertToScreen(&loc);
if (force || fLastLoc != loc || counter++ % 35 == 0) {
if (fImageView->CreateImage(loc, force))
Invalidate();
@@ -1609,6 +1621,13 @@ TMagnify::MakeActive(bool s)
}
void
TMagnify::MakeSticked(bool s)
{
fStickCoordinates = s;
}
void
TMagnify::PixelCount(int32* width, int32* height)
{
+4
View File
@@ -100,6 +100,9 @@ class TMagnify : public BView {
void MakeActive(bool);
bool Active() { return fActive; }
void MakeSticked(bool);
bool Sticked() const { return fStickCoordinates; }
void AddCrossHair();
void RemoveCrossHair();
void SetCrossHairsShowing(bool ch1=false, bool ch2=false);
@@ -138,6 +141,7 @@ class TMagnify : public BView {
TWindow* fParent;
bool fImageFrozenOnSave;
bool fStickCoordinates;
};
class TMenu : public BMenu {