Implemented a progress window: it will be shown after one second in case the translator
supports it - currently, only the RAW image translator does this (as it needs about 10 seconds to open a 6 mio. pixel RAW image on a 2.6 GHz P4). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20650 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
64f5accb3a
commit
a58eacec3c
@ -4,7 +4,8 @@ UsePrivateHeaders tracker ;
|
|||||||
|
|
||||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||||
|
|
||||||
Application ShowImage : ShowImageApp.cpp
|
Application ShowImage :
|
||||||
|
ShowImageApp.cpp
|
||||||
ShowImageSettings.cpp
|
ShowImageSettings.cpp
|
||||||
ShowImageStatusView.cpp
|
ShowImageStatusView.cpp
|
||||||
ShowImageUndo.cpp
|
ShowImageUndo.cpp
|
||||||
@ -14,6 +15,7 @@ Application ShowImage : ShowImageApp.cpp
|
|||||||
Filter.cpp
|
Filter.cpp
|
||||||
EntryMenuItem.cpp
|
EntryMenuItem.cpp
|
||||||
BackgroundImage.cpp
|
BackgroundImage.cpp
|
||||||
|
ProgressWindow.cpp
|
||||||
ResizerWindow.cpp
|
ResizerWindow.cpp
|
||||||
: be tracker translation
|
: be tracker translation
|
||||||
: ShowImage.rdef
|
: ShowImage.rdef
|
||||||
|
116
src/apps/showimage/ProgressWindow.cpp
Normal file
116
src/apps/showimage/ProgressWindow.cpp
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "ProgressWindow.h"
|
||||||
|
|
||||||
|
#include <Autolock.h>
|
||||||
|
#include <MessageRunner.h>
|
||||||
|
#include <Screen.h>
|
||||||
|
#include <StatusBar.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
|
static const uint32 kMsgShow = 'show';
|
||||||
|
static const uint32 kMsgStatusUpdate = 'SIup';
|
||||||
|
|
||||||
|
|
||||||
|
ProgressWindow::ProgressWindow(BWindow* referenceWindow)
|
||||||
|
: BWindow(BRect(0, 0, 250, 100), "Progress Monitor",
|
||||||
|
B_MODAL_WINDOW_LOOK, B_FLOATING_APP_WINDOW_FEEL,
|
||||||
|
B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS),
|
||||||
|
fRunner(NULL)
|
||||||
|
{
|
||||||
|
BRect rect = Bounds();
|
||||||
|
|
||||||
|
BView *view = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
|
||||||
|
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
AddChild(view);
|
||||||
|
|
||||||
|
rect = view->Bounds().InsetByCopy(5, 5);
|
||||||
|
fStatusBar = new BStatusBar(rect, "status", NULL, NULL);
|
||||||
|
float width, height;
|
||||||
|
fStatusBar->GetPreferredSize(&width, &height);
|
||||||
|
fStatusBar->ResizeTo(rect.Width(), height);
|
||||||
|
fStatusBar->SetResizingMode(B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT);
|
||||||
|
view->AddChild(fStatusBar);
|
||||||
|
|
||||||
|
BScreen screen(referenceWindow);
|
||||||
|
ResizeTo(Bounds().Width(), height + 9);
|
||||||
|
MoveTo(screen.Frame().left + 5, screen.Frame().bottom - Bounds().Height() - 5);
|
||||||
|
|
||||||
|
Run();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ProgressWindow::~ProgressWindow()
|
||||||
|
{
|
||||||
|
delete fRunner;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ProgressWindow::Start()
|
||||||
|
{
|
||||||
|
BAutolock _(this);
|
||||||
|
|
||||||
|
fRetrievedUpdate = false;
|
||||||
|
fRetrievedShow = false;
|
||||||
|
delete fRunner;
|
||||||
|
|
||||||
|
BMessage show(kMsgShow);
|
||||||
|
fRunner = new BMessageRunner(this, &show, 1000000, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ProgressWindow::Stop()
|
||||||
|
{
|
||||||
|
BAutolock _(this);
|
||||||
|
|
||||||
|
delete fRunner;
|
||||||
|
fRunner = NULL;
|
||||||
|
|
||||||
|
if (!IsHidden())
|
||||||
|
Hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ProgressWindow::MessageReceived(BMessage *message)
|
||||||
|
{
|
||||||
|
switch (message->what) {
|
||||||
|
case kMsgShow:
|
||||||
|
if (fRetrievedUpdate && IsHidden()) {
|
||||||
|
Show();
|
||||||
|
Minimize(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
fRetrievedShow = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case kMsgStatusUpdate:
|
||||||
|
float percent;
|
||||||
|
if (message->FindFloat("percent", &percent) == B_OK)
|
||||||
|
fStatusBar->Update(percent - fStatusBar->CurrentValue());
|
||||||
|
|
||||||
|
const char *text;
|
||||||
|
if (message->FindString("message", &text) == B_OK)
|
||||||
|
fStatusBar->SetText(text);
|
||||||
|
|
||||||
|
fRetrievedUpdate = true;
|
||||||
|
|
||||||
|
if (fRetrievedShow && IsHidden()) {
|
||||||
|
Show();
|
||||||
|
Minimize(false);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
BWindow::MessageReceived(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
32
src/apps/showimage/ProgressWindow.h
Normal file
32
src/apps/showimage/ProgressWindow.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef PROGRESS_WINDOW_H
|
||||||
|
#define PROGRESS_WINDOW_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
|
class BMessageRunner;
|
||||||
|
class BStatusBar;
|
||||||
|
|
||||||
|
|
||||||
|
class ProgressWindow : public BWindow {
|
||||||
|
public:
|
||||||
|
ProgressWindow(BWindow* referenceWindow);
|
||||||
|
virtual ~ProgressWindow();
|
||||||
|
|
||||||
|
virtual void MessageReceived(BMessage *message);
|
||||||
|
|
||||||
|
void Start();
|
||||||
|
void Stop();
|
||||||
|
|
||||||
|
private:
|
||||||
|
BStatusBar* fStatusBar;
|
||||||
|
BMessageRunner* fRunner;
|
||||||
|
bool fRetrievedUpdate;
|
||||||
|
bool fRetrievedShow;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PROGRESS_WINDOW_H
|
@ -14,6 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "ProgressWindow.h"
|
||||||
#include "ShowImageApp.h"
|
#include "ShowImageApp.h"
|
||||||
#include "ShowImageConstants.h"
|
#include "ShowImageConstants.h"
|
||||||
#include "ShowImageView.h"
|
#include "ShowImageView.h"
|
||||||
@ -175,7 +176,8 @@ PopUpMenu::~PopUpMenu()
|
|||||||
|
|
||||||
ShowImageView::ShowImageView(BRect rect, const char *name, uint32 resizingMode,
|
ShowImageView::ShowImageView(BRect rect, const char *name, uint32 resizingMode,
|
||||||
uint32 flags)
|
uint32 flags)
|
||||||
: BView(rect, name, resizingMode, flags)
|
: BView(rect, name, resizingMode, flags),
|
||||||
|
fProgressWindow(NULL)
|
||||||
{
|
{
|
||||||
ShowImageSettings* settings;
|
ShowImageSettings* settings;
|
||||||
settings = my_app->Settings();
|
settings = my_app->Settings();
|
||||||
@ -488,17 +490,28 @@ ShowImageView::SetImage(const entry_ref *ref)
|
|||||||
// if new image, reset to first document
|
// if new image, reset to first document
|
||||||
fDocumentIndex = 1;
|
fDocumentIndex = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ioExtension.AddInt32("/documentIndex", fDocumentIndex) != B_OK)
|
if (ioExtension.AddInt32("/documentIndex", fDocumentIndex) != B_OK)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
if (roster->Identify(&file, &ioExtension, &info, 0, NULL,
|
|
||||||
B_TRANSLATOR_BITMAP) != B_OK)
|
if (ioExtension.AddMessenger("/progressMonitor", fProgressWindow) == B_OK)
|
||||||
return B_ERROR;
|
fProgressWindow->Start();
|
||||||
|
|
||||||
// Translate image data and create a new ShowImage window
|
// Translate image data and create a new ShowImage window
|
||||||
|
|
||||||
BBitmapStream outstream;
|
BBitmapStream outstream;
|
||||||
if (roster->Translate(&file, &info, &ioExtension, &outstream,
|
|
||||||
B_TRANSLATOR_BITMAP) != B_OK)
|
status_t status = roster->Identify(&file, &ioExtension, &info, 0, NULL,
|
||||||
return B_ERROR;
|
B_TRANSLATOR_BITMAP);
|
||||||
|
if (status == B_OK) {
|
||||||
|
status = roster->Translate(&file, &info, &ioExtension, &outstream,
|
||||||
|
B_TRANSLATOR_BITMAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
fProgressWindow->Stop();
|
||||||
|
|
||||||
|
if (status != B_OK)
|
||||||
|
return status;
|
||||||
|
|
||||||
BBitmap *newBitmap = NULL;
|
BBitmap *newBitmap = NULL;
|
||||||
if (outstream.DetachBitmap(&newBitmap) != B_OK)
|
if (outstream.DetachBitmap(&newBitmap) != B_OK)
|
||||||
@ -565,8 +578,8 @@ ShowImageView::SetImage(const entry_ref *ref)
|
|||||||
|
|
||||||
// get the number of documents (pages) if it has been supplied
|
// get the number of documents (pages) if it has been supplied
|
||||||
int32 documentCount = 0;
|
int32 documentCount = 0;
|
||||||
if (ioExtension.FindInt32("/documentCount", &documentCount) == B_OK &&
|
if (ioExtension.FindInt32("/documentCount", &documentCount) == B_OK
|
||||||
documentCount > 0)
|
&& documentCount > 0)
|
||||||
fDocumentCount = documentCount;
|
fDocumentCount = documentCount;
|
||||||
else
|
else
|
||||||
fDocumentCount = 1;
|
fDocumentCount = 1;
|
||||||
@ -719,6 +732,16 @@ ShowImageView::AttachedToWindow()
|
|||||||
{
|
{
|
||||||
fUndo.SetWindow(Window());
|
fUndo.SetWindow(Window());
|
||||||
FixupScrollBars();
|
FixupScrollBars();
|
||||||
|
|
||||||
|
fProgressWindow = new ProgressWindow(Window());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ShowImageView::DetachedFromWindow()
|
||||||
|
{
|
||||||
|
fProgressWindow->Lock();
|
||||||
|
fProgressWindow->Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2006, Haiku, Inc. All Rights Reserved.
|
* Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
|
||||||
* Copyright 2004-2005 yellowTAB GmbH. All Rights Reserverd.
|
* Copyright 2004-2005 yellowTAB GmbH. All Rights Reserverd.
|
||||||
* Copyright 2006 Bernd Korz. All Rights Reserved
|
* Copyright 2006 Bernd Korz. All Rights Reserved
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
@ -36,6 +36,8 @@
|
|||||||
// the delay time for hiding the cursor in 1/10 seconds (the pulse rate)
|
// the delay time for hiding the cursor in 1/10 seconds (the pulse rate)
|
||||||
#define HIDE_CURSOR_DELAY_TIME 20
|
#define HIDE_CURSOR_DELAY_TIME 20
|
||||||
|
|
||||||
|
class ProgressWindow;
|
||||||
|
|
||||||
class ShowImageView : public BView {
|
class ShowImageView : public BView {
|
||||||
public:
|
public:
|
||||||
ShowImageView(BRect rect, const char *name, uint32 resizingMode,
|
ShowImageView(BRect rect, const char *name, uint32 resizingMode,
|
||||||
@ -43,6 +45,7 @@ class ShowImageView : public BView {
|
|||||||
virtual ~ShowImageView();
|
virtual ~ShowImageView();
|
||||||
|
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
|
virtual void DetachedFromWindow();
|
||||||
virtual void Draw(BRect updateRect);
|
virtual void Draw(BRect updateRect);
|
||||||
virtual void FrameResized(float width, float height);
|
virtual void FrameResized(float width, float height);
|
||||||
virtual void MouseDown(BPoint point);
|
virtual void MouseDown(BPoint point);
|
||||||
@ -249,6 +252,8 @@ class ShowImageView : public BView {
|
|||||||
int fHideCursorCountDown; // Hides the cursor when it reaches zero
|
int fHideCursorCountDown; // Hides the cursor when it reaches zero
|
||||||
bool fIsActiveWin; // Is the parent window the active window?
|
bool fIsActiveWin; // Is the parent window the active window?
|
||||||
|
|
||||||
|
ProgressWindow* fProgressWindow;
|
||||||
|
|
||||||
enum image_orientation fImageOrientation;
|
enum image_orientation fImageOrientation;
|
||||||
static enum image_orientation fTransformation[
|
static enum image_orientation fTransformation[
|
||||||
ImageProcessor::kNumberOfAffineTransformations][kNumberOfOrientations];
|
ImageProcessor::kNumberOfAffineTransformations][kNumberOfOrientations];
|
||||||
|
Loading…
Reference in New Issue
Block a user