Final changes before redesign. Fixed some issues with module preview lifetimes and added initial support for actually saving prefs, but just as likely broke much more.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1506 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -16,7 +16,7 @@ struct
|
|||||||
bool stopMe;
|
bool stopMe;
|
||||||
} previewData;
|
} previewData;
|
||||||
|
|
||||||
// viewer thread?
|
// viewer thread
|
||||||
int32 previewThread(void* data)
|
int32 previewThread(void* data)
|
||||||
{
|
{
|
||||||
int cycleNumber = 0;
|
int cycleNumber = 0;
|
||||||
@@ -26,18 +26,30 @@ int32 previewThread(void* data)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: implement lood counting
|
|
||||||
int32 loopOnCount = previewData.saver->LoopOnCount();
|
int32 loopOnCount = previewData.saver->LoopOnCount();
|
||||||
|
int32 loopOnCounter = 0;
|
||||||
int32 loopOffCount = previewData.saver->LoopOffCount();
|
int32 loopOffCount = previewData.saver->LoopOffCount();
|
||||||
|
int32 loopOffCounter = 0;
|
||||||
|
|
||||||
|
if (loopOnCount == 0 && loopOffCount == 0)
|
||||||
|
{
|
||||||
|
// TODO: fill in setup for "normal" loop counting here?
|
||||||
|
}
|
||||||
|
|
||||||
|
snooze( previewData.saver->TickSize() );
|
||||||
while (!previewData.stopMe)
|
while (!previewData.stopMe)
|
||||||
{
|
{
|
||||||
previewData.previewArea->Window()->Lock();
|
if (previewData.previewArea->Window()->Lock())
|
||||||
previewData.saver->Draw( previewData.previewArea, cycleNumber );
|
{
|
||||||
previewData.previewArea->Window()->Unlock();
|
if (!previewData.previewArea->IsHidden())
|
||||||
previewData.previewArea->Flush();
|
{
|
||||||
|
previewData.saver->Draw( previewData.previewArea, cycleNumber );
|
||||||
|
}
|
||||||
|
previewData.previewArea->Window()->Unlock();
|
||||||
|
// previewData.previewArea->Flush();
|
||||||
|
}
|
||||||
snooze( previewData.saver->TickSize() );
|
snooze( previewData.saver->TickSize() );
|
||||||
cycleNumber++;
|
++cycleNumber;
|
||||||
}
|
}
|
||||||
} // end previewThread()
|
} // end previewThread()
|
||||||
|
|
||||||
@@ -62,7 +74,6 @@ PreviewView::PreviewView(BRect frame, const char *name)
|
|||||||
saver (0),
|
saver (0),
|
||||||
settingsBoxPtr (0),
|
settingsBoxPtr (0),
|
||||||
configView (0),
|
configView (0),
|
||||||
messageRunner (0),
|
|
||||||
stopSaver (false),
|
stopSaver (false),
|
||||||
stopConfigView (false),
|
stopConfigView (false),
|
||||||
removeConfigView (false),
|
removeConfigView (false),
|
||||||
@@ -122,7 +133,7 @@ PreviewView::~PreviewView()
|
|||||||
previewArea->RemoveSelf();
|
previewArea->RemoveSelf();
|
||||||
delete previewArea;
|
delete previewArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end PreviewView::~PreviewView()
|
} // end PreviewView::~PreviewView()
|
||||||
|
|
||||||
void PreviewView::Draw(BRect update)
|
void PreviewView::Draw(BRect update)
|
||||||
@@ -145,7 +156,7 @@ void PreviewView::Draw(BRect update)
|
|||||||
FillRect(scale2(5,6,4,5,Bounds()));
|
FillRect(scale2(5,6,4,5,Bounds()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreviewView::LoadNewAddon(const char* addOnFilename)
|
void PreviewView::LoadNewAddon(const char* addOnFilename, BMessage* settingsMsg)
|
||||||
{
|
{
|
||||||
if (previewData.previewThreadId != 0)
|
if (previewData.previewThreadId != 0)
|
||||||
{
|
{
|
||||||
@@ -230,7 +241,7 @@ void PreviewView::LoadNewAddon(const char* addOnFilename)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
saver = instantiate(new BMessage, addonImage);
|
saver = instantiate(settingsMsg, addonImage);
|
||||||
if (saver == 0)
|
if (saver == 0)
|
||||||
{
|
{
|
||||||
std::cout << "Saver not instantiated.\n";
|
std::cout << "Saver not instantiated.\n";
|
||||||
|
|||||||
@@ -12,18 +12,17 @@ public:
|
|||||||
PreviewView(BRect frame, const char *name);
|
PreviewView(BRect frame, const char *name);
|
||||||
~PreviewView();
|
~PreviewView();
|
||||||
void Draw(BRect update);
|
void Draw(BRect update);
|
||||||
void LoadNewAddon(const char* addOnFilename);
|
void LoadNewAddon(const char* addOnFilename, BMessage* settingsMsg);
|
||||||
|
|
||||||
void SetSettingsBoxPtr( BBox* settingsBox )
|
void SetSettingsBoxPtr( BBox* settingsBox )
|
||||||
{ settingsBoxPtr = settingsBox; }
|
{ settingsBoxPtr = settingsBox; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BView *previewArea;
|
BView *previewArea;
|
||||||
BBox *settingsBoxPtr;
|
BBox *settingsBoxPtr;
|
||||||
BView *configView;
|
BView *configView;
|
||||||
image_id addonImage;
|
image_id addonImage;
|
||||||
BScreenSaver* saver;
|
BScreenSaver* saver;
|
||||||
BMessageRunner* messageRunner;
|
|
||||||
|
|
||||||
// to keep track of what to tear down
|
// to keep track of what to tear down
|
||||||
bool stopSaver;
|
bool stopSaver;
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ struct SSListItem
|
|||||||
|
|
||||||
void ScreenSaver::MessageReceived(BMessage *msg)
|
void ScreenSaver::MessageReceived(BMessage *msg)
|
||||||
{
|
{
|
||||||
|
SSListItem* listItem;
|
||||||
switch(msg->what)
|
switch(msg->what)
|
||||||
{
|
{
|
||||||
case TAB1_CHG:
|
case TAB1_CHG:
|
||||||
@@ -53,8 +54,12 @@ void ScreenSaver::MessageReceived(BMessage *msg)
|
|||||||
break;
|
break;
|
||||||
case SAVER_SEL:
|
case SAVER_SEL:
|
||||||
updateStatus();
|
updateStatus();
|
||||||
SelectedAddonFileName = reinterpret_cast<SSListItem*>(AddonList->ItemAt(ListView1->CurrentSelection()))->fileName;
|
listItem = reinterpret_cast<SSListItem*>(AddonList->ItemAt(ListView1->CurrentSelection()));
|
||||||
previewDisplay->LoadNewAddon(SelectedAddonFileName.String());
|
//BString settingsMsgName(listItem->fileName);
|
||||||
|
//settingsMsgName.Prepend("settings_");
|
||||||
|
//BMessage thisModulesSettings;
|
||||||
|
//settingsMsg.FindMessage(settingsMsgName, &thisModulesSettings);
|
||||||
|
previewDisplay->LoadNewAddon(listItem->fileName.String(), &settings);
|
||||||
BWindow::MessageReceived(msg);
|
BWindow::MessageReceived(msg);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -213,9 +218,8 @@ void ScreenSaver::SetupForm(void)
|
|||||||
find_directory(B_USER_SETTINGS_DIRECTORY,&path);
|
find_directory(B_USER_SETTINGS_DIRECTORY,&path);
|
||||||
path.Append("OBOS_Screen_Saver",true);
|
path.Append("OBOS_Screen_Saver",true);
|
||||||
BFile file(path.Path(),B_READ_ONLY);
|
BFile file(path.Path(),B_READ_ONLY);
|
||||||
BMessage msg;
|
settings.Unflatten(&file);
|
||||||
msg.Unflatten(&file);
|
loadSettings (&settings);
|
||||||
loadSettings (&msg);
|
|
||||||
updateStatus();
|
updateStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ private:
|
|||||||
pwWindow *pwWin;
|
pwWindow *pwWin;
|
||||||
BMessenger *pwMessenger;
|
BMessenger *pwMessenger;
|
||||||
|
|
||||||
|
BMessage settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _ScreenSaver_H
|
#endif // _ScreenSaver_H
|
||||||
|
|||||||
Reference in New Issue
Block a user