* Fix can't cut and drag a piece of picture from ShowImage to Desktop, ticket #4874.
* Set the current image mime as first in the translators list, thus on drag&drop with left mouse button the same image type is created as the currently loaded in ShowImage. Still this does more hide than fix the real problem, beeing ICO translator the first in the generated translator list due to the high capabilitys values and a limited set of output sizes it can handle. I attached a further fix to the ticket, still i would like to get some other opinions on it before commiting. By default the transla git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35139 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -596,6 +596,7 @@ ShowImageView::SetImage(const entry_ref *ref)
|
|||||||
fDocumentCount = 1;
|
fDocumentCount = 1;
|
||||||
|
|
||||||
fImageType = info.name;
|
fImageType = info.name;
|
||||||
|
fImageMime = info.MIME;
|
||||||
|
|
||||||
GetPath(&fCaption);
|
GetPath(&fCaption);
|
||||||
if (fDocumentCount > 1)
|
if (fDocumentCount > 1)
|
||||||
@@ -1125,31 +1126,46 @@ ShowImageView::_AddSupportedTypes(BMessage* msg, BBitmap* bitmap)
|
|||||||
if (roster == NULL)
|
if (roster == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
BBitmapStream stream(bitmap);
|
// add the current image mime first, will make it the preferred format on
|
||||||
|
// left mouse drag
|
||||||
|
msg->AddString("be:types", fImageMime);
|
||||||
|
msg->AddString("be:filetypes", fImageMime);
|
||||||
|
msg->AddString("be:type_descriptions", fImageType);
|
||||||
|
|
||||||
translator_info *outInfo;
|
bool foundOther = false;
|
||||||
bool found = false;
|
bool foundCurrent = false;
|
||||||
int32 outNumInfo;
|
|
||||||
if (roster->GetTranslators(&stream, NULL, &outInfo, &outNumInfo) == B_OK) {
|
int32 infoCount;
|
||||||
for (int32 i = 0; i < outNumInfo; i++) {
|
translator_info* info;
|
||||||
const translation_format *fmts;
|
BBitmapStream stream(bitmap);
|
||||||
int32 num_fmts;
|
if (roster->GetTranslators(&stream, NULL, &info, &infoCount) == B_OK) {
|
||||||
roster->GetOutputFormats(outInfo[i].translator, &fmts, &num_fmts);
|
for (int32 i = 0; i < infoCount; i++) {
|
||||||
for (int32 j = 0; j < num_fmts; j++) {
|
const translation_format* formats;
|
||||||
if (strcmp(fmts[j].MIME, "image/x-be-bitmap") != 0) {
|
int32 count;
|
||||||
|
roster->GetOutputFormats(info[i].translator, &formats, &count);
|
||||||
|
for (int32 j = 0; j < count; j++) {
|
||||||
|
if (fImageMime == formats[j].MIME) {
|
||||||
|
foundCurrent = true;
|
||||||
|
} else if (strcmp(formats[j].MIME, "image/x-be-bitmap") != 0) {
|
||||||
|
foundOther = true;
|
||||||
// needed to send data in message
|
// needed to send data in message
|
||||||
msg->AddString("be:types", fmts[j].MIME);
|
msg->AddString("be:types", formats[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", formats[j].MIME);
|
||||||
msg->AddString("be:type_descriptions", fmts[j].name);
|
msg->AddString("be:type_descriptions", formats[j].name);
|
||||||
}
|
}
|
||||||
found = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stream.DetachBitmap(&bitmap);
|
stream.DetachBitmap(&bitmap);
|
||||||
|
|
||||||
return found;
|
if (!foundCurrent) {
|
||||||
|
msg->RemoveData("be:types", 0);
|
||||||
|
msg->RemoveData("be:filetypes", 0);
|
||||||
|
msg->RemoveData("be:type_descriptions", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return foundOther || foundCurrent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1174,8 +1190,10 @@ ShowImageView::_BeginDrag(BPoint sourcePoint)
|
|||||||
drag.AddString("be:types", B_FILE_MIME_TYPE);
|
drag.AddString("be:types", B_FILE_MIME_TYPE);
|
||||||
// avoid flickering of dragged bitmap caused by drawing into the window
|
// avoid flickering of dragged bitmap caused by drawing into the window
|
||||||
_AnimateSelection(false);
|
_AnimateSelection(false);
|
||||||
// only use a transparent bitmap on selections less than 400x400 (taking into account zooming)
|
// only use a transparent bitmap on selections less than 400x400
|
||||||
if ((fSelectionRect.Width() * fZoom) < 400.0 && (fSelectionRect.Height() * fZoom) < 400.0) {
|
// (taking into account zooming)
|
||||||
|
if ((fSelectionRect.Width() * fZoom) < 400.0
|
||||||
|
&& (fSelectionRect.Height() * fZoom) < 400.0) {
|
||||||
sourcePoint -= fSelectionRect.LeftTop();
|
sourcePoint -= fSelectionRect.LeftTop();
|
||||||
sourcePoint.x *= fZoom;
|
sourcePoint.x *= fZoom;
|
||||||
sourcePoint.y *= fZoom;
|
sourcePoint.y *= fZoom;
|
||||||
@@ -1288,20 +1306,16 @@ ShowImageView::_SendInMessage(BMessage* msg, BBitmap* bitmap, translation_format
|
|||||||
void
|
void
|
||||||
ShowImageView::_HandleDrop(BMessage* msg)
|
ShowImageView::_HandleDrop(BMessage* msg)
|
||||||
{
|
{
|
||||||
BMessage data(B_MIME_DATA);
|
|
||||||
entry_ref dirRef;
|
entry_ref dirRef;
|
||||||
BString name, type;
|
BString name, type;
|
||||||
bool saveToFile;
|
bool saveToFile = msg->FindString("be:filetypes", &type) == B_OK
|
||||||
bool sendInMessage;
|
|
||||||
BBitmap *bitmap;
|
|
||||||
|
|
||||||
saveToFile = msg->FindString("be:filetypes", &type) == B_OK
|
|
||||||
&& msg->FindRef("directory", &dirRef) == B_OK
|
&& msg->FindRef("directory", &dirRef) == B_OK
|
||||||
&& msg->FindString("name", &name) == B_OK;
|
&& msg->FindString("name", &name) == B_OK;
|
||||||
|
|
||||||
sendInMessage = (!saveToFile) && msg->FindString("be:types", &type) == B_OK;
|
bool sendInMessage = !saveToFile
|
||||||
|
&& msg->FindString("be:types", &type) == B_OK;
|
||||||
|
|
||||||
bitmap = _CopySelection();
|
BBitmap* bitmap = _CopySelection();
|
||||||
if (bitmap == NULL)
|
if (bitmap == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -242,6 +242,7 @@ class ShowImageView : public BView {
|
|||||||
BString fCaption; // caption text
|
BString fCaption; // caption text
|
||||||
|
|
||||||
BString fImageType; // Type of image, for use in status bar and caption
|
BString fImageType; // Type of image, for use in status bar and caption
|
||||||
|
BString fImageMime;
|
||||||
|
|
||||||
bool fInverted;
|
bool fInverted;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user