* Introduce a new tab to the Appearance Preflet for Decorator
* Show Decorator information button * Decorator changes happen in real time on click * Remove *old* OpenBeOS Decerator selection code * Still have a little cleanup todo * Need to give a little focus on revert/default buttons * Decerator test / screenshots? git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42356 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -23,8 +23,6 @@
|
|||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
#include <SpaceLayoutItem.h>
|
#include <SpaceLayoutItem.h>
|
||||||
|
|
||||||
#include <DecorInfo.h>
|
|
||||||
|
|
||||||
#include "APRWindow.h"
|
#include "APRWindow.h"
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "ColorWell.h"
|
#include "ColorWell.h"
|
||||||
@@ -41,10 +39,8 @@
|
|||||||
|
|
||||||
APRView::APRView(const char* name, uint32 flags)
|
APRView::APRView(const char* name, uint32 flags)
|
||||||
:
|
:
|
||||||
BView(name, flags),
|
BView(name, flags),
|
||||||
fDefaultSet(ColorSet::DefaultColorSet()),
|
fDefaultSet(ColorSet::DefaultColorSet())
|
||||||
fDecorMenu(NULL),
|
|
||||||
fDecorUtil(new DecorInfoUtility(false))
|
|
||||||
{
|
{
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
|
||||||
@@ -126,9 +122,6 @@ APRView::AttachedToWindow()
|
|||||||
fAttrList->SetTarget(this);
|
fAttrList->SetTarget(this);
|
||||||
fColorWell->SetTarget(this);
|
fColorWell->SetTarget(this);
|
||||||
|
|
||||||
if (fDecorMenu)
|
|
||||||
fDecorMenu->SetTargetForItems(BMessenger(this));
|
|
||||||
|
|
||||||
LoadSettings();
|
LoadSettings();
|
||||||
fAttrList->Select(0);
|
fAttrList->Select(0);
|
||||||
}
|
}
|
||||||
@@ -148,15 +141,6 @@ APRView::MessageReceived(BMessage *msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (msg->what) {
|
switch (msg->what) {
|
||||||
case DECORATOR_CHANGED:
|
|
||||||
{
|
|
||||||
int32 index = fDecorMenu->IndexOf(fDecorMenu->FindMarked());
|
|
||||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
|
||||||
if (index >= 0)
|
|
||||||
fDecorUtil->SetDecorator(index);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case UPDATE_COLOR:
|
case UPDATE_COLOR:
|
||||||
{
|
{
|
||||||
// Received from the color fPicker when its color changes
|
// Received from the color fPicker when its color changes
|
||||||
@@ -199,15 +183,6 @@ APRView::MessageReceived(BMessage *msg)
|
|||||||
UpdateControls();
|
UpdateControls();
|
||||||
UpdateAllColors();
|
UpdateAllColors();
|
||||||
|
|
||||||
if (fDecorMenu) {
|
|
||||||
BMenuItem *item = fDecorMenu->FindItem("Default");
|
|
||||||
if (item) {
|
|
||||||
item->SetMarked(true);
|
|
||||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
|
||||||
fDecorUtil->SetDecorator(fDecorMenu->IndexOf(item));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Window()->PostMessage(kMsgUpdate);
|
Window()->PostMessage(kMsgUpdate);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,9 +63,6 @@ protected:
|
|||||||
ColorSet fCurrentSet;
|
ColorSet fCurrentSet;
|
||||||
ColorSet fPrevSet;
|
ColorSet fPrevSet;
|
||||||
ColorSet fDefaultSet;
|
ColorSet fDefaultSet;
|
||||||
|
|
||||||
BMenu *fDecorMenu;
|
|
||||||
DecorInfoUtility*fDecorUtil;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2006, Haiku. All rights reserved.
|
* Copyright 2002-2011, Haiku. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* DarkWyrm ([email protected])
|
* DarkWyrm ([email protected])
|
||||||
|
* Alexander von Gluck, [email protected]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "APRWindow.h"
|
#include "APRWindow.h"
|
||||||
|
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
@@ -18,16 +21,19 @@
|
|||||||
#include "APRView.h"
|
#include "APRView.h"
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
|
|
||||||
|
|
||||||
#undef B_TRANSLATE_CONTEXT
|
#undef B_TRANSLATE_CONTEXT
|
||||||
#define B_TRANSLATE_CONTEXT "APRWindow"
|
#define B_TRANSLATE_CONTEXT "APRWindow"
|
||||||
|
|
||||||
|
|
||||||
static const uint32 kMsgSetDefaults = 'dflt';
|
static const uint32 kMsgSetDefaults = 'dflt';
|
||||||
static const uint32 kMsgRevert = 'rvrt';
|
static const uint32 kMsgRevert = 'rvrt';
|
||||||
|
|
||||||
|
|
||||||
APRWindow::APRWindow(BRect frame)
|
APRWindow::APRWindow(BRect frame)
|
||||||
:
|
:
|
||||||
BWindow(frame, B_TRANSLATE_SYSTEM_NAME("Appearance"), B_TITLED_WINDOW,
|
BWindow(frame, B_TRANSLATE_SYSTEM_NAME("Appearance"), B_TITLED_WINDOW,
|
||||||
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS, B_ALL_WORKSPACES)
|
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS, B_ALL_WORKSPACES)
|
||||||
{
|
{
|
||||||
|
|
||||||
SetLayout(new BGroupLayout(B_HORIZONTAL));
|
SetLayout(new BGroupLayout(B_HORIZONTAL));
|
||||||
@@ -42,13 +48,19 @@ APRWindow::APRWindow(BRect frame)
|
|||||||
|
|
||||||
fAntialiasingSettings = new AntialiasingSettingsView(
|
fAntialiasingSettings = new AntialiasingSettingsView(
|
||||||
B_TRANSLATE("Antialiasing"));
|
B_TRANSLATE("Antialiasing"));
|
||||||
|
|
||||||
|
fDecorSettings = new DecorSettingsView(
|
||||||
|
B_TRANSLATE("Window Decorator"));
|
||||||
|
|
||||||
fColorsView = new APRView(B_TRANSLATE("Colors"), B_WILL_DRAW);
|
fColorsView = new APRView(B_TRANSLATE("Colors"), B_WILL_DRAW);
|
||||||
|
|
||||||
tabView->AddTab(fColorsView);
|
tabView->AddTab(fColorsView);
|
||||||
tabView->AddTab(fAntialiasingSettings);
|
tabView->AddTab(fAntialiasingSettings);
|
||||||
|
tabView->AddTab(fDecorSettings);
|
||||||
|
|
||||||
fDefaultsButton->SetEnabled(fColorsView->IsDefaultable()
|
fDefaultsButton->SetEnabled(fColorsView->IsDefaultable()
|
||||||
|| fAntialiasingSettings->IsDefaultable());
|
|| fAntialiasingSettings->IsDefaultable()
|
||||||
|
|| fDecorSettings->IsDefaultable());
|
||||||
fRevertButton->SetEnabled(false);
|
fRevertButton->SetEnabled(false);
|
||||||
|
|
||||||
AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
|
AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2006, Haiku. All rights reserved.
|
* Copyright 2002-2011, Haiku. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* DarkWyrm ([email protected])
|
* DarkWyrm ([email protected])
|
||||||
|
* Alexander von Gluck, [email protected]
|
||||||
*/
|
*/
|
||||||
#ifndef APR_WINDOW_H
|
#ifndef APR_WINDOW_H
|
||||||
#define APR_WINDOW_H
|
#define APR_WINDOW_H
|
||||||
|
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
@@ -16,23 +18,26 @@
|
|||||||
|
|
||||||
#include "APRView.h"
|
#include "APRView.h"
|
||||||
#include "AntialiasingSettingsView.h"
|
#include "AntialiasingSettingsView.h"
|
||||||
|
#include "DecorSettingsView.h"
|
||||||
|
|
||||||
class APRWindow : public BWindow
|
|
||||||
|
class APRWindow : public BWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
APRWindow(BRect frame);
|
APRWindow(BRect frame);
|
||||||
bool QuitRequested(void);
|
bool QuitRequested(void);
|
||||||
void MessageReceived(BMessage *message);
|
void MessageReceived(BMessage *message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
APRView* fColorsView;
|
APRView* fColorsView;
|
||||||
BButton* fDefaultsButton;
|
BButton* fDefaultsButton;
|
||||||
BButton* fRevertButton;
|
BButton* fRevertButton;
|
||||||
|
|
||||||
AntialiasingSettingsView* fAntialiasingSettings;
|
|
||||||
|
|
||||||
|
AntialiasingSettingsView* fAntialiasingSettings;
|
||||||
|
DecorSettingsView* fDecorSettings;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int32 kMsgUpdate = 'updt';
|
static const int32 kMsgUpdate = 'updt';
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,220 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
// Copyright (c) 2001-2002, OpenBeOS
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
|
||||||
// to deal in the Software without restriction, including without limitation
|
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
// Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in
|
|
||||||
// all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
//
|
|
||||||
// File Name: DecView.cpp
|
|
||||||
// Author: DarkWyrm <[email protected]>
|
|
||||||
// Description: decorator handler for the app
|
|
||||||
//
|
|
||||||
// Utilizes app_server graphics module emulation to allows decorators to display
|
|
||||||
// a preview. Saves the chosen decorator's path in a settings file in the app_server
|
|
||||||
// settings directory.
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
#include <OS.h>
|
|
||||||
#include <Message.h>
|
|
||||||
#include <File.h>
|
|
||||||
#include <ScrollView.h>
|
|
||||||
#include <ListItem.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <Directory.h>
|
|
||||||
#include <Bitmap.h>
|
|
||||||
|
|
||||||
#include "ServerConfig.h"
|
|
||||||
#include "DecView.h"
|
|
||||||
#include "defs.h"
|
|
||||||
|
|
||||||
//#define DEBUG_DECORATOR
|
|
||||||
|
|
||||||
#ifdef DEBUG_DECORATOR
|
|
||||||
#define STRACE(a) printf a
|
|
||||||
#else
|
|
||||||
#define STRACE(a) /* nothing */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace BPrivate
|
|
||||||
{
|
|
||||||
int32 count_decorators(void);
|
|
||||||
status_t set_decorator(const int32 &index);
|
|
||||||
int32 get_decorator(void);
|
|
||||||
status_t get_decorator_name(const int32 &index, BString &name);
|
|
||||||
status_t get_decorator_preview(const int32 &index, BBitmap *bitmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
class DecoratorItem : public BStringItem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DecoratorItem(const char *text, const int32 &index);
|
|
||||||
int32 GetIndex(void) const { return fIndex; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
int32 fIndex;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
DecoratorItem::DecoratorItem(const char *text, const int32 &index)
|
|
||||||
: BStringItem(text),
|
|
||||||
fIndex(index)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
DecView::DecView(BRect frame, const char *name, int32 resize, int32 flags)
|
|
||||||
:BView(frame,name,resize,flags)
|
|
||||||
{
|
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
||||||
|
|
||||||
BRect r;
|
|
||||||
|
|
||||||
r.left = r.top = 10;
|
|
||||||
|
|
||||||
r.right = Bounds().Width()/2 - 10;
|
|
||||||
r.bottom = Bounds().bottom * .75;
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: This will eventually be just a BView which draws a BBitmap, but for now
|
|
||||||
// we will use a placeholder
|
|
||||||
preview = new BView(r, "preview", B_FOLLOW_NONE, B_WILL_DRAW);
|
|
||||||
preview->SetViewColor(100,140,255);
|
|
||||||
AddChild(preview);
|
|
||||||
|
|
||||||
r.left = r.right + 20;
|
|
||||||
r.right = Bounds().right - 10 - B_V_SCROLL_BAR_WIDTH;
|
|
||||||
|
|
||||||
|
|
||||||
declist = new BListView(r, "listview");
|
|
||||||
declist->SetSelectionMessage( new BMessage(DECORATOR_CHOSEN) );
|
|
||||||
|
|
||||||
BScrollView *scrollView = new BScrollView("scrollview", declist, B_FOLLOW_NONE,
|
|
||||||
0,false,true);
|
|
||||||
AddChild(scrollView);
|
|
||||||
|
|
||||||
apply = new BButton( BRect(0,0,1,1), "apply", "Apply", new BMessage(APPLY_SETTINGS),
|
|
||||||
B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
|
|
||||||
apply->ResizeToPreferred();
|
|
||||||
apply->MoveTo( Bounds().Width() - 10 - apply->Bounds().Width(),
|
|
||||||
Bounds().Height() - 10 - apply->Bounds().Height() );
|
|
||||||
AddChild(apply);
|
|
||||||
|
|
||||||
// Now that we have all the controls in place, populate the list
|
|
||||||
int32 decCount = BPrivate::count_decorators();
|
|
||||||
|
|
||||||
for(int32 i=0; i<decCount; i++)
|
|
||||||
{
|
|
||||||
BString string;
|
|
||||||
|
|
||||||
if( BPrivate::get_decorator_name( i, string ) == B_OK )
|
|
||||||
declist->AddItem( new DecoratorItem( string.String(), i ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DecView::AttachedToWindow(void)
|
|
||||||
{
|
|
||||||
declist->SetTarget(this);
|
|
||||||
apply->SetTarget(this);
|
|
||||||
|
|
||||||
int32 currentDec = BPrivate::get_decorator();
|
|
||||||
if(currentDec>=0)
|
|
||||||
declist->Select(currentDec);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DecView::MessageReceived(BMessage *msg)
|
|
||||||
{
|
|
||||||
switch(msg->what)
|
|
||||||
{
|
|
||||||
case APPLY_SETTINGS:
|
|
||||||
{
|
|
||||||
SaveSettings();
|
|
||||||
|
|
||||||
int32 selection = declist->CurrentSelection();
|
|
||||||
if(selection >=0 )
|
|
||||||
BPrivate::set_decorator(selection);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case DECORATOR_CHOSEN:
|
|
||||||
{
|
|
||||||
// TODO: update the preview here
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
BView::MessageReceived(msg);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DecView::SaveSettings(void)
|
|
||||||
{
|
|
||||||
BStringItem *item=(DecoratorItem*)declist->ItemAt(declist->CurrentSelection());
|
|
||||||
if(!item)
|
|
||||||
return;
|
|
||||||
|
|
||||||
BString path(SERVER_SETTINGS_DIR);
|
|
||||||
path+="decorator_settings";
|
|
||||||
STRACE(("%s\n",path.String()));
|
|
||||||
BFile file(path.String(),B_READ_WRITE|B_CREATE_FILE|B_ERASE_FILE);
|
|
||||||
|
|
||||||
BMessage settings;
|
|
||||||
settings.AddString("decorator",item->Text());
|
|
||||||
settings.Flatten(&file);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DecView::LoadSettings(void)
|
|
||||||
{
|
|
||||||
BMessage settings;
|
|
||||||
|
|
||||||
BDirectory dir,newdir;
|
|
||||||
if(dir.SetTo(SERVER_SETTINGS_DIR)==B_ENTRY_NOT_FOUND)
|
|
||||||
create_directory(SERVER_SETTINGS_DIR,0777);
|
|
||||||
|
|
||||||
BString path(SERVER_SETTINGS_DIR);
|
|
||||||
path+="decorator_settings";
|
|
||||||
BFile file(path.String(),B_READ_ONLY);
|
|
||||||
|
|
||||||
if(file.InitCheck()!=B_OK)
|
|
||||||
{
|
|
||||||
STRACE(("Error opening settings file %s\n",path.String()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(settings.Unflatten(&file)!=B_OK)
|
|
||||||
{
|
|
||||||
STRACE(("Error unflattening settings file %s\n",path.String()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
BString itemtext;
|
|
||||||
if(settings.FindString("decorator",&itemtext)!=B_OK)
|
|
||||||
{
|
|
||||||
STRACE(("Couldn't find decorator name in settings file %s\n",path.String()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int32 i=0;i<declist->CountItems();i++)
|
|
||||||
{
|
|
||||||
BStringItem *item=(BStringItem*)declist->ItemAt(i);
|
|
||||||
if(item && itemtext.Compare(item->Text())==0)
|
|
||||||
{
|
|
||||||
declist->Select(i);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
// Copyright (c) 2001-2002, OpenBeOS
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
|
||||||
// to deal in the Software without restriction, including without limitation
|
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
// Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in
|
|
||||||
// all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
//
|
|
||||||
// File Name: DecView.h
|
|
||||||
// Author: DarkWyrm <[email protected]>
|
|
||||||
// Description: decorator handler for the app
|
|
||||||
//
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
#ifndef DEC_VIEW_H_
|
|
||||||
#define DEC_VIEW_H_
|
|
||||||
|
|
||||||
#include <View.h>
|
|
||||||
#include <ListView.h>
|
|
||||||
#include <Button.h>
|
|
||||||
#include <String.h>
|
|
||||||
|
|
||||||
class DecView : public BView
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DecView(BRect frame, const char *name, int32 resize, int32 flags);
|
|
||||||
|
|
||||||
void AttachedToWindow(void);
|
|
||||||
void MessageReceived(BMessage *msg);
|
|
||||||
|
|
||||||
void SaveSettings(void);
|
|
||||||
void LoadSettings(void);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
BButton *apply;
|
|
||||||
BListView *declist;
|
|
||||||
BView *preview;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -0,0 +1,235 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2011 Haiku, Inc. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT license.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Alexander von Gluck, [email protected]
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "DecorSettingsView.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <Alert.h>
|
||||||
|
#include <Box.h>
|
||||||
|
#include <Catalog.h>
|
||||||
|
#include <GridLayoutBuilder.h>
|
||||||
|
#include <GroupLayoutBuilder.h>
|
||||||
|
#include <Locale.h>
|
||||||
|
#include <MenuField.h>
|
||||||
|
#include <MenuItem.h>
|
||||||
|
#include <PopUpMenu.h>
|
||||||
|
#include <Slider.h>
|
||||||
|
#include <SpaceLayoutItem.h>
|
||||||
|
#include <String.h>
|
||||||
|
#include <TextView.h>
|
||||||
|
|
||||||
|
#include "APRWindow.h"
|
||||||
|
|
||||||
|
|
||||||
|
#undef B_TRANSLATE_CONTEXT
|
||||||
|
#define B_TRANSLATE_CONTEXT "DecorSettingsView"
|
||||||
|
|
||||||
|
|
||||||
|
static const int32 kMsgSetDecor = 'deco';
|
||||||
|
static const int32 kMsgDecorInfo = 'idec';
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
DecorSettingsView::DecorSettingsView(const char* name)
|
||||||
|
:
|
||||||
|
BView(name, 0)
|
||||||
|
{
|
||||||
|
// Decorator menu
|
||||||
|
_BuildDecorMenu();
|
||||||
|
fDecorMenuField = new BMenuField("decorator",
|
||||||
|
B_TRANSLATE("Window Decorator:"), fDecorMenu);
|
||||||
|
|
||||||
|
fDecorInfoButton = new BButton(B_TRANSLATE("About"),
|
||||||
|
new BMessage(kMsgDecorInfo));
|
||||||
|
|
||||||
|
SetLayout(new BGroupLayout(B_VERTICAL));
|
||||||
|
|
||||||
|
// control layout
|
||||||
|
AddChild(BGridLayoutBuilder(10, 10)
|
||||||
|
.Add(fDecorMenuField->CreateLabelLayoutItem(), 0, 0)
|
||||||
|
.Add(fDecorMenuField->CreateMenuBarLayoutItem(), 1, 0)
|
||||||
|
.Add(fDecorInfoButton, 2, 0)
|
||||||
|
|
||||||
|
.Add(BSpaceLayoutItem::CreateGlue(), 0, 3, 2)
|
||||||
|
.SetInsets(10, 10, 10, 10)
|
||||||
|
);
|
||||||
|
// TODO : Decorator Preview Image?
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DecorSettingsView::~DecorSettingsView()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DecorSettingsView::AttachedToWindow()
|
||||||
|
{
|
||||||
|
if (Parent() != NULL)
|
||||||
|
SetViewColor(Parent()->ViewColor());
|
||||||
|
else
|
||||||
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
|
||||||
|
fDecorMenu->SetTargetForItems(this);
|
||||||
|
fDecorInfoButton->SetTarget(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DecorSettingsView::MessageReceived(BMessage *msg)
|
||||||
|
{
|
||||||
|
switch (msg->what) {
|
||||||
|
case kMsgSetDecor:
|
||||||
|
{
|
||||||
|
BString newDecor;
|
||||||
|
if (msg->FindString("decor", &newDecor) != B_OK)
|
||||||
|
break;
|
||||||
|
|
||||||
|
DecorInfoUtility* decorUtility = new DecorInfoUtility();
|
||||||
|
if (decorUtility == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
DecorInfo* decor = decorUtility->FindDecorator(newDecor);
|
||||||
|
if (decor == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fSavedDecor = fCurrentDecor;
|
||||||
|
fCurrentDecor = (char*)decor->Name().String();
|
||||||
|
|
||||||
|
decorUtility->SetDecorator(decor);
|
||||||
|
|
||||||
|
Window()->PostMessage(kMsgUpdate);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case kMsgDecorInfo:
|
||||||
|
{
|
||||||
|
DecorInfoUtility* decorUtility = new DecorInfoUtility();
|
||||||
|
if (decorUtility == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
BString decoratorName(fCurrentDecor);
|
||||||
|
DecorInfo* decor = decorUtility->FindDecorator(decoratorName);
|
||||||
|
if (decor == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
BString authorsText(decor->Authors().String());
|
||||||
|
authorsText.ReplaceAll(", ", "\n ");
|
||||||
|
|
||||||
|
BString infoText("Name: %decorName\n"
|
||||||
|
"Authors:\n %decorAuthors\n"
|
||||||
|
"URL: %decorURL\n"
|
||||||
|
"License: %decorLic\n"
|
||||||
|
"Description:\n %decorDesc\n");
|
||||||
|
|
||||||
|
infoText.ReplaceFirst("%decorName", decor->Name().String());
|
||||||
|
infoText.ReplaceFirst("%decorAuthors", authorsText.String());
|
||||||
|
infoText.ReplaceFirst("%decorLic", decor->LicenseName().String());
|
||||||
|
infoText.ReplaceFirst("%decorURL", decor->SupportURL().String());
|
||||||
|
infoText.ReplaceFirst("%decorDesc", decor->ShortDescription().String());
|
||||||
|
|
||||||
|
BAlert *infoAlert = new BAlert(B_TRANSLATE("About Decerator"),
|
||||||
|
infoText.String(), B_TRANSLATE("OK"));
|
||||||
|
infoAlert->SetShortcut(0, B_ESCAPE);
|
||||||
|
infoAlert->Go();
|
||||||
|
|
||||||
|
Window()->PostMessage(kMsgUpdate);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
BView::MessageReceived(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DecorSettingsView::_BuildDecorMenu()
|
||||||
|
{
|
||||||
|
fDecorMenu = new BPopUpMenu(B_TRANSLATE("Choose Decorator"));
|
||||||
|
DecorInfo* decorator = NULL;
|
||||||
|
|
||||||
|
// collect the current system decor settings
|
||||||
|
DecorInfoUtility* decorUtility = new DecorInfoUtility();
|
||||||
|
|
||||||
|
if (decorUtility == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 count = decorUtility->CountDecorators();
|
||||||
|
for (int32 i = 0; i < count; ++i) {
|
||||||
|
decorator = decorUtility->DecoratorAt(i);
|
||||||
|
if (decorator == NULL) {
|
||||||
|
fprintf(stderr, "Decorator : error NULL entry @ %li / %li\n",
|
||||||
|
i, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
BString decorName = decorator->Name();
|
||||||
|
|
||||||
|
if (decorUtility->CurrentDecorator() == decorator)
|
||||||
|
fCurrentDecor = (char*)decorName.String();
|
||||||
|
|
||||||
|
BMessage* message = new BMessage(kMsgSetDecor);
|
||||||
|
message->AddString("decor", decorator->Name());
|
||||||
|
|
||||||
|
BMenuItem* item
|
||||||
|
= new BMenuItem(decorator->Name(), message);
|
||||||
|
|
||||||
|
fDecorMenu->AddItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
_SetCurrentDecor();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DecorSettingsView::_SetCurrentDecor()
|
||||||
|
{
|
||||||
|
BMenuItem *item = fDecorMenu->FindItem(fCurrentDecor);
|
||||||
|
BString currDecor = fCurrentDecor;
|
||||||
|
if (item != NULL)
|
||||||
|
item->SetMarked(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DecorSettingsView::SetDefaults()
|
||||||
|
{
|
||||||
|
DecorInfoUtility* decorUtility = new DecorInfoUtility();
|
||||||
|
if (decorUtility == NULL)
|
||||||
|
return;
|
||||||
|
DecorInfo* defaultDecorator(decorUtility->DefaultDecorator());
|
||||||
|
decorUtility->SetDecorator(defaultDecorator);
|
||||||
|
_BuildDecorMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
DecorSettingsView::IsDefaultable()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
DecorSettingsView::IsRevertable()
|
||||||
|
{
|
||||||
|
return fCurrentDecor != fSavedDecor;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DecorSettingsView::Revert()
|
||||||
|
{
|
||||||
|
if (!IsRevertable())
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2011 Haiku, Inc. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT license.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Alexander von Gluck, [email protected]
|
||||||
|
*/
|
||||||
|
#ifndef DECOR_SETTINGS_VIEW_H
|
||||||
|
#define DECOR_SETTINGS_VIEW_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <Button.h>
|
||||||
|
#include <GroupView.h>
|
||||||
|
#include <InterfaceDefs.h>
|
||||||
|
#include <View.h>
|
||||||
|
|
||||||
|
#include <DecorInfo.h>
|
||||||
|
|
||||||
|
|
||||||
|
class BBox;
|
||||||
|
class BMenuField;
|
||||||
|
class BPopUpMenu;
|
||||||
|
|
||||||
|
|
||||||
|
class DecorSettingsView : public BView {
|
||||||
|
public:
|
||||||
|
DecorSettingsView(const char* name);
|
||||||
|
virtual ~DecorSettingsView();
|
||||||
|
|
||||||
|
virtual void AttachedToWindow();
|
||||||
|
virtual void MessageReceived(BMessage* message);
|
||||||
|
|
||||||
|
void SetDefaults();
|
||||||
|
void Revert();
|
||||||
|
bool IsDefaultable();
|
||||||
|
bool IsRevertable();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void _BuildDecorMenu();
|
||||||
|
void _SetCurrentDecor();
|
||||||
|
|
||||||
|
BButton* fDecorInfoButton;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
float fDivider;
|
||||||
|
|
||||||
|
BMenuField* fDecorMenuField;
|
||||||
|
BPopUpMenu* fDecorMenu;
|
||||||
|
|
||||||
|
char* fSavedDecor;
|
||||||
|
char* fCurrentDecor;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DECOR_SETTINGS_VIEW_H
|
||||||
@@ -6,6 +6,7 @@ UseFreeTypeHeaders ;
|
|||||||
Preference Appearance :
|
Preference Appearance :
|
||||||
APRMain.cpp
|
APRMain.cpp
|
||||||
AntialiasingSettingsView.cpp
|
AntialiasingSettingsView.cpp
|
||||||
|
DecorSettingsView.cpp
|
||||||
APRView.cpp
|
APRView.cpp
|
||||||
APRWindow.cpp
|
APRWindow.cpp
|
||||||
ColorSet.cpp
|
ColorSet.cpp
|
||||||
@@ -15,14 +16,13 @@ Preference Appearance :
|
|||||||
# These are currently disabled while everything else is being worked on
|
# These are currently disabled while everything else is being worked on
|
||||||
#CurView.cpp
|
#CurView.cpp
|
||||||
#CursorWhichItem.cpp
|
#CursorWhichItem.cpp
|
||||||
#DecView.cpp
|
|
||||||
#SysCursorAPI.cpp
|
#SysCursorAPI.cpp
|
||||||
|
|
||||||
# These exist for post-R1, so they are disabled for now
|
# These exist for post-R1, so they are disabled for now
|
||||||
#FontMenu.cpp
|
#FontMenu.cpp
|
||||||
#MenuView.cpp
|
#MenuView.cpp
|
||||||
|
|
||||||
: be $(TARGET_LIBSTDC++) $(HAIKU_LOCALE_LIBS)
|
: be $(TARGET_LIBSTDC++) $(TARGET_LIBSUPC++) $(HAIKU_LOCALE_LIBS)
|
||||||
: Appearance.rdef
|
: Appearance.rdef
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -30,6 +30,7 @@ DoCatalogs Appearance :
|
|||||||
x-vnd.Haiku-Appearance
|
x-vnd.Haiku-Appearance
|
||||||
:
|
:
|
||||||
AntialiasingSettingsView.cpp
|
AntialiasingSettingsView.cpp
|
||||||
|
DecorSettingsView.cpp
|
||||||
APRView.cpp
|
APRView.cpp
|
||||||
APRWindow.cpp
|
APRWindow.cpp
|
||||||
ColorSet.cpp
|
ColorSet.cpp
|
||||||
|
|||||||
Reference in New Issue
Block a user