* Removed the slide show code from ShowImageView, and reimplemented them in
ShowImageWindow using a BMessageRunner. * Note, this is completely untested, as it turns out my Haiku installation on this box is too old to run it. It compiles, at least, and shouldn't break anything else. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40178 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2010 Haiku Inc. All rights reserved.
|
* Copyright 2003-2011 Haiku Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -15,15 +15,20 @@
|
|||||||
|
|
||||||
|
|
||||||
ShowImageSettings::ShowImageSettings()
|
ShowImageSettings::ShowImageSettings()
|
||||||
|
:
|
||||||
|
fLock("settings lock"),
|
||||||
|
fUpdated(false)
|
||||||
{
|
{
|
||||||
Load();
|
_Load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ShowImageSettings::~ShowImageSettings()
|
ShowImageSettings::~ShowImageSettings()
|
||||||
{
|
{
|
||||||
if (Lock()) {
|
if (Lock()) {
|
||||||
Save();
|
if (fUpdated)
|
||||||
|
_Save();
|
||||||
|
|
||||||
Unlock();
|
Unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -87,6 +92,17 @@ ShowImageSettings::GetRect(const char* name, BRect defaultValue)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bigtime_t
|
||||||
|
ShowImageSettings::GetTime(const char* name, bigtime_t defaultValue)
|
||||||
|
{
|
||||||
|
int64 value;
|
||||||
|
if (fSettings.FindInt64(name, &value) == B_OK)
|
||||||
|
return value;
|
||||||
|
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const char*
|
const char*
|
||||||
ShowImageSettings::GetString(const char* name, const char* defaultValue)
|
ShowImageSettings::GetString(const char* name, const char* defaultValue)
|
||||||
{
|
{
|
||||||
@@ -105,6 +121,8 @@ ShowImageSettings::SetBool(const char* name, bool value)
|
|||||||
fSettings.ReplaceBool(name, value);
|
fSettings.ReplaceBool(name, value);
|
||||||
else
|
else
|
||||||
fSettings.AddBool(name, value);
|
fSettings.AddBool(name, value);
|
||||||
|
|
||||||
|
fUpdated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -115,6 +133,8 @@ ShowImageSettings::SetInt32(const char* name, int32 value)
|
|||||||
fSettings.ReplaceInt32(name, value);
|
fSettings.ReplaceInt32(name, value);
|
||||||
else
|
else
|
||||||
fSettings.AddInt32(name, value);
|
fSettings.AddInt32(name, value);
|
||||||
|
|
||||||
|
fUpdated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -125,6 +145,8 @@ ShowImageSettings::SetFloat(const char* name, float value)
|
|||||||
fSettings.ReplaceFloat(name, value);
|
fSettings.ReplaceFloat(name, value);
|
||||||
else
|
else
|
||||||
fSettings.AddFloat(name, value);
|
fSettings.AddFloat(name, value);
|
||||||
|
|
||||||
|
fUpdated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -135,6 +157,18 @@ ShowImageSettings::SetRect(const char* name, BRect value)
|
|||||||
fSettings.ReplaceRect(name, value);
|
fSettings.ReplaceRect(name, value);
|
||||||
else
|
else
|
||||||
fSettings.AddRect(name, value);
|
fSettings.AddRect(name, value);
|
||||||
|
|
||||||
|
fUpdated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ShowImageSettings::SetTime(const char* name, bigtime_t value)
|
||||||
|
{
|
||||||
|
if (fSettings.ReplaceInt64(name, value) != B_OK)
|
||||||
|
fSettings.AddInt64(name, value);
|
||||||
|
|
||||||
|
fUpdated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -145,11 +179,13 @@ ShowImageSettings::SetString(const char* name, const char* value)
|
|||||||
fSettings.ReplaceString(name, value);
|
fSettings.ReplaceString(name, value);
|
||||||
else
|
else
|
||||||
fSettings.AddString(name, value);
|
fSettings.AddString(name, value);
|
||||||
|
|
||||||
|
fUpdated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ShowImageSettings::OpenSettingsFile(BFile* file, bool forReading)
|
ShowImageSettings::_OpenSettingsFile(BFile* file, bool forReading)
|
||||||
{
|
{
|
||||||
BPath path;
|
BPath path;
|
||||||
status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
|
status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
|
||||||
@@ -164,18 +200,18 @@ ShowImageSettings::OpenSettingsFile(BFile* file, bool forReading)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageSettings::Load()
|
ShowImageSettings::_Load()
|
||||||
{
|
{
|
||||||
BFile file;
|
BFile file;
|
||||||
if (OpenSettingsFile(&file, true))
|
if (_OpenSettingsFile(&file, true))
|
||||||
fSettings.Unflatten(&file);
|
fSettings.Unflatten(&file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageSettings::Save()
|
ShowImageSettings::_Save()
|
||||||
{
|
{
|
||||||
BFile file;
|
BFile file;
|
||||||
if (OpenSettingsFile(&file, false))
|
if (_OpenSettingsFile(&file, false))
|
||||||
fSettings.Flatten(&file);
|
fSettings.Flatten(&file);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2009 Haiku Inc. All rights reserved.
|
* Copyright 2003-2011 Haiku Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -9,36 +9,46 @@
|
|||||||
#define SHOW_IMAGE_SETTINGS_H
|
#define SHOW_IMAGE_SETTINGS_H
|
||||||
|
|
||||||
|
|
||||||
#include <File.h>
|
|
||||||
#include <Message.h>
|
|
||||||
#include <Locker.h>
|
#include <Locker.h>
|
||||||
|
#include <Message.h>
|
||||||
|
|
||||||
|
|
||||||
|
class BFile;
|
||||||
|
|
||||||
|
|
||||||
class ShowImageSettings {
|
class ShowImageSettings {
|
||||||
public:
|
public:
|
||||||
ShowImageSettings();
|
ShowImageSettings();
|
||||||
~ShowImageSettings();
|
virtual ~ShowImageSettings();
|
||||||
|
|
||||||
|
bool Lock();
|
||||||
|
void Unlock();
|
||||||
|
|
||||||
|
bool GetBool(const char* name, bool defaultValue);
|
||||||
|
int32 GetInt32(const char* name, int32 defaultValue);
|
||||||
|
float GetFloat(const char* name, float defaultValue);
|
||||||
|
BRect GetRect(const char* name, BRect defaultValue);
|
||||||
|
bigtime_t GetTime(const char* name,
|
||||||
|
bigtime_t defaultValue);
|
||||||
|
const char* GetString(const char* name,
|
||||||
|
const char* defaultValue);
|
||||||
|
|
||||||
|
void SetBool(const char* name, bool value);
|
||||||
|
void SetInt32(const char* name, int32 value);
|
||||||
|
void SetFloat(const char* name, float value);
|
||||||
|
void SetRect(const char* name, BRect value);
|
||||||
|
void SetTime(const char* name, bigtime_t value);
|
||||||
|
void SetString(const char* name, const char* value);
|
||||||
|
|
||||||
bool Lock();
|
|
||||||
bool GetBool(const char* name, bool defaultValue);
|
|
||||||
int32 GetInt32(const char* name, int32 defaultValue);
|
|
||||||
float GetFloat(const char* name, float defaultValue);
|
|
||||||
BRect GetRect(const char* name, BRect defaultValue);
|
|
||||||
const char* GetString(const char* name, const char* defaultValue);
|
|
||||||
void SetBool(const char* name, bool value);
|
|
||||||
void SetInt32(const char* name, int32 value);
|
|
||||||
void SetFloat(const char* name, float value);
|
|
||||||
void SetRect(const char* name, BRect value);
|
|
||||||
void SetString(const char* name, const char* value);
|
|
||||||
void Unlock();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool OpenSettingsFile(BFile* file, bool forReading);
|
bool _OpenSettingsFile(BFile* file, bool forReading);
|
||||||
void Load();
|
void _Load();
|
||||||
void Save();
|
void _Save();
|
||||||
|
|
||||||
BLocker fLock;
|
private:
|
||||||
BMessage fSettings;
|
BLocker fLock;
|
||||||
|
BMessage fSettings;
|
||||||
|
bool fUpdated;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2010, Haiku, Inc. All Rights Reserved.
|
* Copyright 2003-2011, 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.
|
||||||
@@ -192,20 +192,15 @@ ShowImageView::ShowImageView(BRect rect, const char *name, uint32 resizingMode,
|
|||||||
fSelectionMode(false),
|
fSelectionMode(false),
|
||||||
fAnimateSelection(true),
|
fAnimateSelection(true),
|
||||||
fHasSelection(false),
|
fHasSelection(false),
|
||||||
fSlideShow(false),
|
|
||||||
fSlideShowDelay(3 * 10), // 3 seconds
|
|
||||||
fSlideShowCountDown(0),
|
|
||||||
fShowCaption(false),
|
fShowCaption(false),
|
||||||
fShowingPopUpMenu(false),
|
fShowingPopUpMenu(false),
|
||||||
fHideCursorCountDown(HIDE_CURSOR_DELAY_TIME),
|
fHideCursorCountDown(HIDE_CURSOR_DELAY_TIME),
|
||||||
fIsActiveWin(true)
|
fIsActiveWin(true)
|
||||||
{
|
{
|
||||||
ShowImageSettings* settings;
|
ShowImageSettings* settings = my_app->Settings();
|
||||||
settings = my_app->Settings();
|
|
||||||
if (settings->Lock()) {
|
if (settings->Lock()) {
|
||||||
fStretchToBounds = settings->GetBool("StretchToBounds",
|
fStretchToBounds = settings->GetBool("StretchToBounds",
|
||||||
fStretchToBounds);
|
fStretchToBounds);
|
||||||
fSlideShowDelay = settings->GetInt32("SlideShowDelay", fSlideShowDelay);
|
|
||||||
fScaleBilinear = settings->GetBool("ScaleBilinear", fScaleBilinear);
|
fScaleBilinear = settings->GetBool("ScaleBilinear", fScaleBilinear);
|
||||||
settings->Unlock();
|
settings->Unlock();
|
||||||
}
|
}
|
||||||
@@ -237,17 +232,6 @@ ShowImageView::Pulse()
|
|||||||
fSelectionBox.Animate();
|
fSelectionBox.Animate();
|
||||||
fSelectionBox.Draw(this, Bounds());
|
fSelectionBox.Draw(this, Bounds());
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
if (fSlideShow) {
|
|
||||||
fSlideShowCountDown --;
|
|
||||||
if (fSlideShowCountDown <= 0) {
|
|
||||||
fSlideShowCountDown = fSlideShowDelay;
|
|
||||||
if (!NextFile()) {
|
|
||||||
_FirstFile();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (fHideCursor && !fHasSelection && !fShowingPopUpMenu && fIsActiveWin) {
|
if (fHideCursor && !fHasSelection && !fShowingPopUpMenu && fIsActiveWin) {
|
||||||
if (fHideCursorCountDown <= 0)
|
if (fHideCursorCountDown <= 0)
|
||||||
@@ -1280,9 +1264,7 @@ ShowImageView::KeyDown(const char* bytes, int32 numBytes)
|
|||||||
break;
|
break;
|
||||||
case B_ESCAPE:
|
case B_ESCAPE:
|
||||||
// stop slide show
|
// stop slide show
|
||||||
if (fSlideShow)
|
_StopSlideShow();
|
||||||
_ToggleSlideShow();
|
|
||||||
|
|
||||||
_ExitFullScreen();
|
_ExitFullScreen();
|
||||||
|
|
||||||
ClearSelection();
|
ClearSelection();
|
||||||
@@ -1642,43 +1624,6 @@ ShowImageView::FitToBounds()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ShowImageView::SetSlideShowDelay(float seconds)
|
|
||||||
{
|
|
||||||
ShowImageSettings* settings;
|
|
||||||
int32 delay = (int)(seconds * 10.0);
|
|
||||||
if (fSlideShowDelay != delay) {
|
|
||||||
// update counter
|
|
||||||
fSlideShowCountDown = delay - (fSlideShowDelay - fSlideShowCountDown);
|
|
||||||
if (fSlideShowCountDown <= 0) {
|
|
||||||
// show next image on next Pulse()
|
|
||||||
fSlideShowCountDown = 1;
|
|
||||||
}
|
|
||||||
fSlideShowDelay = delay;
|
|
||||||
settings = my_app->Settings();
|
|
||||||
if (settings->Lock()) {
|
|
||||||
settings->SetInt32("SlideShowDelay", fSlideShowDelay);
|
|
||||||
settings->Unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ShowImageView::StartSlideShow()
|
|
||||||
{
|
|
||||||
fSlideShow = true;
|
|
||||||
fSlideShowCountDown = fSlideShowDelay;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ShowImageView::StopSlideShow()
|
|
||||||
{
|
|
||||||
fSlideShow = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageView::_DoImageOperation(ImageProcessor::operation op, bool quiet)
|
ShowImageView::_DoImageOperation(ImageProcessor::operation op, bool quiet)
|
||||||
{
|
{
|
||||||
@@ -1858,6 +1803,13 @@ ShowImageView::_ToggleSlideShow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ShowImageView::_StopSlideShow()
|
||||||
|
{
|
||||||
|
_SendMessageToWindow(kMsgStopSlideShow);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageView::_ExitFullScreen()
|
ShowImageView::_ExitFullScreen()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2010, Haiku, Inc. All Rights Reserved.
|
* Copyright 2003-2011, 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.
|
||||||
@@ -87,13 +87,6 @@ public:
|
|||||||
|
|
||||||
void CopySelectionToClipboard();
|
void CopySelectionToClipboard();
|
||||||
|
|
||||||
void SetSlideShowDelay(float seconds);
|
|
||||||
float GetSlideShowDelay() const
|
|
||||||
{ return fSlideShowDelay / 10.0; }
|
|
||||||
bool SlideShowStarted() const { return fSlideShow; }
|
|
||||||
void StartSlideShow();
|
|
||||||
void StopSlideShow();
|
|
||||||
|
|
||||||
void FitToBounds();
|
void FitToBounds();
|
||||||
void SetZoom(float zoom,
|
void SetZoom(float zoom,
|
||||||
BPoint where = BPoint(-1, -1));
|
BPoint where = BPoint(-1, -1));
|
||||||
@@ -183,6 +176,7 @@ private:
|
|||||||
void _SettingsSetBool(const char* name, bool value);
|
void _SettingsSetBool(const char* name, bool value);
|
||||||
void _SetIcon(bool clear, icon_size which);
|
void _SetIcon(bool clear, icon_size which);
|
||||||
void _ToggleSlideShow();
|
void _ToggleSlideShow();
|
||||||
|
void _StopSlideShow();
|
||||||
void _ExitFullScreen();
|
void _ExitFullScreen();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -214,12 +208,6 @@ private:
|
|||||||
// the portion of the background bitmap the selection is made
|
// the portion of the background bitmap the selection is made
|
||||||
// from
|
// from
|
||||||
|
|
||||||
bool fSlideShow;
|
|
||||||
int fSlideShowDelay;
|
|
||||||
// in pulse rate units
|
|
||||||
int fSlideShowCountDown;
|
|
||||||
// shows next image if it reaches zero
|
|
||||||
|
|
||||||
bool fShowCaption;
|
bool fShowCaption;
|
||||||
BString fCaption;
|
BString fCaption;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2010, Haiku, Inc. All Rights Reserved.
|
* Copyright 2003-2011, 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.
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
#include <Menu.h>
|
#include <Menu.h>
|
||||||
#include <MenuBar.h>
|
#include <MenuBar.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
|
#include <MessageRunner.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
#include <PrintJob.h>
|
#include <PrintJob.h>
|
||||||
#include <RecentItems.h>
|
#include <RecentItems.h>
|
||||||
@@ -57,6 +58,9 @@
|
|||||||
const char* kTypeField = "be:type";
|
const char* kTypeField = "be:type";
|
||||||
const char* kTranslatorField = "be:translator";
|
const char* kTranslatorField = "be:translator";
|
||||||
|
|
||||||
|
const bigtime_t kDefaultSlideShowDelay = 3000000;
|
||||||
|
// 3 seconds
|
||||||
|
|
||||||
|
|
||||||
// message constants
|
// message constants
|
||||||
enum {
|
enum {
|
||||||
@@ -88,7 +92,8 @@ enum {
|
|||||||
MSG_PREPARE_PRINT = 'mPPT',
|
MSG_PREPARE_PRINT = 'mPPT',
|
||||||
kMsgFitToWindow = 'mFtW',
|
kMsgFitToWindow = 'mFtW',
|
||||||
kMsgOriginalSize = 'mOSZ',
|
kMsgOriginalSize = 'mOSZ',
|
||||||
kMsgStretchToWindow = 'mStW'
|
kMsgStretchToWindow = 'mStW',
|
||||||
|
kMsgNextSlide = 'mNxS'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -120,14 +125,16 @@ ShowImageWindow::ShowImageWindow(const entry_ref& ref,
|
|||||||
fBar(NULL),
|
fBar(NULL),
|
||||||
fBrowseMenu(NULL),
|
fBrowseMenu(NULL),
|
||||||
fGoToPageMenu(NULL),
|
fGoToPageMenu(NULL),
|
||||||
fSlideShowDelay(NULL),
|
fSlideShowDelayMenu(NULL),
|
||||||
fImageView(NULL),
|
fImageView(NULL),
|
||||||
fStatusView(NULL),
|
fStatusView(NULL),
|
||||||
fProgressWindow(new ProgressWindow()),
|
fProgressWindow(new ProgressWindow()),
|
||||||
fModified(false),
|
fModified(false),
|
||||||
fFullScreen(false),
|
fFullScreen(false),
|
||||||
fShowCaption(true),
|
fShowCaption(true),
|
||||||
fPrintSettings(NULL)
|
fPrintSettings(NULL),
|
||||||
|
fSlideShowRunner(NULL),
|
||||||
|
fSlideShowDelay(kDefaultSlideShowDelay)
|
||||||
{
|
{
|
||||||
_ApplySettings();
|
_ApplySettings();
|
||||||
|
|
||||||
@@ -210,6 +217,8 @@ ShowImageWindow::~ShowImageWindow()
|
|||||||
{
|
{
|
||||||
fProgressWindow->Lock();
|
fProgressWindow->Lock();
|
||||||
fProgressWindow->Quit();
|
fProgressWindow->Quit();
|
||||||
|
|
||||||
|
_StopSlideShow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -228,25 +237,23 @@ void
|
|||||||
ShowImageWindow::_BuildViewMenu(BMenu* menu, bool popupMenu)
|
ShowImageWindow::_BuildViewMenu(BMenu* menu, bool popupMenu)
|
||||||
{
|
{
|
||||||
_AddItemMenu(menu, B_TRANSLATE("Slide show"), MSG_SLIDE_SHOW, 0, 0, this);
|
_AddItemMenu(menu, B_TRANSLATE("Slide show"), MSG_SLIDE_SHOW, 0, 0, this);
|
||||||
_MarkMenuItem(menu, MSG_SLIDE_SHOW, fImageView->SlideShowStarted());
|
_MarkMenuItem(menu, MSG_SLIDE_SHOW, fSlideShowRunner != NULL);
|
||||||
BMenu* delayMenu = new BMenu(B_TRANSLATE("Slide delay"));
|
BMenu* delayMenu = new BMenu(B_TRANSLATE("Slide delay"));
|
||||||
if (fSlideShowDelay == NULL)
|
if (fSlideShowDelayMenu == NULL)
|
||||||
fSlideShowDelay = delayMenu;
|
fSlideShowDelayMenu = delayMenu;
|
||||||
|
|
||||||
delayMenu->SetRadioMode(true);
|
delayMenu->SetRadioMode(true);
|
||||||
// Note: ShowImage loads images in window thread so it becomes unresponsive
|
|
||||||
// if slide show delay is too short! (Especially if loading the image
|
int32 kDelays[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 20};
|
||||||
// takes as long as or longer than the slide show delay). Should load
|
for (uint32 i = 0; i < sizeof(kDelays) / sizeof(kDelays[0]); i++) {
|
||||||
// in background thread!
|
BString text(B_TRANSLATE_COMMENT("%SECONDS seconds",
|
||||||
_AddDelayItem(delayMenu, B_TRANSLATE("3 seconds"), 3);
|
"Don't translate %SECONDS"));
|
||||||
_AddDelayItem(delayMenu, B_TRANSLATE("4 seconds"), 4);
|
char seconds[32];
|
||||||
_AddDelayItem(delayMenu, B_TRANSLATE("5 seconds"), 5);
|
snprintf(seconds, sizeof(seconds), "%" B_PRIi32, kDelays[i]);
|
||||||
_AddDelayItem(delayMenu, B_TRANSLATE("6 seconds"), 6);
|
text.ReplaceFirst("%SECONDS", seconds);
|
||||||
_AddDelayItem(delayMenu, B_TRANSLATE("7 seconds"), 7);
|
|
||||||
_AddDelayItem(delayMenu, B_TRANSLATE("8 seconds"), 8);
|
_AddDelayItem(delayMenu, text.String(), kDelays[i] * 1000000LL);
|
||||||
_AddDelayItem(delayMenu, B_TRANSLATE("9 seconds"), 9);
|
}
|
||||||
_AddDelayItem(delayMenu, B_TRANSLATE("10 seconds"), 10);
|
|
||||||
_AddDelayItem(delayMenu, B_TRANSLATE("20 seconds"), 20);
|
|
||||||
menu->AddItem(delayMenu);
|
menu->AddItem(delayMenu);
|
||||||
|
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
@@ -387,16 +394,15 @@ ShowImageWindow::_AddItemMenu(BMenu* menu, const char* label, uint32 what,
|
|||||||
|
|
||||||
|
|
||||||
BMenuItem*
|
BMenuItem*
|
||||||
ShowImageWindow::_AddDelayItem(BMenu* menu, const char* label, float value)
|
ShowImageWindow::_AddDelayItem(BMenu* menu, const char* label, bigtime_t delay)
|
||||||
{
|
{
|
||||||
BMessage* message = new BMessage(MSG_SLIDE_SHOW_DELAY);
|
BMessage* message = new BMessage(MSG_SLIDE_SHOW_DELAY);
|
||||||
message->AddFloat("value", value);
|
message->AddInt64("delay", delay);
|
||||||
|
|
||||||
BMenuItem* item = new BMenuItem(label, message, 0);
|
BMenuItem* item = new BMenuItem(label, message, 0);
|
||||||
item->SetTarget(this);
|
item->SetTarget(this);
|
||||||
|
|
||||||
bool marked = fImageView->GetSlideShowDelay() == value;
|
if (delay == fSlideShowDelay)
|
||||||
if (marked)
|
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
|
|
||||||
menu->AddItem(item);
|
menu->AddItem(item);
|
||||||
@@ -479,16 +485,16 @@ ShowImageWindow::_MarkMenuItem(BMenu* menu, uint32 what, bool marked)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageWindow::_MarkSlideShowDelay(float value)
|
ShowImageWindow::_MarkSlideShowDelay(bigtime_t delay)
|
||||||
{
|
{
|
||||||
const int32 n = fSlideShowDelay->CountItems();
|
const int32 count = fSlideShowDelayMenu->CountItems();
|
||||||
float v;
|
for (int32 i = 0; i < count; i ++) {
|
||||||
for (int32 i = 0; i < n; i ++) {
|
BMenuItem* item = fSlideShowDelayMenu->ItemAt(i);
|
||||||
BMenuItem* item = fSlideShowDelay->ItemAt(i);
|
if (item != NULL) {
|
||||||
if (item) {
|
bigtime_t itemDelay;
|
||||||
if (item->Message()->FindFloat("value", &v) == B_OK && v == value) {
|
if (item->Message()->FindInt64("delay", &itemDelay) == B_OK
|
||||||
if (!item->IsMarked())
|
&& itemDelay == delay) {
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -760,6 +766,7 @@ ShowImageWindow::MessageReceived(BMessage* message)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_FILE_NEXT:
|
case MSG_FILE_NEXT:
|
||||||
|
case kMsgNextSlide:
|
||||||
if (_ClosePrompt() && fNavigator.NextFile())
|
if (_ClosePrompt() && fNavigator.NextFile())
|
||||||
_LoadImage();
|
_LoadImage();
|
||||||
break;
|
break;
|
||||||
@@ -792,25 +799,36 @@ ShowImageWindow::MessageReceived(BMessage* message)
|
|||||||
case MSG_SLIDE_SHOW:
|
case MSG_SLIDE_SHOW:
|
||||||
{
|
{
|
||||||
BMenuItem* item = fBar->FindItem(message->what);
|
BMenuItem* item = fBar->FindItem(message->what);
|
||||||
if (!item)
|
if (item == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (item->IsMarked()) {
|
if (item->IsMarked()) {
|
||||||
item->SetMarked(false);
|
item->SetMarked(false);
|
||||||
fImageView->StopSlideShow();
|
_StopSlideShow();
|
||||||
} else if (_ClosePrompt()) {
|
} else if (_ClosePrompt()) {
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
fImageView->StartSlideShow();
|
_StartSlideShow();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case kMsgStopSlideShow:
|
||||||
|
{
|
||||||
|
BMenuItem* item = fBar->FindItem(MSG_SLIDE_SHOW);
|
||||||
|
if (item != NULL)
|
||||||
|
item->SetMarked(false);
|
||||||
|
|
||||||
|
_StopSlideShow();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case MSG_SLIDE_SHOW_DELAY:
|
case MSG_SLIDE_SHOW_DELAY:
|
||||||
{
|
{
|
||||||
float value;
|
bigtime_t delay;
|
||||||
if (message->FindFloat("value", &value) == B_OK) {
|
if (message->FindInt64("delay", &delay) == B_OK) {
|
||||||
fImageView->SetSlideShowDelay(value);
|
_SetSlideShowDelay(delay);
|
||||||
// in case message is sent from popup menu
|
// in case message is sent from popup menu
|
||||||
_MarkSlideShowDelay(value);
|
_MarkSlideShowDelay(delay);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1108,20 +1126,17 @@ ShowImageWindow::_ApplySettings()
|
|||||||
fShowCaption = settings->GetBool("ShowCaption", fShowCaption);
|
fShowCaption = settings->GetBool("ShowCaption", fShowCaption);
|
||||||
fPrintOptions.SetBounds(BRect(0, 0, 1023, 767));
|
fPrintOptions.SetBounds(BRect(0, 0, 1023, 767));
|
||||||
|
|
||||||
int32 op = settings->GetInt32("PO:Option", fPrintOptions.Option());
|
fSlideShowDelay = settings->GetTime("SlideShowDelay", fSlideShowDelay);
|
||||||
fPrintOptions.SetOption((enum PrintOptions::Option)op);
|
|
||||||
|
|
||||||
float f = settings->GetFloat("PO:ZoomFactor", fPrintOptions.ZoomFactor());
|
fPrintOptions.SetOption((enum PrintOptions::Option)settings->GetInt32(
|
||||||
fPrintOptions.SetZoomFactor(f);
|
"PO:Option", fPrintOptions.Option()));
|
||||||
|
fPrintOptions.SetZoomFactor(
|
||||||
f = settings->GetFloat("PO:DPI", fPrintOptions.DPI());
|
settings->GetFloat("PO:ZoomFactor", fPrintOptions.ZoomFactor()));
|
||||||
fPrintOptions.SetDPI(f);
|
fPrintOptions.SetDPI(settings->GetFloat("PO:DPI", fPrintOptions.DPI()));
|
||||||
|
fPrintOptions.SetWidth(
|
||||||
f = settings->GetFloat("PO:Width", fPrintOptions.Width());
|
settings->GetFloat("PO:Width", fPrintOptions.Width()));
|
||||||
fPrintOptions.SetWidth(f);
|
fPrintOptions.SetHeight(
|
||||||
|
settings->GetFloat("PO:Height", fPrintOptions.Height()));
|
||||||
f = settings->GetFloat("PO:Height", fPrintOptions.Height());
|
|
||||||
fPrintOptions.SetHeight(f);
|
|
||||||
|
|
||||||
settings->Unlock();
|
settings->Unlock();
|
||||||
}
|
}
|
||||||
@@ -1249,6 +1264,45 @@ ShowImageWindow::_Print(BMessage* msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ShowImageWindow::_SetSlideShowDelay(bigtime_t delay)
|
||||||
|
{
|
||||||
|
if (fSlideShowDelay == delay)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fSlideShowDelay = delay;
|
||||||
|
|
||||||
|
ShowImageSettings* settings = my_app->Settings();
|
||||||
|
if (settings->Lock()) {
|
||||||
|
settings->SetTime("SlideShowDelay", fSlideShowDelay);
|
||||||
|
settings->Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fSlideShowRunner != NULL)
|
||||||
|
_StartSlideShow();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ShowImageWindow::_StartSlideShow()
|
||||||
|
{
|
||||||
|
_StopSlideShow();
|
||||||
|
|
||||||
|
BMessage nextSlide(kMsgNextSlide);
|
||||||
|
fSlideShowRunner = new BMessageRunner(this, &nextSlide, fSlideShowDelay);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ShowImageWindow::_StopSlideShow()
|
||||||
|
{
|
||||||
|
if (fSlideShowRunner != NULL) {
|
||||||
|
delete fSlideShowRunner;
|
||||||
|
fSlideShowRunner = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ShowImageWindow::QuitRequested()
|
ShowImageWindow::QuitRequested()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2010, Haiku, Inc. All Rights Reserved.
|
* Copyright 2003-2011, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -21,6 +21,7 @@ class BFilePanel;
|
|||||||
class BMenu;
|
class BMenu;
|
||||||
class BMenuBar;
|
class BMenuBar;
|
||||||
class BMenuItem;
|
class BMenuItem;
|
||||||
|
class BMessageRunner;
|
||||||
class ProgressWindow;
|
class ProgressWindow;
|
||||||
class ShowImageView;
|
class ShowImageView;
|
||||||
class ShowImageStatusView;
|
class ShowImageStatusView;
|
||||||
@@ -36,6 +37,7 @@ enum {
|
|||||||
MSG_FILE_PREV = 'mFLP',
|
MSG_FILE_PREV = 'mFLP',
|
||||||
kMsgDeleteCurrentFile = 'mDcF',
|
kMsgDeleteCurrentFile = 'mDcF',
|
||||||
MSG_SLIDE_SHOW = 'mSSW',
|
MSG_SLIDE_SHOW = 'mSSW',
|
||||||
|
kMsgStopSlideShow = 'msss',
|
||||||
MSG_EXIT_FULL_SCREEN = 'mEFS'
|
MSG_EXIT_FULL_SCREEN = 'mEFS'
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -62,14 +64,14 @@ private:
|
|||||||
const BHandler* target,
|
const BHandler* target,
|
||||||
bool enabled = true);
|
bool enabled = true);
|
||||||
BMenuItem* _AddDelayItem(BMenu* menu, const char* label,
|
BMenuItem* _AddDelayItem(BMenu* menu, const char* label,
|
||||||
float value);
|
bigtime_t delay);
|
||||||
|
|
||||||
bool _ToggleMenuItem(uint32 what);
|
bool _ToggleMenuItem(uint32 what);
|
||||||
void _EnableMenuItem(BMenu* menu, uint32 what,
|
void _EnableMenuItem(BMenu* menu, uint32 what,
|
||||||
bool enable);
|
bool enable);
|
||||||
void _MarkMenuItem(BMenu* menu, uint32 what,
|
void _MarkMenuItem(BMenu* menu, uint32 what,
|
||||||
bool marked);
|
bool marked);
|
||||||
void _MarkSlideShowDelay(float value);
|
void _MarkSlideShowDelay(bigtime_t delay);
|
||||||
|
|
||||||
void _UpdateStatusText(const BMessage* message);
|
void _UpdateStatusText(const BMessage* message);
|
||||||
void _LoadError(const entry_ref& ref);
|
void _LoadError(const entry_ref& ref);
|
||||||
@@ -87,13 +89,17 @@ private:
|
|||||||
void _PrepareForPrint();
|
void _PrepareForPrint();
|
||||||
void _Print(BMessage* msg);
|
void _Print(BMessage* msg);
|
||||||
|
|
||||||
|
void _SetSlideShowDelay(bigtime_t delay);
|
||||||
|
void _StartSlideShow();
|
||||||
|
void _StopSlideShow();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ImageFileNavigator fNavigator;
|
ImageFileNavigator fNavigator;
|
||||||
BFilePanel* fSavePanel;
|
BFilePanel* fSavePanel;
|
||||||
BMenuBar* fBar;
|
BMenuBar* fBar;
|
||||||
BMenu* fBrowseMenu;
|
BMenu* fBrowseMenu;
|
||||||
BMenu* fGoToPageMenu;
|
BMenu* fGoToPageMenu;
|
||||||
BMenu* fSlideShowDelay;
|
BMenu* fSlideShowDelayMenu;
|
||||||
ShowImageView* fImageView;
|
ShowImageView* fImageView;
|
||||||
ShowImageStatusView* fStatusView;
|
ShowImageStatusView* fStatusView;
|
||||||
ProgressWindow* fProgressWindow;
|
ProgressWindow* fProgressWindow;
|
||||||
@@ -105,6 +111,9 @@ private:
|
|||||||
PrintOptions fPrintOptions;
|
PrintOptions fPrintOptions;
|
||||||
|
|
||||||
BString fImageType;
|
BString fImageType;
|
||||||
|
|
||||||
|
BMessageRunner* fSlideShowRunner;
|
||||||
|
bigtime_t fSlideShowDelay;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user