* cleanup
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27956 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -71,7 +71,7 @@ class PopUpMenu : public BPopUpMenu {
|
|||||||
#define SHOW_IMAGE_ORIENTATION_ATTRIBUTE "ShowImage:orientation"
|
#define SHOW_IMAGE_ORIENTATION_ATTRIBUTE "ShowImage:orientation"
|
||||||
const rgb_color kBorderColor = { 0, 0, 0, 255 };
|
const rgb_color kBorderColor = { 0, 0, 0, 255 };
|
||||||
|
|
||||||
enum ShowImageView::image_orientation
|
enum ShowImageView::image_orientation
|
||||||
ShowImageView::fTransformation[ImageProcessor::kNumberOfAffineTransformations][kNumberOfOrientations] = {
|
ShowImageView::fTransformation[ImageProcessor::kNumberOfAffineTransformations][kNumberOfOrientations] = {
|
||||||
// rotate 90°
|
// rotate 90°
|
||||||
{k90, k180, k270, k0, k270V, k0V, k90V, k0H},
|
{k90, k180, k270, k0, k270V, k0V, k90V, k0H},
|
||||||
@@ -181,7 +181,7 @@ ShowImageView::ShowImageView(BRect rect, const char *name, uint32 resizingMode,
|
|||||||
{
|
{
|
||||||
ShowImageSettings* settings;
|
ShowImageSettings* settings;
|
||||||
settings = my_app->Settings();
|
settings = my_app->Settings();
|
||||||
|
|
||||||
InitPatterns();
|
InitPatterns();
|
||||||
fDither = BScreen().ColorSpace() == B_CMAP8;
|
fDither = BScreen().ColorSpace() == B_CMAP8;
|
||||||
fBitmap = NULL;
|
fBitmap = NULL;
|
||||||
@@ -231,7 +231,7 @@ ShowImageView::~ShowImageView()
|
|||||||
|
|
||||||
|
|
||||||
//! Use patterns to simulate marching ants for selection
|
//! Use patterns to simulate marching ants for selection
|
||||||
void
|
void
|
||||||
ShowImageView::InitPatterns()
|
ShowImageView::InitPatterns()
|
||||||
{
|
{
|
||||||
uchar p;
|
uchar p;
|
||||||
@@ -257,21 +257,21 @@ ShowImageView::RotatePatterns()
|
|||||||
int i;
|
int i;
|
||||||
uchar p;
|
uchar p;
|
||||||
bool set;
|
bool set;
|
||||||
|
|
||||||
// rotate up
|
// rotate up
|
||||||
p = fPatternUp.data[0];
|
p = fPatternUp.data[0];
|
||||||
for (i = 0; i <= 6; i ++) {
|
for (i = 0; i <= 6; i ++) {
|
||||||
fPatternUp.data[i] = fPatternUp.data[i+1];
|
fPatternUp.data[i] = fPatternUp.data[i+1];
|
||||||
}
|
}
|
||||||
fPatternUp.data[7] = p;
|
fPatternUp.data[7] = p;
|
||||||
|
|
||||||
// rotate down
|
// rotate down
|
||||||
p = fPatternDown.data[7];
|
p = fPatternDown.data[7];
|
||||||
for (i = 7; i >= 1; i --) {
|
for (i = 7; i >= 1; i --) {
|
||||||
fPatternDown.data[i] = fPatternDown.data[i-1];
|
fPatternDown.data[i] = fPatternDown.data[i-1];
|
||||||
}
|
}
|
||||||
fPatternDown.data[0] = p;
|
fPatternDown.data[0] = p;
|
||||||
|
|
||||||
// rotate to left
|
// rotate to left
|
||||||
p = fPatternLeft.data[0];
|
p = fPatternLeft.data[0];
|
||||||
set = (p & 0x80) != 0;
|
set = (p & 0x80) != 0;
|
||||||
@@ -279,7 +279,7 @@ ShowImageView::RotatePatterns()
|
|||||||
p &= 0xfe;
|
p &= 0xfe;
|
||||||
if (set) p |= 1;
|
if (set) p |= 1;
|
||||||
memset(fPatternLeft.data, p, 8);
|
memset(fPatternLeft.data, p, 8);
|
||||||
|
|
||||||
// rotate to right
|
// rotate to right
|
||||||
p = fPatternRight.data[0];
|
p = fPatternRight.data[0];
|
||||||
set = (p & 1) != 0;
|
set = (p & 1) != 0;
|
||||||
@@ -300,7 +300,7 @@ void
|
|||||||
ShowImageView::Pulse()
|
ShowImageView::Pulse()
|
||||||
{
|
{
|
||||||
// animate marching ants
|
// animate marching ants
|
||||||
if (HasSelection() && fAnimateSelection && fIsActiveWin) {
|
if (HasSelection() && fAnimateSelection && fIsActiveWin) {
|
||||||
RotatePatterns();
|
RotatePatterns();
|
||||||
DrawSelectionBox();
|
DrawSelectionBox();
|
||||||
}
|
}
|
||||||
@@ -331,7 +331,7 @@ ShowImageView::Pulse()
|
|||||||
fScalingCountDown --;
|
fScalingCountDown --;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -348,7 +348,7 @@ ShowImageView::IsImage(const entry_ref *ref)
|
|||||||
BTranslatorRoster *roster = BTranslatorRoster::Default();
|
BTranslatorRoster *roster = BTranslatorRoster::Default();
|
||||||
if (!roster)
|
if (!roster)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
BMessage ioExtension;
|
BMessage ioExtension;
|
||||||
if (ioExtension.AddInt32("/documentIndex", fDocumentIndex) != B_OK)
|
if (ioExtension.AddInt32("/documentIndex", fDocumentIndex) != B_OK)
|
||||||
return false;
|
return false;
|
||||||
@@ -358,7 +358,7 @@ ShowImageView::IsImage(const entry_ref *ref)
|
|||||||
if (roster->Identify(&file, &ioExtension, &info, 0, NULL,
|
if (roster->Identify(&file, &ioExtension, &info, 0, NULL,
|
||||||
B_TRANSLATOR_BITMAP) != B_OK)
|
B_TRANSLATOR_BITMAP) != B_OK)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,7 +387,7 @@ ShowImageView::SendMessageToWindow(uint32 code)
|
|||||||
|
|
||||||
|
|
||||||
//! send message to parent about new image
|
//! send message to parent about new image
|
||||||
void
|
void
|
||||||
ShowImageView::Notify()
|
ShowImageView::Notify()
|
||||||
{
|
{
|
||||||
BMessage msg(MSG_UPDATE_STATUS);
|
BMessage msg(MSG_UPDATE_STATUS);
|
||||||
@@ -404,7 +404,7 @@ ShowImageView::Notify()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageView::UpdateStatusText()
|
ShowImageView::UpdateStatusText()
|
||||||
{
|
{
|
||||||
BMessage msg(MSG_UPDATE_STATUS_TEXT);
|
BMessage msg(MSG_UPDATE_STATUS_TEXT);
|
||||||
@@ -417,7 +417,7 @@ ShowImageView::UpdateStatusText()
|
|||||||
fSelectionRect.Height()+1.0);
|
fSelectionRect.Height()+1.0);
|
||||||
status_to_send << size;
|
status_to_send << size;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.AddString("status", status_to_send.String());
|
msg.AddString("status", status_to_send.String());
|
||||||
SendMessageToWindow(&msg);
|
SendMessageToWindow(&msg);
|
||||||
}
|
}
|
||||||
@@ -520,7 +520,7 @@ ShowImageView::SetImage(const entry_ref *ref)
|
|||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
// Now that I've successfully loaded the new bitmap,
|
// Now that I've successfully loaded the new bitmap,
|
||||||
// I can be sure it is safe to delete the old one,
|
// I can be sure it is safe to delete the old one,
|
||||||
// and clear everything
|
// and clear everything
|
||||||
fUndo.Clear();
|
fUndo.Clear();
|
||||||
SetHasSelection(false);
|
SetHasSelection(false);
|
||||||
@@ -587,7 +587,7 @@ ShowImageView::SetImage(const entry_ref *ref)
|
|||||||
fDocumentCount = 1;
|
fDocumentCount = 1;
|
||||||
|
|
||||||
fImageType = info.name;
|
fImageType = info.name;
|
||||||
|
|
||||||
GetPath(&fCaption);
|
GetPath(&fCaption);
|
||||||
if (fDocumentCount > 1)
|
if (fDocumentCount > 1)
|
||||||
fCaption << ", " << fDocumentIndex << "/" << fDocumentCount;
|
fCaption << ", " << fDocumentIndex << "/" << fDocumentCount;
|
||||||
@@ -625,7 +625,7 @@ ShowImageView::SetSelection(const entry_ref *ref, BPoint point)
|
|||||||
BBitmap *newBitmap = NULL;
|
BBitmap *newBitmap = NULL;
|
||||||
if (outstream.DetachBitmap(&newBitmap) != B_OK)
|
if (outstream.DetachBitmap(&newBitmap) != B_OK)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
return PasteBitmap(newBitmap, point);
|
return PasteBitmap(newBitmap, point);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -641,7 +641,7 @@ ShowImageView::SetDither(bool dither)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageView::SetShowCaption(bool show)
|
ShowImageView::SetShowCaption(bool show)
|
||||||
{
|
{
|
||||||
if (fShowCaption != show) {
|
if (fShowCaption != show) {
|
||||||
@@ -764,7 +764,7 @@ ShowImageView::AlignBitmap()
|
|||||||
if (width == 0 || height == 0)
|
if (width == 0 || height == 0)
|
||||||
return rect;
|
return rect;
|
||||||
|
|
||||||
fShrinkOrZoomToBounds = (fShrinkToBounds &&
|
fShrinkOrZoomToBounds = (fShrinkToBounds &&
|
||||||
(bitmapWidth >= width || bitmapHeight >= height)) ||
|
(bitmapWidth >= width || bitmapHeight >= height)) ||
|
||||||
(fZoomToBounds && (bitmapWidth < width && bitmapHeight < height));
|
(fZoomToBounds && (bitmapWidth < width && bitmapHeight < height));
|
||||||
if (fShrinkOrZoomToBounds) {
|
if (fShrinkOrZoomToBounds) {
|
||||||
@@ -784,7 +784,7 @@ ShowImageView::AlignBitmap()
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// zoom image
|
// zoom image
|
||||||
rect.right = floorf(bitmapWidth * fZoom) - 1;
|
rect.right = floorf(bitmapWidth * fZoom) - 1;
|
||||||
rect.bottom = floorf(bitmapHeight * fZoom) - 1;
|
rect.bottom = floorf(bitmapHeight * fZoom) - 1;
|
||||||
|
|
||||||
// update the bitmap size after the zoom
|
// update the bitmap size after the zoom
|
||||||
@@ -885,7 +885,7 @@ ShowImageView::DrawCaption()
|
|||||||
BFont font;
|
BFont font;
|
||||||
BPoint position;
|
BPoint position;
|
||||||
BRect rect;
|
BRect rect;
|
||||||
LayoutCaption(font, position, rect);
|
LayoutCaption(font, position, rect);
|
||||||
|
|
||||||
PushState();
|
PushState();
|
||||||
|
|
||||||
@@ -911,7 +911,7 @@ ShowImageView::UpdateCaption()
|
|||||||
BFont font;
|
BFont font;
|
||||||
BPoint pos;
|
BPoint pos;
|
||||||
BRect rect;
|
BRect rect;
|
||||||
LayoutCaption(font, pos, rect);
|
LayoutCaption(font, pos, rect);
|
||||||
|
|
||||||
// draw over portion of image where caption is located
|
// draw over portion of image where caption is located
|
||||||
BRegion clip(rect);
|
BRegion clip(rect);
|
||||||
@@ -1047,7 +1047,7 @@ ShowImageView::ConstrainToImage(BRect &rect)
|
|||||||
|
|
||||||
BBitmap*
|
BBitmap*
|
||||||
ShowImageView::CopyFromRect(BRect srcRect)
|
ShowImageView::CopyFromRect(BRect srcRect)
|
||||||
{
|
{
|
||||||
BRect rect(0, 0, srcRect.Width(), srcRect.Height());
|
BRect rect(0, 0, srcRect.Width(), srcRect.Height());
|
||||||
BView view(rect, NULL, B_FOLLOW_NONE, B_WILL_DRAW);
|
BView view(rect, NULL, B_FOLLOW_NONE, B_WILL_DRAW);
|
||||||
BBitmap *bitmap = new(nothrow) BBitmap(rect, fBitmap->ColorSpace(), true);
|
BBitmap *bitmap = new(nothrow) BBitmap(rect, fBitmap->ColorSpace(), true);
|
||||||
@@ -1079,7 +1079,7 @@ ShowImageView::CopySelection(uchar alpha, bool imageSize)
|
|||||||
BRect rect(0, 0, fSelectionRect.Width(), fSelectionRect.Height());
|
BRect rect(0, 0, fSelectionRect.Width(), fSelectionRect.Height());
|
||||||
if (!imageSize) {
|
if (!imageSize) {
|
||||||
// scale image to view size
|
// scale image to view size
|
||||||
rect.right = floorf((rect.right + 1.0) * fZoom - 1.0);
|
rect.right = floorf((rect.right + 1.0) * fZoom - 1.0);
|
||||||
rect.bottom = floorf((rect.bottom + 1.0) * fZoom - 1.0);
|
rect.bottom = floorf((rect.bottom + 1.0) * fZoom - 1.0);
|
||||||
}
|
}
|
||||||
BView view(rect, NULL, B_FOLLOW_NONE, B_WILL_DRAW);
|
BView view(rect, NULL, B_FOLLOW_NONE, B_WILL_DRAW);
|
||||||
@@ -1120,7 +1120,7 @@ ShowImageView::AddSupportedTypes(BMessage* msg, BBitmap* bitmap)
|
|||||||
|
|
||||||
translator_info *outInfo;
|
translator_info *outInfo;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
int32 outNumInfo;
|
int32 outNumInfo;
|
||||||
if (roster->GetTranslators(&stream, NULL, &outInfo, &outNumInfo) == B_OK) {
|
if (roster->GetTranslators(&stream, NULL, &outInfo, &outNumInfo) == B_OK) {
|
||||||
for (int32 i = 0; i < outNumInfo; i++) {
|
for (int32 i = 0; i < outNumInfo; i++) {
|
||||||
const translation_format *fmts;
|
const translation_format *fmts;
|
||||||
@@ -1129,8 +1129,8 @@ ShowImageView::AddSupportedTypes(BMessage* msg, BBitmap* bitmap)
|
|||||||
for (int32 j = 0; j < num_fmts; j++) {
|
for (int32 j = 0; j < num_fmts; j++) {
|
||||||
if (strcmp(fmts[j].MIME, "image/x-be-bitmap") != 0) {
|
if (strcmp(fmts[j].MIME, "image/x-be-bitmap") != 0) {
|
||||||
// needed to send data in message
|
// needed to send data in message
|
||||||
msg->AddString("be:types", fmts[j].MIME);
|
msg->AddString("be:types", fmts[j].MIME);
|
||||||
// needed to pass data via file
|
// needed to pass data via file
|
||||||
msg->AddString("be:filetypes", fmts[j].MIME);
|
msg->AddString("be:filetypes", fmts[j].MIME);
|
||||||
msg->AddString("be:type_descriptions", fmts[j].name);
|
msg->AddString("be:type_descriptions", fmts[j].name);
|
||||||
}
|
}
|
||||||
@@ -1156,7 +1156,7 @@ ShowImageView::BeginDrag(BPoint sourcePoint)
|
|||||||
// fill the drag message
|
// fill the drag message
|
||||||
BMessage drag(B_SIMPLE_DATA);
|
BMessage drag(B_SIMPLE_DATA);
|
||||||
drag.AddInt32("be:actions", B_COPY_TARGET);
|
drag.AddInt32("be:actions", B_COPY_TARGET);
|
||||||
drag.AddString("be:clip_name", "Bitmap Clip");
|
drag.AddString("be:clip_name", "Bitmap Clip");
|
||||||
// ShowImage specific fields
|
// ShowImage specific fields
|
||||||
drag.AddPoint("be:_source_point", sourcePoint);
|
drag.AddPoint("be:_source_point", sourcePoint);
|
||||||
drag.AddRect("be:_frame", fSelectionRect);
|
drag.AddRect("be:_frame", fSelectionRect);
|
||||||
@@ -1199,10 +1199,10 @@ ShowImageView::OutputFormatForType(BBitmap* bitmap, const char* type,
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
BBitmapStream stream(bitmap);
|
BBitmapStream stream(bitmap);
|
||||||
|
|
||||||
translator_info *outInfo;
|
translator_info *outInfo;
|
||||||
int32 outNumInfo;
|
int32 outNumInfo;
|
||||||
if (roster->GetTranslators(&stream, NULL, &outInfo, &outNumInfo) == B_OK) {
|
if (roster->GetTranslators(&stream, NULL, &outInfo, &outNumInfo) == B_OK) {
|
||||||
for (int32 i = 0; i < outNumInfo; i++) {
|
for (int32 i = 0; i < outNumInfo; i++) {
|
||||||
const translation_format *fmts;
|
const translation_format *fmts;
|
||||||
int32 num_fmts;
|
int32 num_fmts;
|
||||||
@@ -1210,7 +1210,7 @@ ShowImageView::OutputFormatForType(BBitmap* bitmap, const char* type,
|
|||||||
for (int32 j = 0; j < num_fmts; j++) {
|
for (int32 j = 0; j < num_fmts; j++) {
|
||||||
if (strcmp(fmts[j].MIME, type) == 0) {
|
if (strcmp(fmts[j].MIME, type) == 0) {
|
||||||
*format = fmts[j];
|
*format = fmts[j];
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1247,7 +1247,7 @@ ShowImageView::SaveToFile(BDirectory* dir, const char* name, BBitmap* bitmap,
|
|||||||
BNodeInfo info(&file);
|
BNodeInfo info(&file);
|
||||||
if (info.InitCheck() == B_OK)
|
if (info.InitCheck() == B_OK)
|
||||||
info.SetType(format->MIME);
|
info.SetType(format->MIME);
|
||||||
|
|
||||||
loop = false;
|
loop = false;
|
||||||
// break out of loop gracefully (indicates no errors)
|
// break out of loop gracefully (indicates no errors)
|
||||||
}
|
}
|
||||||
@@ -1343,9 +1343,9 @@ ShowImageView::GetMouseButtons()
|
|||||||
GetMouse(&point, &buttons);
|
GetMouse(&point, &buttons);
|
||||||
if (buttons == B_PRIMARY_MOUSE_BUTTON) {
|
if (buttons == B_PRIMARY_MOUSE_BUTTON) {
|
||||||
if ((modifiers() & B_CONTROL_KEY) != 0) {
|
if ((modifiers() & B_CONTROL_KEY) != 0) {
|
||||||
buttons = B_SECONDARY_MOUSE_BUTTON; // simulate second button
|
buttons = B_SECONDARY_MOUSE_BUTTON; // simulate second button
|
||||||
} else if ((modifiers() & B_SHIFT_KEY) != 0) {
|
} else if ((modifiers() & B_SHIFT_KEY) != 0) {
|
||||||
buttons = B_TERTIARY_MOUSE_BUTTON; // simulate third button
|
buttons = B_TERTIARY_MOUSE_BUTTON; // simulate third button
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return buttons;
|
return buttons;
|
||||||
@@ -1378,7 +1378,7 @@ ShowImageView::GetMergeRects(BBitmap *merge, BRect selection, BRect &srcBits,
|
|||||||
if (srcBits.bottom > fBitmap->Bounds().bottom)
|
if (srcBits.bottom > fBitmap->Bounds().bottom)
|
||||||
srcBits.bottom = srcBits.top + destRect.Height();
|
srcBits.bottom = srcBits.top + destRect.Height();
|
||||||
else
|
else
|
||||||
srcBits.bottom = merge->Bounds().bottom;
|
srcBits.bottom = merge->Bounds().bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1405,14 +1405,14 @@ ShowImageView::MergeWithBitmap(BBitmap *merge, BRect selection)
|
|||||||
BRect srcBits, destRect;
|
BRect srcBits, destRect;
|
||||||
GetMergeRects(merge, selection, srcBits, destRect);
|
GetMergeRects(merge, selection, srcBits, destRect);
|
||||||
view.DrawBitmap(merge, srcBits, destRect);
|
view.DrawBitmap(merge, srcBits, destRect);
|
||||||
|
|
||||||
view.Sync();
|
view.Sync();
|
||||||
bitmap->RemoveChild(&view);
|
bitmap->RemoveChild(&view);
|
||||||
bitmap->Unlock();
|
bitmap->Unlock();
|
||||||
|
|
||||||
DeleteBitmap();
|
DeleteBitmap();
|
||||||
fBitmap = bitmap;
|
fBitmap = bitmap;
|
||||||
|
|
||||||
SendMessageToWindow(MSG_MODIFIED);
|
SendMessageToWindow(MSG_MODIFIED);
|
||||||
} else
|
} else
|
||||||
delete bitmap;
|
delete bitmap;
|
||||||
@@ -1424,7 +1424,7 @@ ShowImageView::MergeSelection()
|
|||||||
{
|
{
|
||||||
if (!HasSelection())
|
if (!HasSelection())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!fSelBitmap) {
|
if (!fSelBitmap) {
|
||||||
// Even though the merge will not change
|
// Even though the merge will not change
|
||||||
// the background image, I still need to save
|
// the background image, I still need to save
|
||||||
@@ -1448,7 +1448,7 @@ ShowImageView::MouseDown(BPoint position)
|
|||||||
|
|
||||||
point = ViewToImage(position);
|
point = ViewToImage(position);
|
||||||
buttons = GetMouseButtons();
|
buttons = GetMouseButtons();
|
||||||
|
|
||||||
if (HasSelection() && fSelectionRect.Contains(point)
|
if (HasSelection() && fSelectionRect.Contains(point)
|
||||||
&& (buttons & (B_PRIMARY_MOUSE_BUTTON | B_SECONDARY_MOUSE_BUTTON))) {
|
&& (buttons & (B_PRIMARY_MOUSE_BUTTON | B_SECONDARY_MOUSE_BUTTON))) {
|
||||||
if (!fSelBitmap)
|
if (!fSelBitmap)
|
||||||
@@ -1456,11 +1456,11 @@ ShowImageView::MouseDown(BPoint position)
|
|||||||
|
|
||||||
BPoint sourcePoint = point;
|
BPoint sourcePoint = point;
|
||||||
BeginDrag(sourcePoint);
|
BeginDrag(sourcePoint);
|
||||||
|
|
||||||
while (buttons) {
|
while (buttons) {
|
||||||
// Keep reading mouse movement until
|
// Keep reading mouse movement until
|
||||||
// the user lets up on all mouse buttons
|
// the user lets up on all mouse buttons
|
||||||
GetMouse(&point, &buttons);
|
GetMouse(&point, &buttons);
|
||||||
snooze(25 * 1000);
|
snooze(25 * 1000);
|
||||||
// sleep for 25 milliseconds to minimize CPU usage during loop
|
// sleep for 25 milliseconds to minimize CPU usage during loop
|
||||||
}
|
}
|
||||||
@@ -1470,11 +1470,11 @@ ShowImageView::MouseDown(BPoint position)
|
|||||||
// (Some of the selection may be in the border area, which can be OK)
|
// (Some of the selection may be in the border area, which can be OK)
|
||||||
BPoint last, diff;
|
BPoint last, diff;
|
||||||
last = ViewToImage(point);
|
last = ViewToImage(point);
|
||||||
diff = last - sourcePoint;
|
diff = last - sourcePoint;
|
||||||
|
|
||||||
BRect newSelection = fSelectionRect;
|
BRect newSelection = fSelectionRect;
|
||||||
newSelection.OffsetBy(diff);
|
newSelection.OffsetBy(diff);
|
||||||
|
|
||||||
if (fBitmap->Bounds().Intersects(newSelection)) {
|
if (fBitmap->Bounds().Intersects(newSelection)) {
|
||||||
// Do not accept the new selection box location
|
// Do not accept the new selection box location
|
||||||
// if it does not intersect with the bitmap rectangle
|
// if it does not intersect with the bitmap rectangle
|
||||||
@@ -1486,7 +1486,7 @@ ShowImageView::MouseDown(BPoint position)
|
|||||||
AnimateSelection(true);
|
AnimateSelection(true);
|
||||||
} else if (buttons == B_PRIMARY_MOUSE_BUTTON) {
|
} else if (buttons == B_PRIMARY_MOUSE_BUTTON) {
|
||||||
MergeSelection();
|
MergeSelection();
|
||||||
// If there is an existing selection,
|
// If there is an existing selection,
|
||||||
// Make it part of the background image
|
// Make it part of the background image
|
||||||
|
|
||||||
// begin new selection
|
// begin new selection
|
||||||
@@ -1497,7 +1497,7 @@ ShowImageView::MouseDown(BPoint position)
|
|||||||
fFirstPoint = point;
|
fFirstPoint = point;
|
||||||
fCopyFromRect.Set(point.x, point.y, point.x, point.y);
|
fCopyFromRect.Set(point.x, point.y, point.x, point.y);
|
||||||
fSelectionRect = fCopyFromRect;
|
fSelectionRect = fCopyFromRect;
|
||||||
Invalidate();
|
Invalidate();
|
||||||
} else if (buttons == B_SECONDARY_MOUSE_BUTTON) {
|
} else if (buttons == B_SECONDARY_MOUSE_BUTTON) {
|
||||||
ShowPopUpMenu(ConvertToScreen(position));
|
ShowPopUpMenu(ConvertToScreen(position));
|
||||||
} else if (buttons == B_TERTIARY_MOUSE_BUTTON) {
|
} else if (buttons == B_TERTIARY_MOUSE_BUTTON) {
|
||||||
@@ -1641,16 +1641,16 @@ ShowImageView::KeyDown(const char* bytes, int32 numBytes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (*bytes) {
|
switch (*bytes) {
|
||||||
case B_DOWN_ARROW:
|
case B_DOWN_ARROW:
|
||||||
ScrollRestrictedBy(0, 10);
|
ScrollRestrictedBy(0, 10);
|
||||||
break;
|
break;
|
||||||
case B_UP_ARROW:
|
case B_UP_ARROW:
|
||||||
ScrollRestrictedBy(0, -10);
|
ScrollRestrictedBy(0, -10);
|
||||||
break;
|
break;
|
||||||
case B_LEFT_ARROW:
|
case B_LEFT_ARROW:
|
||||||
ScrollRestrictedBy(-10, 0);
|
ScrollRestrictedBy(-10, 0);
|
||||||
break;
|
break;
|
||||||
case B_RIGHT_ARROW:
|
case B_RIGHT_ARROW:
|
||||||
ScrollRestrictedBy(10, 0);
|
ScrollRestrictedBy(10, 0);
|
||||||
break;
|
break;
|
||||||
case B_ENTER:
|
case B_ENTER:
|
||||||
@@ -1685,7 +1685,7 @@ ShowImageView::KeyDown(const char* bytes, int32 numBytes)
|
|||||||
BMessenger tracker(kTrackerSignature);
|
BMessenger tracker(kTrackerSignature);
|
||||||
if (tracker.SendMessage(&trash) == B_OK)
|
if (tracker.SendMessage(&trash) == B_OK)
|
||||||
if (!NextFile()) {
|
if (!NextFile()) {
|
||||||
// This is the last (or only file) in this directory,
|
// This is the last (or only file) in this directory,
|
||||||
// close the window
|
// close the window
|
||||||
SendMessageToWindow(B_QUIT_REQUESTED);
|
SendMessageToWindow(B_QUIT_REQUESTED);
|
||||||
}
|
}
|
||||||
@@ -1698,7 +1698,7 @@ ShowImageView::KeyDown(const char* bytes, int32 numBytes)
|
|||||||
case '-':
|
case '-':
|
||||||
ZoomOut();
|
ZoomOut();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1713,7 +1713,7 @@ ShowImageView::MouseWheelChanged(BMessage *msg)
|
|||||||
const float kscrollBy = 40;
|
const float kscrollBy = 40;
|
||||||
float dy, dx;
|
float dy, dx;
|
||||||
float x, y;
|
float x, y;
|
||||||
x = 0; y = 0;
|
x = 0; y = 0;
|
||||||
if (msg->FindFloat("be:wheel_delta_x", &dx) == B_OK)
|
if (msg->FindFloat("be:wheel_delta_x", &dx) == B_OK)
|
||||||
x = dx * kscrollBy;
|
x = dx * kscrollBy;
|
||||||
if (msg->FindFloat("be:wheel_delta_y", &dy) == B_OK)
|
if (msg->FindFloat("be:wheel_delta_y", &dy) == B_OK)
|
||||||
@@ -1804,14 +1804,14 @@ ShowImageView::MessageReceived(BMessage *message)
|
|||||||
// adjust drop point before scaling is factored in
|
// adjust drop point before scaling is factored in
|
||||||
point = ConvertFromScreen(point);
|
point = ConvertFromScreen(point);
|
||||||
point = ViewToImage(point);
|
point = ViewToImage(point);
|
||||||
|
|
||||||
PasteBitmap(bitmap, point);
|
PasteBitmap(bitmap, point);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_COPY_TARGET:
|
case B_COPY_TARGET:
|
||||||
HandleDrop(message);
|
HandleDrop(message);
|
||||||
break;
|
break;
|
||||||
@@ -1837,7 +1837,7 @@ void
|
|||||||
ShowImageView::FixupScrollBar(orientation o, float bitmapLength, float viewLength)
|
ShowImageView::FixupScrollBar(orientation o, float bitmapLength, float viewLength)
|
||||||
{
|
{
|
||||||
float prop, range;
|
float prop, range;
|
||||||
BScrollBar *psb;
|
BScrollBar *psb;
|
||||||
|
|
||||||
psb = ScrollBar(o);
|
psb = ScrollBar(o);
|
||||||
if (psb) {
|
if (psb) {
|
||||||
@@ -1851,7 +1851,7 @@ ShowImageView::FixupScrollBar(orientation o, float bitmapLength, float viewLengt
|
|||||||
}
|
}
|
||||||
psb->SetRange(0, range);
|
psb->SetRange(0, range);
|
||||||
psb->SetProportion(prop);
|
psb->SetProportion(prop);
|
||||||
psb->SetSteps(10, 100);
|
psb->SetSteps(10, 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1864,7 +1864,7 @@ ShowImageView::FixupScrollBars()
|
|||||||
rctbitmap = AlignBitmap();
|
rctbitmap = AlignBitmap();
|
||||||
rctbitmap.OffsetTo(0, 0);
|
rctbitmap.OffsetTo(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
FixupScrollBar(B_HORIZONTAL, rctbitmap.Width() + 2 * PEN_SIZE, rctview.Width());
|
FixupScrollBar(B_HORIZONTAL, rctbitmap.Width() + 2 * PEN_SIZE, rctview.Width());
|
||||||
FixupScrollBar(B_VERTICAL, rctbitmap.Height() + 2 * PEN_SIZE, rctview.Height());
|
FixupScrollBar(B_VERTICAL, rctbitmap.Height() + 2 * PEN_SIZE, rctview.Height());
|
||||||
}
|
}
|
||||||
@@ -1890,13 +1890,13 @@ ShowImageView::Undo()
|
|||||||
int32 undoType = fUndo.GetType();
|
int32 undoType = fUndo.GetType();
|
||||||
if (undoType != UNDO_UNDO && undoType != UNDO_REDO)
|
if (undoType != UNDO_UNDO && undoType != UNDO_REDO)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// backup current selection
|
// backup current selection
|
||||||
BRect undoneSelRect;
|
BRect undoneSelRect;
|
||||||
BBitmap *undoneSelection;
|
BBitmap *undoneSelection;
|
||||||
undoneSelRect = fSelectionRect;
|
undoneSelRect = fSelectionRect;
|
||||||
undoneSelection = CopySelection();
|
undoneSelection = CopySelection();
|
||||||
|
|
||||||
if (undoType == UNDO_UNDO) {
|
if (undoType == UNDO_UNDO) {
|
||||||
BBitmap *undoRestore;
|
BBitmap *undoRestore;
|
||||||
undoRestore = fUndo.GetRestoreBitmap();
|
undoRestore = fUndo.GetRestoreBitmap();
|
||||||
@@ -1938,17 +1938,17 @@ ShowImageView::AddWhiteRect(BRect &rect)
|
|||||||
if (bitmap->Lock()) {
|
if (bitmap->Lock()) {
|
||||||
bitmap->AddChild(&view);
|
bitmap->AddChild(&view);
|
||||||
view.DrawBitmap(fBitmap, fBitmap->Bounds());
|
view.DrawBitmap(fBitmap, fBitmap->Bounds());
|
||||||
|
|
||||||
view.FillRect(rect, B_SOLID_LOW);
|
view.FillRect(rect, B_SOLID_LOW);
|
||||||
// draw white rect
|
// draw white rect
|
||||||
|
|
||||||
view.Sync();
|
view.Sync();
|
||||||
bitmap->RemoveChild(&view);
|
bitmap->RemoveChild(&view);
|
||||||
bitmap->Unlock();
|
bitmap->Unlock();
|
||||||
|
|
||||||
DeleteBitmap();
|
DeleteBitmap();
|
||||||
fBitmap = bitmap;
|
fBitmap = bitmap;
|
||||||
|
|
||||||
SendMessageToWindow(MSG_MODIFIED);
|
SendMessageToWindow(MSG_MODIFIED);
|
||||||
} else
|
} else
|
||||||
delete bitmap;
|
delete bitmap;
|
||||||
@@ -2010,20 +2010,20 @@ ShowImageView::PasteBitmap(BBitmap *bitmap, BPoint point)
|
|||||||
// but only if the resulting selection rectangle
|
// but only if the resulting selection rectangle
|
||||||
// intersects with the background bitmap rectangle
|
// intersects with the background bitmap rectangle
|
||||||
fSelectionRect = offsetRect;
|
fSelectionRect = offsetRect;
|
||||||
|
|
||||||
Invalidate();
|
Invalidate();
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageView::Paste()
|
ShowImageView::Paste()
|
||||||
{
|
{
|
||||||
if (be_clipboard->Lock()) {
|
if (be_clipboard->Lock()) {
|
||||||
BMessage *pclip;
|
BMessage *pclip;
|
||||||
if ((pclip = be_clipboard->Data()) != NULL) {
|
if ((pclip = be_clipboard->Data()) != NULL) {
|
||||||
BPoint point(0, 0);
|
BPoint point(0, 0);
|
||||||
@@ -2033,7 +2033,7 @@ ShowImageView::Paste()
|
|||||||
PasteBitmap(pbits, point);
|
PasteBitmap(pbits, point);
|
||||||
}
|
}
|
||||||
|
|
||||||
be_clipboard->Unlock();
|
be_clipboard->Unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2064,7 +2064,7 @@ ShowImageView::SetHasSelection(bool bHasSelection)
|
|||||||
fHasSelection = bHasSelection;
|
fHasSelection = bHasSelection;
|
||||||
|
|
||||||
UpdateStatusText();
|
UpdateStatusText();
|
||||||
|
|
||||||
BMessage msg(MSG_SELECTION);
|
BMessage msg(MSG_SELECTION);
|
||||||
msg.AddBool("has_selection", fHasSelection);
|
msg.AddBool("has_selection", fHasSelection);
|
||||||
SendMessageToWindow(&msg);
|
SendMessageToWindow(&msg);
|
||||||
@@ -2142,7 +2142,7 @@ ShowImageView::PrevPage()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
ShowImageView::CompareEntries(const void* a, const void* b)
|
ShowImageView::CompareEntries(const void* a, const void* b)
|
||||||
{
|
{
|
||||||
entry_ref *r1, *r2;
|
entry_ref *r1, *r2;
|
||||||
@@ -2168,13 +2168,13 @@ ShowImageView::FreeEntries(BList* entries)
|
|||||||
const int32 n = entries->CountItems();
|
const int32 n = entries->CountItems();
|
||||||
for (int32 i = 0; i < n; i ++) {
|
for (int32 i = 0; i < n; i ++) {
|
||||||
entry_ref* ref = (entry_ref*)entries->ItemAt(i);
|
entry_ref* ref = (entry_ref*)entries->ItemAt(i);
|
||||||
delete ref;
|
delete ref;
|
||||||
}
|
}
|
||||||
entries->MakeEmpty();
|
entries->MakeEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageView::SetTrackerSelectionToCurrent()
|
ShowImageView::SetTrackerSelectionToCurrent()
|
||||||
{
|
{
|
||||||
BMessage setsel(B_SET_PROPERTY);
|
BMessage setsel(B_SET_PROPERTY);
|
||||||
@@ -2207,15 +2207,15 @@ ShowImageView::FindNextImageByDir(entry_ref *in_current, entry_ref *out_image, b
|
|||||||
entries.AddItem(new entry_ref(entry));
|
entries.AddItem(new entry_ref(entry));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
entries.SortItems(CompareEntries);
|
entries.SortItems(CompareEntries);
|
||||||
|
|
||||||
cur = entries.IndexOf(in_current);
|
cur = entries.IndexOf(in_current);
|
||||||
ASSERT(cur >= 0);
|
ASSERT(cur >= 0);
|
||||||
|
|
||||||
// remove it so FreeEntries() does not delete it
|
// remove it so FreeEntries() does not delete it
|
||||||
entries.RemoveItem(in_current);
|
entries.RemoveItem(in_current);
|
||||||
|
|
||||||
if (next) {
|
if (next) {
|
||||||
// find the next image in the list
|
// find the next image in the list
|
||||||
if (rewind) cur = 0; // start with first
|
if (rewind) cur = 0; // start with first
|
||||||
@@ -2258,7 +2258,7 @@ ShowImageView::FindNextImage(entry_ref *in_current, entry_ref *ref, bool next, b
|
|||||||
// image is found.
|
// image is found.
|
||||||
//
|
//
|
||||||
entry_ref nextRef = *in_current;
|
entry_ref nextRef = *in_current;
|
||||||
bool foundRef = false;
|
bool foundRef = false;
|
||||||
while (!foundRef)
|
while (!foundRef)
|
||||||
{
|
{
|
||||||
BMessage request(B_GET_PROPERTY);
|
BMessage request(B_GET_PROPERTY);
|
||||||
@@ -2277,16 +2277,16 @@ ShowImageView::FindNextImage(entry_ref *in_current, entry_ref *ref, bool next, b
|
|||||||
else
|
else
|
||||||
spc.AddRef("data", &nextRef);
|
spc.AddRef("data", &nextRef);
|
||||||
request.AddSpecifier(&spc);
|
request.AddSpecifier(&spc);
|
||||||
|
|
||||||
BMessage reply;
|
BMessage reply;
|
||||||
if (fTrackerMessenger.SendMessage(&request, &reply) != B_OK)
|
if (fTrackerMessenger.SendMessage(&request, &reply) != B_OK)
|
||||||
return FindNextImageByDir(in_current, ref, next, rewind);;
|
return FindNextImageByDir(in_current, ref, next, rewind);;
|
||||||
if (reply.FindRef("result", &nextRef) != B_OK)
|
if (reply.FindRef("result", &nextRef) != B_OK)
|
||||||
return FindNextImageByDir(in_current, ref, next, rewind);;
|
return FindNextImageByDir(in_current, ref, next, rewind);;
|
||||||
|
|
||||||
if (IsImage(&nextRef))
|
if (IsImage(&nextRef))
|
||||||
foundRef = true;
|
foundRef = true;
|
||||||
|
|
||||||
rewind = false;
|
rewind = false;
|
||||||
// stop asking for the first ref in the directory
|
// stop asking for the first ref in the directory
|
||||||
}
|
}
|
||||||
@@ -2422,7 +2422,7 @@ ShowImageView::StopSlideShow()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageView::DoImageOperation(ImageProcessor::operation op, bool quiet)
|
ShowImageView::DoImageOperation(ImageProcessor::operation op, bool quiet)
|
||||||
{
|
{
|
||||||
BMessenger msgr;
|
BMessenger msgr;
|
||||||
ImageProcessor imageProcessor(op, fBitmap, msgr, 0);
|
ImageProcessor imageProcessor(op, fBitmap, msgr, 0);
|
||||||
@@ -2430,7 +2430,7 @@ ShowImageView::DoImageOperation(ImageProcessor::operation op, bool quiet)
|
|||||||
BBitmap* bm = imageProcessor.DetachBitmap();
|
BBitmap* bm = imageProcessor.DetachBitmap();
|
||||||
if (bm == NULL) {
|
if (bm == NULL) {
|
||||||
// operation failed
|
// operation failed
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// update orientation state
|
// update orientation state
|
||||||
@@ -2459,13 +2459,13 @@ ShowImageView::DoImageOperation(ImageProcessor::operation op, bool quiet)
|
|||||||
|
|
||||||
// set new bitmap
|
// set new bitmap
|
||||||
DeleteBitmap();
|
DeleteBitmap();
|
||||||
fBitmap = bm;
|
fBitmap = bm;
|
||||||
|
|
||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
// remove selection
|
// remove selection
|
||||||
SetHasSelection(false);
|
SetHasSelection(false);
|
||||||
Notify();
|
Notify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2490,7 +2490,7 @@ ShowImageView::Rotate(int degree)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageView::Flip(bool vertical)
|
ShowImageView::Flip(bool vertical)
|
||||||
{
|
{
|
||||||
if (vertical) {
|
if (vertical) {
|
||||||
UserDoImageOperation(ImageProcessor::kFlipLeftToRight);
|
UserDoImageOperation(ImageProcessor::kFlipLeftToRight);
|
||||||
@@ -2514,17 +2514,17 @@ ShowImageView::Invert()
|
|||||||
void
|
void
|
||||||
ShowImageView::ResizeImage(int w, int h)
|
ShowImageView::ResizeImage(int w, int h)
|
||||||
{
|
{
|
||||||
if (fBitmap == NULL || w < 1 || h < 1)
|
if (fBitmap == NULL || w < 1 || h < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Scaler scaler(fBitmap, BRect(0, 0, w-1, h-1), BMessenger(), 0, false);
|
Scaler scaler(fBitmap, BRect(0, 0, w-1, h-1), BMessenger(), 0, false);
|
||||||
scaler.Start(false);
|
scaler.Start(false);
|
||||||
BBitmap* scaled = scaler.DetachBitmap();
|
BBitmap* scaled = scaler.DetachBitmap();
|
||||||
if (scaled == NULL) {
|
if (scaled == NULL) {
|
||||||
// operation failed
|
// operation failed
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove selection
|
// remove selection
|
||||||
SetHasSelection(false);
|
SetHasSelection(false);
|
||||||
fUndo.Clear();
|
fUndo.Clear();
|
||||||
@@ -2591,7 +2591,7 @@ ShowImageView::SetIcon(bool clear, icon_size which)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set icon
|
// set icon
|
||||||
BNode node(&fCurrentRef);
|
BNode node(&fCurrentRef);
|
||||||
BNodeInfo info(&node);
|
BNodeInfo info(&node);
|
||||||
info.SetIcon(clear ? NULL : &icon, which);
|
info.SetIcon(clear ? NULL : &icon, which);
|
||||||
@@ -2621,7 +2621,7 @@ ShowImageView::ExitFullScreen()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageView::WindowActivated(bool active)
|
ShowImageView::WindowActivated(bool active)
|
||||||
{
|
{
|
||||||
fIsActiveWin = active;
|
fIsActiveWin = active;
|
||||||
|
|||||||
Reference in New Issue
Block a user