Partial clean-up.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33910 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jonas Sundström
2009-11-05 23:39:57 +00:00
parent abf272eedb
commit dca191e9b7
8 changed files with 316 additions and 271 deletions
+25 -16
View File
@@ -35,8 +35,14 @@ All rights reserved.
// Classes used for setting up and managing background images
//
#include "BackgroundImage.h"
#include <new>
#include <stdlib.h>
#include <Bitmap.h>
#include <Debug.h>
#include <fs_attr.h>
#include <Node.h>
#include <TranslationKit.h>
#include <View.h>
@@ -47,14 +53,8 @@ All rights reserved.
#include <Screen.h>
#include <String.h>
#include <fs_attr.h>
#include <stdlib.h>
#include "BackgroundImage.h"
#include "BackgroundsView.h"
#include <new>
const char* kBackgroundImageInfo = "be:bgndimginfo";
const char* kBackgroundImageInfoOffset = "be:bgndimginfooffset";
@@ -104,7 +104,8 @@ BackgroundImage::GetBackgroundImage(const BNode *node, bool isDesktop,
if (isDesktop) {
container.FindInt32(kBackgroundImageSetPeriod, (int32*)&imageSetPeriod);
container.FindInt32(kBackgroundImageCacheMode, (int32 *)&globalCacheMode);
container.FindInt32(kBackgroundImageCacheMode,
(int32*)&globalCacheMode);
container.FindBool(kBackgroundImageRandomChange, &randomChange);
}
@@ -118,7 +119,8 @@ BackgroundImage::GetBackgroundImage(const BNode *node, bool isDesktop,
uint32 cacheMode = 0;
int32 imageIndex = -1;
if (container.FindString(kBackgroundImageInfoPath, index, &path) == B_OK) {
if (container.FindString(kBackgroundImageInfoPath, index, &path)
== B_OK) {
if (strcmp(path, "")) {
BPath bpath(path);
imageIndex = view->AddImage(bpath);
@@ -191,7 +193,8 @@ BackgroundImage::BackgroundImageInfo::~BackgroundImageInfo()
// #pragma mark -
BackgroundImage::BackgroundImage(const BNode *node, bool desktop, BackgroundsView* view)
BackgroundImage::BackgroundImage(const BNode* node, bool desktop,
BackgroundsView* view)
:
fIsDesktop(desktop),
fDefinedByNode(*node),
@@ -249,7 +252,8 @@ BackgroundImage::Show(BView *view, int32 workspace)
if (info) {
/*BPoseView* poseView = dynamic_cast<BPoseView*>(fView);
if (poseView)
poseView->SetEraseWidgetTextBackground(info->fTextWidgetLabelOutline);*/
poseView
->SetEraseWidgetTextBackground(info->fTextWidgetLabelOutline);*/
Show(info, fView);
}
}
@@ -258,7 +262,8 @@ BackgroundImage::Show(BView *view, int32 workspace)
void
BackgroundImage::Show(BackgroundImageInfo* info, BView* view)
{
BBitmap *bitmap = fBackgroundsView->GetImage(info->fImageIndex)->GetBitmap();
BBitmap* bitmap
= fBackgroundsView->GetImage(info->fImageIndex)->GetBitmap();
if (!bitmap)
return;
@@ -287,7 +292,8 @@ BackgroundImage::Show(BackgroundImageInfo *info, BView *view)
if (fIsDesktop) {
destinationBitmapBounds.OffsetBy(
(viewBounds.Width() - destinationBitmapBounds.Width()) / 2,
(viewBounds.Height() - destinationBitmapBounds.Height()) / 2);
(viewBounds.Height() - destinationBitmapBounds.Height())
/ 2);
break;
}
// else fall thru
@@ -304,7 +310,8 @@ BackgroundImage::Show(BackgroundImageInfo *info, BView *view)
break;
}
case kTiled:
// Original Backgrounds Preferences center the tiled paper but the Tracker don't do that
// Original Backgrounds Preferences center the tiled paper
// but Tracker doesn't do that
//if (fIsDesktop) {
destinationBitmapBounds.OffsetBy(
(viewBounds.Width() - destinationBitmapBounds.Width()) / 2,
@@ -416,8 +423,8 @@ BackgroundImage::ScreenChanged(BRect, color_space)
(viewBounds.Width() - bitmapBounds.Width()) / 2,
(viewBounds.Height() - bitmapBounds.Height()) / 2);
fView->SetViewBitmap(fShowingBitmap->fBitmap, bitmapBounds, destinationBitmapBounds,
B_FOLLOW_NONE, 0);
fView->SetViewBitmap(fShowingBitmap->fBitmap, bitmapBounds,
destinationBitmapBounds, B_FOLLOW_NONE, 0);
fView->Invalidate();
}*/
}
@@ -437,7 +444,8 @@ BackgroundImage::SetBackgroundImage(BNode *node)
info->fTextWidgetLabelOutline);
if (fBackgroundsView->GetImage(info->fImageIndex) != NULL) {
container.AddString(kBackgroundImageInfoPath,
fBackgroundsView->GetImage(info->fImageIndex)->GetPath().Path());
fBackgroundsView
->GetImage(info->fImageIndex)->GetPath().Path());
} else
container.AddString(kBackgroundImageInfoPath, "");
@@ -535,3 +543,4 @@ Image::GetBitmap()
return fBitmap;
}
@@ -38,13 +38,14 @@ All rights reserved.
#ifndef __BACKGROUND_IMAGE__
#define __BACKGROUND_IMAGE__
#include "String.h"
#include "ObjectList.h"
#include <GraphicsDefs.h>
#include <Node.h>
#include <Path.h>
#include "ObjectList.h"
#include "String.h"
class BView;
class BBitmap;
@@ -170,3 +171,4 @@ private:
};
#endif
+4 -3
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008, Haiku, Inc. All Rights Reserved.
* Copyright 2002-2009, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -8,13 +8,13 @@
*/
#include "BackgroundsView.h"
#include <Application.h>
#include <LayoutBuilder.h>
#include <TrackerAddOnAppLaunch.h>
#include <Window.h>
#include "BackgroundsView.h"
static const char* kSignature = "application/x-vnd.Haiku-Backgrounds";
@@ -61,6 +61,7 @@ BackgroundsApplication::RefsReceived(BMessage* message)
fWindow->RefsReceived(message);
}
// #pragma mark -
+16 -14
View File
@@ -10,7 +10,6 @@
#include "BackgroundsView.h"
#include "ImageFilePanel.h"
#include <stdio.h>
#include <stdlib.h>
@@ -28,6 +27,8 @@
#include <be_apps/Tracker/Background.h>
#include "ImageFilePanel.h"
static const uint32 kMsgApplySettings = 'aply';
static const uint32 kMsgRevertSettings = 'rvrt';
@@ -594,8 +595,8 @@ BackgroundsView::UpdateWithCurrent(void)
void
BackgroundsView::Save()
{
bool textWidgetLabelOutline =
fIconLabelOutline->Value() == B_CONTROL_ON;
bool textWidgetLabelOutline
= fIconLabelOutline->Value() == B_CONTROL_ON;
BackgroundImage::Mode mode = FindPlacementMode();
BPoint offset(atoi(fXPlacementText->Text()), atoi(fYPlacementText->Text()));
@@ -631,8 +632,8 @@ BackgroundsView::Save()
fCurrentInfo->fCacheMode);
fCurrent->Add(fCurrentInfo);
} else if (fCurrentInfo->fWorkspace == workspaceMask) {
fCurrentInfo->fTextWidgetLabelOutline =
textWidgetLabelOutline;
fCurrentInfo->fTextWidgetLabelOutline
= textWidgetLabelOutline;
fCurrentInfo->fMode = mode;
if (fCurrentInfo->fMode == BackgroundImage::kAtOffset)
fCurrentInfo->fOffset = offset;
@@ -895,8 +896,8 @@ BackgroundsView::UpdatePreview()
if (index >= 0) {
BBitmap* bitmap = GetImage(index)->GetBitmap();
if (bitmap) {
BackgroundImage::BackgroundImageInfo *info =
new BackgroundImage::BackgroundImageInfo(0, index,
BackgroundImage::BackgroundImageInfo* info
= new BackgroundImage::BackgroundImageInfo(0, index,
FindPlacementMode(), BPoint(atoi(fXPlacementText->Text()),
atoi(fYPlacementText->Text())),
fIconLabelOutline->Value() == B_CONTROL_ON, 0, 0);
@@ -944,20 +945,21 @@ BackgroundsView::UpdateButtons()
&& fPicker->ValueAsColor() != BScreen().DesktopColor()) {
hasChanged = true;
} else if (fCurrentInfo) {
if ((fIconLabelOutline->Value() == B_CONTROL_ON) ^
fCurrentInfo->fTextWidgetLabelOutline) {
if ((fIconLabelOutline->Value() == B_CONTROL_ON)
^ fCurrentInfo->fTextWidgetLabelOutline) {
hasChanged = true;
} else if (FindPlacementMode() != fCurrentInfo->fMode) {
hasChanged = true;
} else if (fCurrentInfo->fImageIndex !=
((BGImageMenuItem*)fImageMenu->FindMarked())->ImageIndex()) {
} else if (fCurrentInfo->fImageIndex
!= ((BGImageMenuItem*)fImageMenu->FindMarked())->ImageIndex()) {
hasChanged = true;
} else if (fCurrent->IsDesktop()
&& ((fCurrentInfo->fWorkspace != B_ALL_WORKSPACES)
^ (fWorkspaceMenu->FindItem(kMsgCurrentWorkspace)->IsMarked()))) {
^ (fWorkspaceMenu->FindItem(kMsgCurrentWorkspace)->IsMarked())))
{
hasChanged = true;
} else if (fCurrentInfo->fImageIndex > -1 &&
fCurrentInfo->fMode == BackgroundImage::kAtOffset) {
} else if (fCurrentInfo->fImageIndex > -1
&& fCurrentInfo->fMode == BackgroundImage::kAtOffset) {
BString oldString, newString;
oldString << (int)fCurrentInfo->fOffset.x;
if (oldString != BString(fXPlacementText->Text())) {
+36 -22
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007, Haiku, Inc. All Rights Reserved.
* Copyright 2002-2009, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -9,8 +9,6 @@
#define BACKGROUNDS_VIEW_H
#include "BackgroundImage.h"
#include <View.h>
#include <ColorControl.h>
#include <Message.h>
@@ -31,15 +29,20 @@
#include <StringView.h>
#include <Cursor.h>
#include "BackgroundImage.h"
#define SETTINGS_FILE "Backgrounds_settings"
class ImageFilePanel;
class BGImageMenuItem : public BMenuItem {
public:
BGImageMenuItem(const char *label, int32 imageIndex, BMessage *message,
char shortcut = 0, uint32 modifiers = 0);
BGImageMenuItem(const char* label, int32 imageIndex,
BMessage* message, char shortcut = 0,
uint32 modifiers = 0);
int32 ImageIndex() { return fImageIndex; }
@@ -85,11 +88,13 @@ class PreView : public BControl {
protected:
void MouseDown(BPoint point);
void MouseUp(BPoint point);
void MouseMoved(BPoint point, uint32 transit, const BMessage *message);
void MouseMoved(BPoint point, uint32 transit,
const BMessage* message);
void AttachedToWindow();
BPoint fOldPoint;
float x_ratio, y_ratio;
float x_ratio;
float y_ratio;
display_mode mode;
BCursor fMoveHandCursor;
@@ -104,7 +109,8 @@ class BackgroundsView : public BBox {
void RefsReceived(BMessage* msg);
void SaveSettings();
void WorkspaceActivated(uint32 oldWorkspaces, bool active);
void WorkspaceActivated(uint32 oldWorkspaces,
bool active);
int32 AddImage(BPath path);
Image* GetImage(int32 imageIndex);
@@ -129,25 +135,33 @@ class BackgroundsView : public BBox {
static int32 NotifyThread(void* data);
BGImageMenuItem* FindImageItem(const int32 imageIndex);
bool AddItem(BGImageMenuItem* item);
BackgroundImage::Mode FindPlacementMode();
BColorControl *fPicker; // color picker
BButton *fApply, *fRevert; // apply and revert buttons
BCheckBox *fIconLabelOutline; // label ckeckbox
BMenu* fPlacementMenu, *fImageMenu, *fWorkspaceMenu; // the three comboboxes
BTextControl *fXPlacementText, *fYPlacementText; // x and y textboxes
PreView *fPreView; // the view for previewing the result
BBox *fPreview; // the box which draws a computer/folder
BFilePanel *fFolderPanel; // the file panels for folders
ImageFilePanel *fPanel; // the file panels for images
BColorControl* fPicker;
BButton* fApply;
BButton* fRevert;
BCheckBox* fIconLabelOutline;
BMenu* fPlacementMenu;
BMenu* fImageMenu;
BMenu* fWorkspaceMenu;
BTextControl* fXPlacementText;
BTextControl* fYPlacementText;
PreView* fPreView;
BBox* fPreview;
BFilePanel* fFolderPanel;
ImageFilePanel* fPanel;
BackgroundImage *fCurrent; // the current BackgroundImage object
BackgroundImage::BackgroundImageInfo *fCurrentInfo;//the current BackgroundImageInfo object
entry_ref fCurrentRef; // the entry for the node which holds current
int32 fLastImageIndex, fLastWorkspaceIndex; // last indexes for cancel
BMessage fSettings; // settings loaded from settings directory
BackgroundImage* fCurrent;
BackgroundImage::BackgroundImageInfo* fCurrentInfo;
entry_ref fCurrentRef;
int32 fLastImageIndex;
int32 fLastWorkspaceIndex;
BMessage fSettings;
BObjectList<BPath> fPathList;
BObjectList<Image> fImageList;
+39 -28
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2005, Haiku, Inc. All Rights Reserved.
* Copyright 2002-2009, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -43,34 +43,42 @@ ImageFilePanel::Show()
if (fImageView == NULL) {
Window()->Lock();
BView* background = Window()->ChildAt(0);
uint32 poseViewResizingMode =
background->FindView("PoseView")->ResizingMode();
uint32 countVwResizingMode =
background->FindView("CountVw")->ResizingMode();
uint32 vScrollBarResizingMode =
background->FindView("VScrollBar")->ResizingMode();
uint32 hScrollBarResizingMode =
background->FindView("HScrollBar")->ResizingMode();
uint32 poseViewResizingMode
= background->FindView("PoseView")->ResizingMode();
uint32 countVwResizingMode
= background->FindView("CountVw")->ResizingMode();
uint32 vScrollBarResizingMode
= background->FindView("VScrollBar")->ResizingMode();
uint32 hScrollBarResizingMode
= background->FindView("HScrollBar")->ResizingMode();
background->FindView("PoseView")->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP);
background->FindView("CountVw")->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP);
background->FindView("VScrollBar")->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP);
background->FindView("HScrollBar")->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP);
background->FindView("PoseView")
->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP);
background->FindView("CountVw")
->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP);
background->FindView("VScrollBar")
->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP);
background->FindView("HScrollBar")
->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP);
Window()->ResizeBy(0, 70);
background->FindView("PoseView")->SetResizingMode(poseViewResizingMode);
background->FindView("CountVw")->SetResizingMode(countVwResizingMode);
background->FindView("VScrollBar")->SetResizingMode(vScrollBarResizingMode);
background->FindView("HScrollBar")->SetResizingMode(hScrollBarResizingMode);
background->FindView("VScrollBar")
->SetResizingMode(vScrollBarResizingMode);
background->FindView("HScrollBar")
->SetResizingMode(hScrollBarResizingMode);
BRect rect(background->Bounds().left + 15, background->Bounds().bottom - 94,
background->Bounds().left + 122, background->Bounds().bottom - 15);
fImageView = new BView(rect, "ImageView", B_FOLLOW_LEFT | B_FOLLOW_BOTTOM,
B_SUBPIXEL_PRECISE);
BRect rect(background->Bounds().left + 15,
background->Bounds().bottom - 94, background->Bounds().left + 122,
background->Bounds().bottom - 15);
fImageView = new BView(rect, "ImageView",
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_SUBPIXEL_PRECISE);
fImageView->SetViewColor(background->ViewColor());
background->AddChild(fImageView);
rect = BRect(background->Bounds().left + 132, background->Bounds().bottom - 85,
background->Bounds().right, background->Bounds().bottom - 65);
rect = BRect(background->Bounds().left + 132,
background->Bounds().bottom - 85, background->Bounds().right,
background->Bounds().bottom - 65);
fResolutionView = new BStringView(rect, "ResolutionView", NULL,
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
background->AddChild(fResolutionView);
@@ -104,19 +112,22 @@ ImageFilePanel::SelectionChanged()
if (bitmap != NULL) {
BRect dest(fImageView->Bounds());
if (bitmap->Bounds().Width() > bitmap->Bounds().Height()) {
dest.InsetBy(0, (dest.Height() + 1 -
((bitmap->Bounds().Height() + 1) /
(bitmap->Bounds().Width() + 1) *(dest.Width() + 1))) / 2);
dest.InsetBy(0, (dest.Height() + 1
- ((bitmap->Bounds().Height() + 1)
/ (bitmap->Bounds().Width() + 1)
* (dest.Width() + 1))) / 2);
} else {
dest.InsetBy((dest.Width() + 1 -
((bitmap->Bounds().Width() + 1) /
(bitmap->Bounds().Height() + 1) *(dest.Height() + 1))) / 2, 0);
dest.InsetBy((dest.Width() + 1
- ((bitmap->Bounds().Width() + 1)
/ (bitmap->Bounds().Height() + 1)
* (dest.Height() + 1))) / 2, 0);
}
fImageView->SetViewBitmap(bitmap, bitmap->Bounds(), dest,
B_FOLLOW_LEFT | B_FOLLOW_TOP, 0);
BString resolution;
resolution << "Resolution: " << (int)(bitmap->Bounds().Width() + 1)
resolution << "Resolution: "
<< (int)(bitmap->Bounds().Width() + 1)
<< "x" << (int)(bitmap->Bounds().Height() + 1);
fResolutionView->SetText(resolution.String());
delete bitmap;
+17 -10
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2005, Haiku, Inc. All Rights Reserved.
* Copyright 2002-2009, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -9,8 +9,9 @@
#define IMAGE_FILE_PANEL_H
#include <Node.h>
#include <FilePanel.h>
#include <Node.h>
class BStringView;
class BView;
@@ -21,25 +22,30 @@ class CustomRefFilter : public BRefFilter {
CustomRefFilter(bool imageFiltering);
virtual ~CustomRefFilter() {};
bool Filter(const entry_ref *ref, BNode* node, struct stat_beos *st,
const char *filetype);
bool Filter(const entry_ref* ref, BNode* node,
struct stat_beos* st, const char* filetype);
protected:
bool fImageFiltering; // true for images only, false for directory only
bool fImageFiltering;
// true for images
// false for directory
};
class ImageFilePanel : public BFilePanel {
public:
ImageFilePanel(file_panel_mode mode = B_OPEN_PANEL,
BMessenger* target = NULL, const entry_ref* startDirectory = NULL,
uint32 nodeFlavors = 0, bool allowMultipleSelection = true,
BMessage* message = NULL, BRefFilter* filter = NULL,
bool modal = false, bool hideWhenDone = true);
BMessenger* target = NULL,
const entry_ref* startDirectory = NULL,
uint32 nodeFlavors = 0,
bool allowMultipleSelection = true,
BMessage* message = NULL,
BRefFilter* filter = NULL,
bool modal = false,
bool hideWhenDone = true);
~ImageFilePanel();
virtual void SelectionChanged();
void Show();
protected:
@@ -49,3 +55,4 @@ class ImageFilePanel : public BFilePanel {
};
#endif // IMAGE_FILE_PANEL_H
-1
View File
@@ -13,4 +13,3 @@ Preference Backgrounds :
: Backgrounds.rdef
;