removed tracker to app user feedback, added comments
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3592 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -41,13 +41,10 @@
|
|||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <Node.h>
|
|
||||||
#include <NodeInfo.h>
|
|
||||||
#include <MenuBar.h>
|
#include <MenuBar.h>
|
||||||
#include <Screen.h>
|
#include <Screen.h>
|
||||||
#include <ScrollBar.h>
|
#include <ScrollBar.h>
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
#include <Font.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -56,11 +53,8 @@ ImageView::ImageView(BRect rect, const char *name)
|
|||||||
: BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS)
|
: BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS)
|
||||||
{
|
{
|
||||||
fpbitmap = NULL;
|
fpbitmap = NULL;
|
||||||
fpmsgFromTracker = NULL;
|
|
||||||
fbdragFromTracker = false;
|
|
||||||
|
|
||||||
SetViewColor(255, 255, 255);
|
SetViewColor(255, 255, 255);
|
||||||
SetHighColor(255, 255, 255);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageView::~ImageView()
|
ImageView::~ImageView()
|
||||||
@@ -78,30 +72,8 @@ ImageView::AttachedToWindow()
|
|||||||
void
|
void
|
||||||
ImageView::Draw(BRect rect)
|
ImageView::Draw(BRect rect)
|
||||||
{
|
{
|
||||||
// Force view setting changes to be local
|
|
||||||
// to this function
|
|
||||||
PushState();
|
|
||||||
|
|
||||||
// calculate highlight rectangle
|
|
||||||
BRect bounds = Bounds();
|
|
||||||
bounds.right--;
|
|
||||||
bounds.bottom--;
|
|
||||||
|
|
||||||
if (HasImage())
|
if (HasImage())
|
||||||
DrawBitmap(fpbitmap, BPoint(0, 0));
|
DrawBitmap(fpbitmap, BPoint(0, 0));
|
||||||
else if (!fbdragFromTracker) {
|
|
||||||
SetHighColor(255, 255, 255);
|
|
||||||
SetPenSize(2.0);
|
|
||||||
StrokeRect(bounds);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fbdragFromTracker) {
|
|
||||||
SetHighColor(0, 0, 229);
|
|
||||||
SetPenSize(2.0);
|
|
||||||
StrokeRect(bounds);
|
|
||||||
}
|
|
||||||
|
|
||||||
PopState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -123,8 +95,18 @@ ImageView::MouseDown(BPoint point)
|
|||||||
{
|
{
|
||||||
if (!HasImage())
|
if (!HasImage())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Only accept left button clicks
|
||||||
|
BMessage *pmsg = Window()->CurrentMessage();
|
||||||
|
int32 button = pmsg->FindInt32("buttons");
|
||||||
|
if (button != B_PRIMARY_MOUSE_BUTTON)
|
||||||
|
return;
|
||||||
|
|
||||||
// Tell BeOS to setup a Drag/Drop operation
|
// Tell BeOS to setup a Drag/Drop operation
|
||||||
|
//
|
||||||
|
// (When the image is dropped, BeOS sends
|
||||||
|
// the following message to ImageWindow,
|
||||||
|
// which causes it to call ImageView::SetImage())
|
||||||
BMessage msg(B_SIMPLE_DATA);
|
BMessage msg(B_SIMPLE_DATA);
|
||||||
msg.AddInt32("be:actions", B_COPY_TARGET);
|
msg.AddInt32("be:actions", B_COPY_TARGET);
|
||||||
msg.AddString("be:filetypes", "application/octet-stream");
|
msg.AddString("be:filetypes", "application/octet-stream");
|
||||||
@@ -137,46 +119,6 @@ ImageView::MouseDown(BPoint point)
|
|||||||
void
|
void
|
||||||
ImageView::MouseMoved(BPoint point, uint32 state, const BMessage *pmsg)
|
ImageView::MouseMoved(BPoint point, uint32 state, const BMessage *pmsg)
|
||||||
{
|
{
|
||||||
if (state == B_EXITED_VIEW) {
|
|
||||||
// If the cursor was dragged over,
|
|
||||||
// then off of this view, turn off
|
|
||||||
// drag/drop border highlighting and
|
|
||||||
// forget the last drag/drop BMessage
|
|
||||||
// from the tracker
|
|
||||||
fbdragFromTracker = false;
|
|
||||||
fpmsgFromTracker = NULL;
|
|
||||||
ReDraw();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pmsg || pmsg->what != B_SIMPLE_DATA)
|
|
||||||
// if there is no message (nothing being dragged)
|
|
||||||
// or the message contains uninteresting data,
|
|
||||||
// exit this function
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (pmsg != fpmsgFromTracker) {
|
|
||||||
fpmsgFromTracker = pmsg;
|
|
||||||
|
|
||||||
entry_ref ref;
|
|
||||||
if (pmsg->FindRef("refs", 0, &ref) != B_OK)
|
|
||||||
return;
|
|
||||||
|
|
||||||
BNode node(&ref);
|
|
||||||
if (node.InitCheck() != B_OK)
|
|
||||||
return;
|
|
||||||
BNodeInfo nodeinfo(&node);
|
|
||||||
if (nodeinfo.InitCheck() != B_OK)
|
|
||||||
return;
|
|
||||||
char mime[B_MIME_TYPE_LENGTH];
|
|
||||||
if (nodeinfo.GetType(mime) != B_OK)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (strstr(mime, "image/") != NULL) {
|
|
||||||
fbdragFromTracker = true;
|
|
||||||
ReDraw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -249,6 +191,7 @@ ImageView::AdjustScrollBars()
|
|||||||
psb->SetProportion(prop);
|
psb->SetProportion(prop);
|
||||||
psb->SetSteps(10, 100);
|
psb->SetSteps(10, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
psb = ScrollBar(B_VERTICAL);
|
psb = ScrollBar(B_VERTICAL);
|
||||||
if (psb) {
|
if (psb) {
|
||||||
range = rctbitmap.Height() - rctview.Height();
|
range = rctbitmap.Height() - rctview.Height();
|
||||||
@@ -266,8 +209,6 @@ ImageView::SetImage(BMessage *pmsg)
|
|||||||
{
|
{
|
||||||
// Replace current image with the image
|
// Replace current image with the image
|
||||||
// specified in the given BMessage
|
// specified in the given BMessage
|
||||||
|
|
||||||
fbdragFromTracker = false;
|
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
if (pmsg->FindRef("refs", &ref) != B_OK)
|
if (pmsg->FindRef("refs", &ref) != B_OK)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -59,8 +59,6 @@ private:
|
|||||||
void SaveImageAtDropLocation(BMessage *pmsg);
|
void SaveImageAtDropLocation(BMessage *pmsg);
|
||||||
|
|
||||||
BBitmap *fpbitmap;
|
BBitmap *fpbitmap;
|
||||||
const BMessage *fpmsgFromTracker;
|
|
||||||
bool fbdragFromTracker;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // #ifndef IMAGEVIEW_H
|
#endif // #ifndef IMAGEVIEW_H
|
||||||
|
|||||||
@@ -29,7 +29,6 @@
|
|||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "ImageWindow.h"
|
#include "ImageWindow.h"
|
||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
@@ -47,9 +46,14 @@ ImageWindow::ImageWindow(BRect rect, const char *name)
|
|||||||
BMenuBar *pbar = new BMenuBar(rctbar, "MenuBar");
|
BMenuBar *pbar = new BMenuBar(rctbar, "MenuBar");
|
||||||
BMenu *pmnufile = new BMenu("File");
|
BMenu *pmnufile = new BMenu("File");
|
||||||
|
|
||||||
BMenuItem *pitmopen = new BMenuItem("Open...", new BMessage(M_OPEN_IMAGE), 'O', 0);
|
BMenuItem *pitmopen = new BMenuItem("Open...",
|
||||||
BMenuItem *pitmsave = new BMenuItem("Save...", new BMessage(M_SAVE_IMAGE), 'S', 0);
|
new BMessage(M_OPEN_IMAGE), 'O', 0);
|
||||||
BMenuItem *pitmquit = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q', 0);
|
|
||||||
|
BMenuItem *pitmsave = new BMenuItem("Save...",
|
||||||
|
new BMessage(M_SAVE_IMAGE), 'S', 0);
|
||||||
|
|
||||||
|
BMenuItem *pitmquit = new BMenuItem("Quit",
|
||||||
|
new BMessage(B_QUIT_REQUESTED), 'Q', 0);
|
||||||
|
|
||||||
pmnufile->AddItem(pitmopen);
|
pmnufile->AddItem(pitmopen);
|
||||||
pmnufile->AddItem(pitmsave);
|
pmnufile->AddItem(pitmsave);
|
||||||
@@ -65,11 +69,12 @@ ImageWindow::ImageWindow(BRect rect, const char *name)
|
|||||||
rctview.bottom -= B_H_SCROLL_BAR_HEIGHT;
|
rctview.bottom -= B_H_SCROLL_BAR_HEIGHT;
|
||||||
|
|
||||||
fpimageView = new ImageView(rctview, "ImageView");
|
fpimageView = new ImageView(rctview, "ImageView");
|
||||||
AddChild(new BScrollView("ImageScroll", fpimageView, B_FOLLOW_ALL_SIDES, 0, true, true));
|
AddChild(new BScrollView("ImageScroll", fpimageView,
|
||||||
|
B_FOLLOW_ALL_SIDES, 0, true, true));
|
||||||
|
|
||||||
// Setup file open panel
|
// Setup file open panel
|
||||||
fpopenPanel = new BFilePanel(B_OPEN_PANEL, new BMessenger(this), NULL, 0, false,
|
fpopenPanel = new BFilePanel(B_OPEN_PANEL, new BMessenger(this),
|
||||||
new BMessage(M_OPEN_FILE_PANEL), NULL, false, true);
|
NULL, 0, false, new BMessage(M_OPEN_FILE_PANEL), NULL, false, true);
|
||||||
|
|
||||||
SetSizeLimits(200, 10000, 150, 10000);
|
SetSizeLimits(200, 10000, 150, 10000);
|
||||||
}
|
}
|
||||||
@@ -91,10 +96,12 @@ ImageWindow::MessageReceived(BMessage *pmsg)
|
|||||||
|
|
||||||
case M_SAVE_IMAGE:
|
case M_SAVE_IMAGE:
|
||||||
if (fpimageView->HasImage()) {
|
if (fpimageView->HasImage()) {
|
||||||
BAlert *palert = new BAlert(NULL, "Save feature not implemented yet.", "Bummer");
|
BAlert *palert = new BAlert(NULL,
|
||||||
|
"Save feature not implemented yet.", "Bummer");
|
||||||
palert->Go();
|
palert->Go();
|
||||||
} else {
|
} else {
|
||||||
BAlert *palert = new BAlert(NULL, "No image available to save.", "OK");
|
BAlert *palert = new BAlert(NULL,
|
||||||
|
"No image available to save.", "OK");
|
||||||
palert->Go();
|
palert->Go();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user