- Changed workunit area to use a static image rather then an animiated gif

- Center the image within the space and resize it dyanmically if necessary to fit
    	  within the allocated space

svn path=/trunk/boinc/; revision=11215
This commit is contained in:
Kevin Reed 2006-09-29 16:01:17 +00:00
parent a3ad40ffaf
commit 3672429df3
13 changed files with 96 additions and 55 deletions

View File

@ -44,8 +44,12 @@ void CImageButton::OnPaint(wxPaintEvent& WXUNUSED(event))
{
dc.SetTextForeground(wxColour(*wxWHITE));
dc.SetFont(wxFont(7,74,90,90,0,wxT("Arial")));
dc.DrawText(wxT("> Show real-time"), wxPoint(220,120));
dc.DrawText(wxT("graphics"), wxPoint(230,130));
wxString text = wxString(wxT("> Show real-time graphics"));
wxCoord width, height;
dc.GetTextExtent(text, &width, &height);
int x, y;
GetSize(&x,&y);
dc.DrawText(text, wxPoint(x-width-7,y-height-4));
}
}
void CImageButton::SetImage(wxBitmap bg)

View File

@ -28,8 +28,9 @@ BEGIN_EVENT_TABLE(ImageLoader, wxWindow)
EVT_PAINT(ImageLoader::OnPaint)
END_EVENT_TABLE()
ImageLoader::ImageLoader(wxWindow* parent) : wxWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNO_BORDER)
ImageLoader::ImageLoader(wxWindow* parent, bool center) : wxWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNO_BORDER)
{
centerOnParent = center;
}
void ImageLoader::LoadImage(wxBitmap image)
{
@ -37,6 +38,9 @@ void ImageLoader::LoadImage(wxBitmap image)
int height = image.GetHeight();
Bitmap = image;
SetSize(width, height);
if ( centerOnParent ) {
CentreOnParent();
}
}
void ImageLoader::OnPaint(wxPaintEvent& WXUNUSED(event))

View File

@ -28,13 +28,14 @@ class ImageLoader : public wxWindow
{
public:
/// Constructors
ImageLoader(wxWindow* parent);
ImageLoader(wxWindow* parent, bool center = false);
void LoadImage(wxBitmap image);
void OnPaint(wxPaintEvent& event);
private:
//static const int MaxWidth = 320;
//static const int MaxHeight = 240;
wxBitmap Bitmap;
bool centerOnParent;
DECLARE_EVENT_TABLE()
};

View File

@ -60,7 +60,7 @@ bool SkinClass::CheckSkin()
return false;//skin xml file is not available
}
if ( skinImageNames.size() != 35 ) {
if ( skinImageNames.size() != 36 ) {
return false;
}
@ -174,8 +174,7 @@ int SkinClass::LoadSkinXML(){
} else if (GetImageName(buf, "right_arrow_button")){
} else if (GetImageName(buf, "right_arrow_clicked_button")){
} else if (GetImageName(buf, "animation_background")){
} else if (parse_str(buf, "<default_animation", val)){
SetAnimationFile(wxString( val.c_str(), wxConvUTF8 ));
} else if (GetImageName(buf, "default_wu_image")){
} else if (match_tag(buf, "<icons")) {
while (mf.fgets(buf, 256)) {
std::string val;

View File

@ -83,8 +83,8 @@ public:
wxBitmap* GetIcnWorkingWkUnit() { return skinImages[wxString(_T("workingWkUnit"))]; }
wxBitmap* GetDefaultStatIcn() { return skinImages[wxString(_T("defaultStatIcon"))]; }
wxBitmap* GetAnimationBg() { return skinImages[wxString(_T("animation_background"))]; }
wxString GetAnimationFile() const { return m_animFile; }
wxBitmap* GetDefaultWorkunitImage() { return skinImages[wxString(_T("default_wu_image"))]; }
wxString GetSkinName() const { return m_skinName; }
wxString GetSkinsFolder() const { return m_skinsFolder; }

View File

@ -102,28 +102,13 @@ void CViewTabPage::CreatePage()
// project image behind graphic <><><>
btnAminBg = new CImageButton(this,*(appSkin->GetAnimationBg()),wxPoint(28,154),wxSize(294,146),m_hasGraphic);
//// Animation Window
wAnimWk1=new wxWindow(this,-1,wxPoint(98,156),wxSize(148,142),wxNO_BORDER);
// media control
/////////////
m_canvas = new MyCanvas(wAnimWk1, wxPoint(0,0), wxSize(148,142));
#if 0
m_player.SetDestroyAnimation(false);
m_player.SetWindow(m_canvas);
m_player.SetPosition(wxPoint(0, 0));
#endif
m_animationCtrl = new wxGIFAnimationCtrl(m_canvas, -1, wxEmptyString,
wxPoint(0, 0), wxSize(148, 142));
m_animationCtrl->GetPlayer().UseBackgroundColour(true);
m_animationCtrl->Stop();
if (m_animationCtrl->LoadFile(appSkin->ComputeSkinDir() + wxString(_T("/")) + appSkin->GetAnimationFile()))
{
m_animationCtrl->Play();
}
else
{
wxMessageBox(_T("Sorry, this animation was not a valid animated GIF."));
}
CreateSlideShowWindow();
}
std::vector<wxBitmap> CViewTabPage::GetSlideShow() {
std::vector<wxBitmap> vSlideShow;
vSlideShow.push_back(*(appSkin->GetDefaultWorkunitImage()));
return vSlideShow;
}
void CViewTabPage::UpdateInterface()
{
@ -145,13 +130,33 @@ void CViewTabPage::UpdateInterface()
DrawText();
// check to see if we can display graphics
bool changed = false;
if (resultWU->supports_graphics && resultWU->active_task_state == 1) {
if ( !m_hasGraphic ) {
changed = true;
}
m_hasGraphic = true;
} else {
if ( m_hasGraphic ) {
changed = true;
}
m_hasGraphic = false;
}
btnAminBg->SetShowText(m_hasGraphic);
if ( changed ) {
btnAminBg->Update();
m_canvas->Refresh();
m_canvas->Update();
}
}
void CViewTabPage::CreateSlideShowWindow() {
// wAnimWk1=new wxWindow(this,-1,wxPoint(98,156),wxSize(148,142),wxNO_BORDER);
if ( wSlideShow <= NULL ) {
delete wSlideShow;
}
wSlideShow=new wxWindow(this,-1,wxPoint(32,158),wxSize(286,128),wxNO_BORDER);
// m_canvas = new MyCanvas(wAnimWk1, wxPoint(0,0), wxSize(148,142), GetSlideShow());
m_canvas = new MyCanvas(wSlideShow, wxPoint(0,0), wxSize(286,128), GetSlideShow());
}
void CViewTabPage::ReskinInterface()
{
@ -161,6 +166,7 @@ void CViewTabPage::ReskinInterface()
lnProjName->SetLineColor(appSkin->GetStaticLineCol());
// gauge
gaugeWUMain->ReskinInterface();
CreateSlideShowWindow();
}
@ -356,24 +362,49 @@ BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow)
END_EVENT_TABLE()
// Define a constructor for my canvas
MyCanvas::MyCanvas(wxWindow *parent, const wxPoint& pos, const wxSize& size)
MyCanvas::MyCanvas(wxWindow *parent, const wxPoint& pos, const wxSize& size, std::vector<wxBitmap> images)
: wxScrolledWindow(parent, -1, pos, size,
wxNO_BORDER |
wxNO_FULL_REPAINT_ON_RESIZE)
{
SetBackgroundColour(wxColour(_T("BLACK")));
wxBitmap* image;
ImageLoader* il;
double xRatio, yRatio, ratio;
for(unsigned int i=0; i < images.size(); i++) {
image = &(images.at(i));
// Check to see if they need to be rescaled to fit in the window
ratio = 1.0;
xRatio = ((double) size.GetWidth())/((double) image->GetWidth());
yRatio = ((double) size.GetHeight())/((double) image->GetHeight());
if ( xRatio < ratio ) {
ratio = xRatio;
}
if ( yRatio < ratio ) {
ratio = yRatio;
}
if ( ratio < 1.0 ) {
wxImage img = image->ConvertToImage();
img.Rescale((int) image->GetWidth()*ratio, (int) image->GetHeight()*ratio);
image = new wxBitmap(img);
}
il = new ImageLoader(this, true);
il->LoadImage(*image);
if ( ratio < 1.0 ) {
delete image;
}
il->Show(true);
vSlideShow.push_back(il);
}
}
void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event))
{
wxLogTrace(wxT("Function Start/End"), wxT("MyCanvas::OnPaint - Begin"));
wxPaintDC dc(this);
#if 0
CSimpleFrame* frame = (CSimpleFrame*) GetParent();
if (frame->GetPlayer().IsPlaying())
{
frame->GetPlayer().Draw(dc);
}
#endif
// if ( vSlideShow.size() > 0 && vSlideShow.at(0).Ok() ) {
// dc.DrawBitmap(vSlideShow.at(0),0,0,false);
// }
wxLogTrace(wxT("Function Start/End"), wxT("MyCanvas::OnPaint - End"));
}

View File

@ -24,13 +24,20 @@
#pragma interface "sg_ViewTabPage.cpp"
#endif
#include <vector>
#include "common/wxFlatNotebook.h"
#include "BOINCGUIApp.h"
#include "sg_ImageLoader.h"
class MyCanvas : public wxScrolledWindow
{
public:
MyCanvas(wxWindow *parent, const wxPoint& pos, const wxSize& size);
MyCanvas(wxWindow *parent, const wxPoint& pos, const wxSize& size, std::vector<wxBitmap> images);
void OnPaint(wxPaintEvent& event);
private:
std::vector<ImageLoader*> vSlideShow;
DECLARE_EVENT_TABLE()
};
@ -40,10 +47,6 @@ class CStaticLine;
class CStaticLine;
class CImageButton;
#include "BOINCGUIApp.h"
#include "common/wxAnimate.h"
#include "common/wxFlatNotebook.h"
class CViewTabPage : public wxPanel {
DECLARE_DYNAMIC_CLASS( CViewTabPage )
@ -56,7 +59,6 @@ public:
////////////////////
// animation
wxBitmap* btmpBgAnim;
wxWindow* wAnimWk1;
CImageButton * btnAminBg;
//line
CStaticLine *lnProjName;
@ -98,7 +100,6 @@ public:
// Animation
MyCanvas* GetCanvas() const { return m_canvas; }
wxGIFAnimationCtrl* GetAnimationCtrl() const { return m_animationCtrl; }
DECLARE_EVENT_TABLE()
@ -116,12 +117,13 @@ protected:
void OnEraseBackground(wxEraseEvent& event);
void DrawBackImg(wxEraseEvent& event,wxWindow *win,wxBitmap bitMap,int opz);
MyCanvas* m_canvas;
wxGIFAnimationCtrl* m_animationCtrl;
#if 0
wxAnimationPlayer m_player;
wxGIFAnimation m_animation;
#endif
private:
void CreateSlideShowWindow();
std::vector<wxBitmap> GetSlideShow();
wxWindow* wSlideShow;
MyCanvas* m_canvas;
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 268 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@ -35,7 +35,7 @@
<right_arrow_button>graphic/arwRight.png</right_arrow_button>
<right_arrow_clicked_button>graphic/arwRightClick.png</right_arrow_clicked_button>
<animation_background>graphic/project_image.png</animation_background>
<default_animation>graphic/molecule.gif</default_animation>
<default_wu_image>graphic/wcg_black_bacground.png</default_wu_image>
<icons>
<workingWkUnit>
<imgsrc>graphic/ico_workWU.png</imgsrc>

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 268 KiB

View File

@ -35,7 +35,7 @@
<right_arrow_button>graphic/arwRight.png</right_arrow_button>
<right_arrow_clicked_button>graphic/arwRightClick.png</right_arrow_clicked_button>
<animation_background>graphic/project_image.png</animation_background>
<default_animation>graphic/molecule.gif</default_animation>
<default_wu_image>graphic/boinc_black_background.png</default_wu_image>
<icons>
<workingWkUnit>
<imgsrc>graphic/ico_workWU.png</imgsrc>