Fully updated sources and jamfile. Added icon to app
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@875 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
77a6586a2e
commit
321a1ba7c1
@ -18,13 +18,14 @@
|
||||
#include <Invoker.h>
|
||||
|
||||
class ColorWell;
|
||||
class APRWindow;
|
||||
|
||||
class APRView : public BView
|
||||
{
|
||||
public:
|
||||
APRView(const BRect &frame, const char *name, int32 resize, int32 flags);
|
||||
~APRView(void);
|
||||
void AttachedToWindow(void);
|
||||
void AllAttached(void);
|
||||
void MessageReceived(BMessage *msg);
|
||||
color_which SelectionToAttribute(int32 index);
|
||||
const char *AttributeToString(const color_which &attr);
|
||||
@ -35,10 +36,10 @@ public:
|
||||
void NotifyServer(void);
|
||||
rgb_color GetColorFromMessage(BMessage *msg, const char *name, int32 index=0);
|
||||
protected:
|
||||
friend APRWindow;
|
||||
BMenu *LoadColorSets(void);
|
||||
void SaveColorSet(const BString &name);
|
||||
void LoadColorSet(const BString &name);
|
||||
void DeleteColorSet(const BString &name);
|
||||
void SetColorSetName(const char *name);
|
||||
BColorControl *picker;
|
||||
BButton *apply,*revert,*defaults,*try_settings;
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "APRWindow.h"
|
||||
#include "APRView.h"
|
||||
#include "DecView.h"
|
||||
#include "defs.h"
|
||||
|
||||
APRWindow::APRWindow(BRect frame)
|
||||
: BWindow(frame, "Appearance", B_TITLED_WINDOW,
|
||||
@ -20,6 +21,7 @@ APRWindow::APRWindow(BRect frame)
|
||||
tabview->AddTab(decorators,tab);
|
||||
|
||||
AddChild(tabview);
|
||||
decorators->SetColors(colors->settings);
|
||||
}
|
||||
|
||||
bool APRWindow::QuitRequested()
|
||||
@ -36,3 +38,14 @@ void APRWindow::WorkspaceActivated(int32 wkspc, bool is_active)
|
||||
notifier.SendMessage(new BMessage(B_WORKSPACE_ACTIVATED));
|
||||
}
|
||||
}
|
||||
|
||||
#include <stdio.h>
|
||||
void APRWindow::MessageReceived(BMessage *msg)
|
||||
{
|
||||
if(msg->what==SET_UI_COLORS)
|
||||
{
|
||||
decorators->SetColors(colors->settings);
|
||||
}
|
||||
else
|
||||
BWindow::MessageReceived(msg);
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ public:
|
||||
APRWindow(BRect frame);
|
||||
virtual bool QuitRequested();
|
||||
virtual void WorkspaceActivated(int32 wkspc, bool is_active);
|
||||
virtual void MessageReceived(BMessage *msg);
|
||||
BTabView *tabview;
|
||||
APRView *colors;
|
||||
DecView *decorators;
|
||||
|
BIN
src/prefs/appearance/Appearance.rsrc
Normal file
BIN
src/prefs/appearance/Appearance.rsrc
Normal file
Binary file not shown.
@ -3,8 +3,15 @@
|
||||
|
||||
#include "RGBColor.h"
|
||||
|
||||
typedef struct
|
||||
class ColorSet
|
||||
{
|
||||
public:
|
||||
ColorSet(void);
|
||||
ColorSet(const ColorSet &cs);
|
||||
ColorSet & operator=(const ColorSet &cs);
|
||||
void SetColors(const ColorSet &cs);
|
||||
void PrintToStream(void);
|
||||
|
||||
RGBColor panel_background,
|
||||
panel_text,
|
||||
document_background,
|
||||
@ -21,7 +28,11 @@ typedef struct
|
||||
menu_selected_text,
|
||||
menu_separator_high,
|
||||
menu_separator_low,
|
||||
menu_triggers;
|
||||
} ColorSet;
|
||||
menu_triggers,
|
||||
window_tab,
|
||||
window_tab_text,
|
||||
keyboard_navigation,
|
||||
desktop;
|
||||
};
|
||||
|
||||
#endif
|
@ -16,11 +16,12 @@
|
||||
#include <Directory.h>
|
||||
#include <File.h>
|
||||
#include <stdio.h>
|
||||
#include "RGBColor.h"
|
||||
#include "defs.h"
|
||||
#include "PreviewDriver.h"
|
||||
#include "Decorator.h"
|
||||
|
||||
//#define DEBUG_DECORATOR
|
||||
#define DEBUG_DECORATOR
|
||||
|
||||
DecView::DecView(BRect frame, const char *name, int32 resize, int32 flags)
|
||||
:BView(frame,name,resize,flags)
|
||||
@ -59,10 +60,9 @@ DecView::DecView(BRect frame, const char *name, int32 resize, int32 flags)
|
||||
preview->MoveTo(scrollview->Frame().right+20,scrollview->Frame().top);
|
||||
}
|
||||
|
||||
LayerData ldata;
|
||||
ldata.highcolor.SetColor(51,102,160);
|
||||
uint64 pat=0xFFFFFFFFFFFFFFFFLL;
|
||||
driver->FillRect(preview_bounds,&ldata,(int8*)&pat);
|
||||
pat_solid_high=0xFFFFFFFFFFFFFFFFLL;
|
||||
driver->FillRect(preview_bounds,&ldata,(int8*)&pat_solid_high);
|
||||
|
||||
decorator=NULL;
|
||||
decorator_id=-1;
|
||||
@ -78,7 +78,7 @@ DecView::~DecView(void)
|
||||
delete decorator;
|
||||
}
|
||||
|
||||
void DecView::AttachedToWindow(void)
|
||||
void DecView::AllAttached(void)
|
||||
{
|
||||
declist->SetTarget(this);
|
||||
apply->SetTarget(this);
|
||||
@ -117,12 +117,13 @@ printf("MSG: Decorator NOT Chosen - couldn't load decorator\n");
|
||||
break;
|
||||
}
|
||||
|
||||
LayerData ldata;
|
||||
ldata.highcolor.SetColor(ui_color(B_DESKTOP_COLOR));
|
||||
uint64 pat=0xFFFFFFFFFFFFFFFFLL;
|
||||
driver->FillRect(preview_bounds,&ldata,(int8*)&pat);
|
||||
ldata.highcolor.SetColor(colorset.desktop);
|
||||
driver->FillRect(preview_bounds,&ldata,(int8*)&pat_solid_high);
|
||||
if(decorator)
|
||||
{
|
||||
decorator->SetColors(colorset);
|
||||
decorator->Draw();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -313,7 +314,13 @@ printf("LoadDecorator(%s): Couldn't get allocation symbol\n",path);
|
||||
printf("LoadDecorator(): Deleting old decorator\n");
|
||||
#endif
|
||||
delete decorator;
|
||||
unload_add_on(decorator_id);
|
||||
decorator=NULL;
|
||||
|
||||
// NEVER, *EVER*, call unload_add_on() if there is _any_ possibility,
|
||||
// no matter remote, that memory might still be in use when it is called.
|
||||
// It wll lead to unpredictable crashes which have almost nothing to
|
||||
// do with the *real* cause.
|
||||
// unload_add_on(decorator_id);
|
||||
}
|
||||
decorator_id=addon;
|
||||
decorator=pcreatefunc(SRect(50,50,150,150),WLOOK_TITLED,WFEEL_NORMAL,0);
|
||||
@ -340,3 +347,66 @@ printf("ConvertIndexToPath(): returned %s\n",path.String());
|
||||
#endif
|
||||
return BString(path.String());
|
||||
}
|
||||
|
||||
void DecView::SetColors(const BMessage &message)
|
||||
{
|
||||
#ifdef DEBUG_DECORATOR
|
||||
printf("DecView::SetColors\n");
|
||||
#endif
|
||||
if(UnpackSettings(&colorset,&message))
|
||||
{
|
||||
if(decorator)
|
||||
{
|
||||
ldata.highcolor.SetColor(colorset.desktop);
|
||||
driver->FillRect(preview_bounds,&ldata,(int8*)&pat_solid_high);
|
||||
decorator->SetColors(colorset);
|
||||
decorator->Draw();
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG_DECORATOR
|
||||
printf("DecView::SetColors: NULL decorator\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG_DECORATOR
|
||||
printf("DecView::SetColors: UnpackSetting returned false\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
bool DecView::UnpackSettings(ColorSet *set, const BMessage *msg)
|
||||
{
|
||||
if(!set || !msg)
|
||||
{
|
||||
#ifdef DEBUG_DECORATOR
|
||||
printf("UnpackSettings(): NULL parameter\n");
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
rgb_color *col;
|
||||
ssize_t size;
|
||||
|
||||
// Once the OBOS app_server is in place, there will be more attributes
|
||||
|
||||
if(msg->FindData("PANEL_BACKGROUND",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
|
||||
set->panel_background.SetColor(*col);
|
||||
if(msg->FindData("MENU_BACKGROUND",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
|
||||
set->menu_background.SetColor(*col);
|
||||
if(msg->FindData("MENU_SELECTION_BACKGROUND",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
|
||||
set->menu_selected_background.SetColor(*col);
|
||||
if(msg->FindData("MENU_ITEM_TEXT",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
|
||||
set->menu_text.SetColor(*col);
|
||||
if(msg->FindData("MENU_SELECTED_ITEM_TEXT",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
|
||||
set->menu_selected_text.SetColor(*col);
|
||||
if(msg->FindData("WINDOW_TAB",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
|
||||
set->window_tab.SetColor(*col);
|
||||
if(msg->FindData("KEYBOARD_NAVIGATION",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
|
||||
set->keyboard_navigation.SetColor(*col);
|
||||
if(msg->FindData("DESKTOP",(type_code)'RGBC',(const void**)&col,&size)==B_OK)
|
||||
set->desktop.SetColor(*col);
|
||||
return true;
|
||||
}
|
||||
|
@ -9,7 +9,8 @@
|
||||
#include <ScrollView.h>
|
||||
#include <ScrollBar.h>
|
||||
#include <String.h>
|
||||
|
||||
#include "ColorSet.h"
|
||||
#include "LayerData.h"
|
||||
class PreviewDriver;
|
||||
class Decorator;
|
||||
|
||||
@ -18,16 +19,18 @@ class DecView : public BView
|
||||
public:
|
||||
DecView(BRect frame, const char *name, int32 resize, int32 flags);
|
||||
~DecView(void);
|
||||
void AttachedToWindow(void);
|
||||
void AllAttached(void);
|
||||
void MessageReceived(BMessage *msg);
|
||||
void SaveSettings(void);
|
||||
void LoadSettings(void);
|
||||
void SetDefaults(void);
|
||||
void NotifyServer(void);
|
||||
void GetDecorators(void);
|
||||
void SetColors(const BMessage &message);
|
||||
bool LoadDecorator(const char *path);
|
||||
BString ConvertIndexToPath(int32 index);
|
||||
protected:
|
||||
bool UnpackSettings(ColorSet *set, const BMessage *msg);
|
||||
BButton *apply;
|
||||
BListView *declist;
|
||||
BMessage settings;
|
||||
@ -37,6 +40,9 @@ protected:
|
||||
Decorator *decorator;
|
||||
image_id decorator_id;
|
||||
BString decpath;
|
||||
LayerData ldata;
|
||||
uint64 pat_solid_high;
|
||||
ColorSet colorset;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -25,14 +25,18 @@ Decorator::Decorator(SRect rect, int32 wlook, int32 wfeel, int32 wflags)
|
||||
|
||||
Decorator::~Decorator(void)
|
||||
{
|
||||
delete colors;
|
||||
if(colors!=NULL)
|
||||
{
|
||||
delete colors;
|
||||
colors=NULL;
|
||||
}
|
||||
if(title_string)
|
||||
delete title_string;
|
||||
}
|
||||
|
||||
void Decorator::SetColors(ColorSet cset)
|
||||
{
|
||||
*colors=cset;
|
||||
colors->SetColors(cset);
|
||||
}
|
||||
|
||||
void Decorator::SetDriver(DisplayDriver *d)
|
||||
|
@ -76,6 +76,7 @@ public:
|
||||
const char *GetTitle(void);
|
||||
// void SetFont(SFont *sf);
|
||||
void _ClipTitle(void);
|
||||
ColorSet GetColors(void) { if(colors) return *colors; else return ColorSet(); }
|
||||
|
||||
virtual void MoveBy(float x, float y);
|
||||
virtual void MoveBy(SPoint pt);
|
||||
|
@ -4,4 +4,4 @@ AddResources Appearance : Appearance.rsrc ;
|
||||
|
||||
Preference Appearance : APRMain.cpp APRView.cpp APRWindow.cpp Decorator.cpp DecView.cpp DisplayDriver.cpp PortLink.cpp PreviewDriver.cpp RGBColor.cpp SPoint.cpp SRect.cpp ColorWell.cpp ;
|
||||
|
||||
LinkSharedOSLibs Appearance : be ;
|
||||
LinkSharedOSLibs Appearance : be tracker ;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef LAYERDATA_H_
|
||||
#define LAYERDATA_H_
|
||||
|
||||
#include "SPoint.h"
|
||||
class ServerBitmap;
|
||||
|
||||
class LayerData
|
||||
|
@ -159,5 +159,5 @@ printf("MakeBlendColor( {%u,%u,%u,%u}, {%u,%u,%u,%u}, %f) : {%u,%u,%u,%u}\n",
|
||||
|
||||
void RGBColor::PrintToStream(void)
|
||||
{
|
||||
printf("RGBColor (%u,%u,%u,%u)\n", color.red,color.green,color.blue,color.alpha);
|
||||
printf("RGBColor (%u,%u,%u,%u)\n", color32.red,color32.green,color32.blue,color32.alpha);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user