Added feature where a file dropped from the Tracker becomes the current selection
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6121 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -406,6 +406,31 @@ ShowImageView::SetImage(const entry_ref *pref)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
status_t
|
||||||
|
ShowImageView::SetSelection(const entry_ref *pref, BPoint point)
|
||||||
|
{
|
||||||
|
BTranslatorRoster *proster = BTranslatorRoster::Default();
|
||||||
|
if (!proster)
|
||||||
|
return B_ERROR;
|
||||||
|
BFile file(pref, B_READ_ONLY);
|
||||||
|
translator_info info;
|
||||||
|
memset(&info, 0, sizeof(translator_info));
|
||||||
|
if (proster->Identify(&file, NULL, &info, 0, NULL,
|
||||||
|
B_TRANSLATOR_BITMAP) != B_OK)
|
||||||
|
return B_ERROR;
|
||||||
|
|
||||||
|
// Translate image data and create a new ShowImage window
|
||||||
|
BBitmapStream outstream;
|
||||||
|
if (proster->Translate(&file, &info, NULL, &outstream,
|
||||||
|
B_TRANSLATOR_BITMAP) != B_OK)
|
||||||
|
return B_ERROR;
|
||||||
|
BBitmap *newBitmap = NULL;
|
||||||
|
if (outstream.DetachBitmap(&newBitmap) != B_OK)
|
||||||
|
return B_ERROR;
|
||||||
|
|
||||||
|
return PasteBitmap(newBitmap, point);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageView::SetDither(bool dither)
|
ShowImageView::SetDither(bool dither)
|
||||||
{
|
{
|
||||||
@@ -1449,11 +1474,24 @@ ShowImageView::MessageReceived(BMessage *pmsg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case B_SIMPLE_DATA:
|
case B_SIMPLE_DATA:
|
||||||
|
if (pmsg->WasDropped()) {
|
||||||
|
uint32 type;
|
||||||
|
int32 count;
|
||||||
|
status_t ret = pmsg->GetInfo("refs", &type, &count);
|
||||||
|
if (ret == B_OK && type == B_REF_TYPE) {
|
||||||
|
// If file was dropped, open it as the selection
|
||||||
|
entry_ref ref;
|
||||||
|
if (pmsg->FindRef("refs", 0, &ref) == B_OK) {
|
||||||
|
BPoint point = pmsg->DropPoint();
|
||||||
|
point = ConvertFromScreen(point);
|
||||||
|
point = ViewToImage(point);
|
||||||
|
SetSelection(&ref, point);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
// If a user drags a clip from another ShowImage window,
|
// If a user drags a clip from another ShowImage window,
|
||||||
// request a BBitmap pointer to that clip, allocated by the
|
// request a BBitmap pointer to that clip, allocated by the
|
||||||
// other view, for use solely by this view, so that it can
|
// other view, for use solely by this view, so that it can
|
||||||
// be dropped/pasted onto this view.
|
// be dropped/pasted onto this view.
|
||||||
if (pmsg->WasDropped()) {
|
|
||||||
BMessenger retMsgr, localMsgr(this);
|
BMessenger retMsgr, localMsgr(this);
|
||||||
retMsgr = pmsg->ReturnAddress();
|
retMsgr = pmsg->ReturnAddress();
|
||||||
if (retMsgr != localMsgr) {
|
if (retMsgr != localMsgr) {
|
||||||
@@ -1475,7 +1513,7 @@ ShowImageView::MessageReceived(BMessage *pmsg)
|
|||||||
|
|
||||||
PasteBitmap(bitmap, point);
|
PasteBitmap(bitmap, point);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1646,7 +1684,7 @@ ShowImageView::Cut()
|
|||||||
RemoveSelection(true);
|
RemoveSelection(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
status_t
|
||||||
ShowImageView::PasteBitmap(BBitmap *bitmap, BPoint point)
|
ShowImageView::PasteBitmap(BBitmap *bitmap, BPoint point)
|
||||||
{
|
{
|
||||||
if (bitmap && bitmap->IsValid()) {
|
if (bitmap && bitmap->IsValid()) {
|
||||||
@@ -1666,7 +1704,11 @@ ShowImageView::PasteBitmap(BBitmap *bitmap, BPoint point)
|
|||||||
fSelectionRect = offsetRect;
|
fSelectionRect = offsetRect;
|
||||||
|
|
||||||
Invalidate();
|
Invalidate();
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -138,7 +138,8 @@ private:
|
|||||||
void AddWhiteRect(BRect &rect);
|
void AddWhiteRect(BRect &rect);
|
||||||
void GetMergeRects(BBitmap *merge, BRect selection, BRect &srcBits, BRect &destRect);
|
void GetMergeRects(BBitmap *merge, BRect selection, BRect &srcBits, BRect &destRect);
|
||||||
void GetSelMergeRects(BRect &srcBits, BRect &destRect);
|
void GetSelMergeRects(BRect &srcBits, BRect &destRect);
|
||||||
void PasteBitmap(BBitmap *bitmap, BPoint point);
|
status_t SetSelection(const entry_ref *pref, BPoint point);
|
||||||
|
status_t PasteBitmap(BBitmap *bitmap, BPoint point);
|
||||||
void MergeWithBitmap(BBitmap *merge, BRect selection);
|
void MergeWithBitmap(BBitmap *merge, BRect selection);
|
||||||
void MergeSelection();
|
void MergeSelection();
|
||||||
void DeleteScaler();
|
void DeleteScaler();
|
||||||
|
|||||||
Reference in New Issue
Block a user