Windows receive focus when shown

System cursor API and infrastructure largely implemented
Added Decorator::SetFont
Removed unnecessary parameter copying in WinBorder class API
Optimized screen updates when a decorator button is clicked
Moved TokenHandler and BitmapManager to libappserver to allow decorators to use bitmaps
Began reworking of DefaultDecorator::_DrawFrame to draw only what it is asked to
Partly implemented ViewDriver::StrokeLineArray - calls StrokeLine
Fixed a Layer init bug - visibility regions were initialized to Bounds() and not Frame()


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4060 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm 2003-07-24 19:38:24 +00:00
parent aea9bed9de
commit 2a8283e420
15 changed files with 451 additions and 129 deletions

View File

@ -618,6 +618,11 @@ void AppServer::DispatchMessage(int32 code, int8 *buffer)
_exit_poller=true;
break;
}
case AS_SET_SYSCURSOR_DEFAULTS:
{
cursormanager->SetDefaults();
break;
}
default:
// we should never get here.
break;
@ -980,7 +985,10 @@ Decorator *new_decorator(BRect rect, const char *title, int32 wlook, int32 wfeel
dec=app_server->make_decorator(rect,wlook,wfeel,wflags);
gui_colorset.Lock();
dec->SetDriver(ddriver);
dec->SetColors(gui_colorset);
dec->SetFont(fontserver->GetSystemPlain());
dec->SetTitle(title);
gui_colorset.Unlock();
return dec;

View File

@ -29,7 +29,10 @@
#include "CursorManager.h"
#include "ServerCursor.h"
#include "CursorData.h"
#include "ServerConfig.h"
#include <Errors.h>
#include <Directory.h>
#include <String.h>
#include <string.h>
//! The global cursor manager object. Allocated and freed by AppServer class
@ -39,7 +42,6 @@ CursorManager *cursormanager;
CursorManager::CursorManager(void)
{
_cursorlist=new BList(0);
_lock=create_sem(1,"cursor_manager_sem");
// Error code for AddCursor
_tokenizer.ExcludeValue(B_ERROR);
@ -53,21 +55,21 @@ CursorManager::CursorManager(void)
AddCursor(ctext);
_textcsr=ctext;
ServerCursor *cdrag=new ServerCursor(default_drag_data);
AddCursor(cdrag);
_dragcsr=cdrag;
ServerCursor *cmove=new ServerCursor(default_move_data);
AddCursor(cmove);
_movecsr=cmove;
ServerCursor *cdrag=new ServerCursor(default_drag_data);
AddCursor(cdrag);
_dragcsr=cdrag;
ServerCursor *cresize=new ServerCursor(default_resize_data);
AddCursor(cresize);
_resizecsr=cresize;
ServerCursor *cresizeew=new ServerCursor(default_resize_ew_data);
AddCursor(cresizeew);
_resize_ew_csr=cresizeew;
ServerCursor *cresizenwse=new ServerCursor(default_resize_nwse_data);
AddCursor(cresizenwse);
_resize_nwse_csr=cresizenwse;
ServerCursor *cresizenesw=new ServerCursor(default_resize_nesw_data);
AddCursor(cresizenesw);
@ -77,9 +79,10 @@ CursorManager::CursorManager(void)
AddCursor(cresizens);
_resize_ns_csr=cresizens;
ServerCursor *cresizenwse=new ServerCursor(default_resize_nwse_data);
AddCursor(cresizenwse);
_resize_nwse_csr=cresizenwse;
ServerCursor *cresizeew=new ServerCursor(default_resize_ew_data);
AddCursor(cresizeew);
_resize_ew_csr=cresizeew;
}
//! Does all the teardown
@ -95,8 +98,6 @@ CursorManager::~CursorManager(void)
_cursorlist->MakeEmpty();
delete _cursorlist;
delete_sem(_lock);
// Note that it is not necessary to remove and delete the system
// cursors. These cursors are kept in the list with a NULL application
// signature so they cannot be removed very easily except via
@ -114,11 +115,11 @@ int32 CursorManager::AddCursor(ServerCursor *sc)
if(!sc)
return B_ERROR;
acquire_sem(_lock);
Lock();
_cursorlist->AddItem(sc);
int32 value=_tokenizer.GetToken();
sc->_token=value;
release_sem(_lock);
Unlock();
return value;
}
@ -131,7 +132,7 @@ int32 CursorManager::AddCursor(ServerCursor *sc)
*/
void CursorManager::DeleteCursor(int32 token)
{
acquire_sem(_lock);
Lock();
ServerCursor *temp;
for(int32 i=0; i<_cursorlist->CountItems();i++)
@ -144,7 +145,7 @@ void CursorManager::DeleteCursor(int32 token)
break;
}
}
release_sem(_lock);
Unlock();
}
/*!
@ -156,7 +157,7 @@ void CursorManager::RemoveAppCursors(const char *signature)
// OPTIMIZATION: For an optimization, it perhaps may be wise down
// the road to replace the ServerCursor's app signature with a
// pointer to its application and compare ServerApp pointers instead.
acquire_sem(_lock);
Lock();
ServerCursor *temp;
for(int32 i=0; i<_cursorlist->CountItems();i++)
@ -170,37 +171,37 @@ void CursorManager::RemoveAppCursors(const char *signature)
break;
}
}
release_sem(_lock);
Unlock();
}
//! Wrapper around the DisplayDriver ShowCursor call
void CursorManager::ShowCursor(void)
{
acquire_sem(_lock);
Lock();
DisplayDriver *driver=GetGfxDriver(ActiveScreen());
driver->ShowCursor();
release_sem(_lock);
Unlock();
}
//! Wrapper around the DisplayDriver HideCursor call
void CursorManager::HideCursor(void)
{
acquire_sem(_lock);
Lock();
DisplayDriver *driver=GetGfxDriver(ActiveScreen());
driver->HideCursor();
release_sem(_lock);
Unlock();
}
//! Wrapper around the DisplayDriver ObscureCursor call
void CursorManager::ObscureCursor(void)
{
acquire_sem(_lock);
Lock();
DisplayDriver *driver=GetGfxDriver(ActiveScreen());
driver->ObscureCursor();
release_sem(_lock);
Unlock();
}
/*!
@ -209,7 +210,7 @@ void CursorManager::ObscureCursor(void)
*/
void CursorManager::SetCursor(int32 token)
{
acquire_sem(_lock);
Lock();
ServerCursor *c=_FindCursor(token);
if(c)
{
@ -217,12 +218,12 @@ void CursorManager::SetCursor(int32 token)
driver->SetCursor(c);
_current_which=B_CURSOR_OTHER;
}
release_sem(_lock);
Unlock();
}
void CursorManager::SetCursor(cursor_which which)
{
acquire_sem(_lock);
Lock();
DisplayDriver *driver=GetGfxDriver(ActiveScreen());
switch(which)
@ -285,7 +286,90 @@ void CursorManager::SetCursor(cursor_which which)
break;
}
release_sem(_lock);
Unlock();
}
/*!
\brief Sets all the cursors from a specified CursorSet
\param path Path to the cursor set
All cursors in the set will be assigned. If the set does not specify a cursor for a
particular cursor specifier, it will remain unchanged. This function will fail if passed
a NULL path, an invalid path, or the path to a non-CursorSet file.
*/
void CursorManager::SetCursorSet(const char *path)
{
Lock();
CursorSet cs(NULL);
if(!path || cs.Load(path)!=B_OK)
return;
ServerCursor *csr;
if(cs.FindCursor(B_CURSOR_DEFAULT,&csr)==B_OK)
{
if(_defaultcsr)
delete _defaultcsr;
_defaultcsr=csr;
}
if(cs.FindCursor(B_CURSOR_TEXT,&csr)==B_OK)
{
if(_textcsr)
delete _textcsr;
_textcsr=csr;
}
if(cs.FindCursor(B_CURSOR_MOVE,&csr)==B_OK)
{
if(_movecsr)
delete _movecsr;
_movecsr=csr;
}
if(cs.FindCursor(B_CURSOR_DRAG,&csr)==B_OK)
{
if(_dragcsr)
delete _dragcsr;
_dragcsr=csr;
}
if(cs.FindCursor(B_CURSOR_RESIZE,&csr)==B_OK)
{
if(_resizecsr)
delete _resizecsr;
_resizecsr=csr;
}
if(cs.FindCursor(B_CURSOR_RESIZE_NWSE,&csr)==B_OK)
{
if(_resize_nwse_csr)
delete _resize_nwse_csr;
_resize_nwse_csr=csr;
}
if(cs.FindCursor(B_CURSOR_RESIZE_NESW,&csr)==B_OK)
{
if(_resize_nesw_csr)
delete _resize_nesw_csr;
_resize_nesw_csr=csr;
}
if(cs.FindCursor(B_CURSOR_RESIZE_NS,&csr)==B_OK)
{
if(_resize_ns_csr)
delete _resize_ns_csr;
_resize_ns_csr=csr;
}
if(cs.FindCursor(B_CURSOR_RESIZE_EW,&csr)==B_OK)
{
if(_resize_ew_csr)
delete _resize_ew_csr;
_resize_ew_csr=csr;
}
Unlock();
}
/*!
@ -298,7 +382,7 @@ ServerCursor *CursorManager::GetCursor(cursor_which which)
{
ServerCursor *temp=NULL;
acquire_sem(_lock);
Lock();
switch(which)
{
@ -351,7 +435,7 @@ ServerCursor *CursorManager::GetCursor(cursor_which which)
break;
}
release_sem(_lock);
Unlock();
return temp;
}
@ -363,9 +447,9 @@ cursor_which CursorManager::GetCursorWhich(void)
{
cursor_which temp;
acquire_sem(_lock);
Lock();
temp=_current_which;
release_sem(_lock);
Unlock();
return temp;
}
@ -380,7 +464,7 @@ cursor_which CursorManager::GetCursorWhich(void)
*/
void CursorManager::ChangeCursor(cursor_which which, int32 token)
{
acquire_sem(_lock);
Lock();
// Find the cursor, based on the token
ServerCursor *cursor=_FindCursor(token);
@ -388,7 +472,7 @@ void CursorManager::ChangeCursor(cursor_which which, int32 token)
// Did we find a cursor with this token?
if(!cursor)
{
release_sem(_lock);
Unlock();
return;
}
@ -407,6 +491,7 @@ void CursorManager::ChangeCursor(cursor_which which, int32 token)
delete cursor->_app_signature;
cursor->_app_signature=NULL;
}
_cursorlist->RemoveItem(cursor);
break;
}
case B_CURSOR_TEXT:
@ -421,6 +506,7 @@ void CursorManager::ChangeCursor(cursor_which which, int32 token)
delete cursor->_app_signature;
cursor->_app_signature=NULL;
}
_cursorlist->RemoveItem(cursor);
break;
}
case B_CURSOR_MOVE:
@ -435,6 +521,7 @@ void CursorManager::ChangeCursor(cursor_which which, int32 token)
delete cursor->_app_signature;
cursor->_app_signature=NULL;
}
_cursorlist->RemoveItem(cursor);
break;
}
case B_CURSOR_DRAG:
@ -449,6 +536,7 @@ void CursorManager::ChangeCursor(cursor_which which, int32 token)
delete cursor->_app_signature;
cursor->_app_signature=NULL;
}
_cursorlist->RemoveItem(cursor);
break;
}
case B_CURSOR_RESIZE:
@ -463,6 +551,7 @@ void CursorManager::ChangeCursor(cursor_which which, int32 token)
delete cursor->_app_signature;
cursor->_app_signature=NULL;
}
_cursorlist->RemoveItem(cursor);
break;
}
case B_CURSOR_RESIZE_NWSE:
@ -477,6 +566,7 @@ void CursorManager::ChangeCursor(cursor_which which, int32 token)
delete cursor->_app_signature;
cursor->_app_signature=NULL;
}
_cursorlist->RemoveItem(cursor);
break;
}
case B_CURSOR_RESIZE_NESW:
@ -491,6 +581,7 @@ void CursorManager::ChangeCursor(cursor_which which, int32 token)
delete cursor->_app_signature;
cursor->_app_signature=NULL;
}
_cursorlist->RemoveItem(cursor);
break;
}
case B_CURSOR_RESIZE_NS:
@ -505,6 +596,7 @@ void CursorManager::ChangeCursor(cursor_which which, int32 token)
delete cursor->_app_signature;
cursor->_app_signature=NULL;
}
_cursorlist->RemoveItem(cursor);
break;
}
case B_CURSOR_RESIZE_EW:
@ -519,13 +611,14 @@ void CursorManager::ChangeCursor(cursor_which which, int32 token)
delete cursor->_app_signature;
cursor->_app_signature=NULL;
}
_cursorlist->RemoveItem(cursor);
break;
}
default:
break;
}
release_sem(_lock);
Unlock();
}
/*!
@ -544,3 +637,31 @@ ServerCursor *CursorManager::_FindCursor(int32 token)
}
return NULL;
}
//! Sets the cursors to the defaults and saves them to CURSOR_SETTINGS_DIR/"d
void CursorManager::SetDefaults(void)
{
Lock();
CursorSet cs("Default");
cs.AddCursor(B_CURSOR_DEFAULT,default_cursor_data);
cs.AddCursor(B_CURSOR_TEXT,default_text_data);
cs.AddCursor(B_CURSOR_MOVE,default_move_data);
cs.AddCursor(B_CURSOR_DRAG,default_drag_data);
cs.AddCursor(B_CURSOR_RESIZE,default_resize_data);
cs.AddCursor(B_CURSOR_RESIZE_NWSE,default_resize_nwse_data);
cs.AddCursor(B_CURSOR_RESIZE_NESW,default_resize_nesw_data);
cs.AddCursor(B_CURSOR_RESIZE_NS,default_resize_ns_data);
cs.AddCursor(B_CURSOR_RESIZE_EW,default_resize_ew_data);
BDirectory dir;
if(dir.SetTo(CURSOR_SET_DIR)==B_ENTRY_NOT_FOUND)
create_directory(CURSOR_SET_DIR,0777);
BString string(CURSOR_SET_DIR);
string+="Default";
cs.Save(string.String(),B_CREATE_FILE | B_FAIL_IF_EXISTS);
SetCursorSet(string.String());
Unlock();
}

View File

@ -30,6 +30,7 @@
#include <List.h>
#include <OS.h>
#include <SysCursor.h>
#include <Locker.h>
#include "TokenHandler.h"
class ServerCursor;
@ -42,7 +43,7 @@ class ServerCursor;
any BeOS platform. It also provides tokens for BCursors and frees all
of an application's cursors whenever an application closes.
*/
class CursorManager
class CursorManager : public BLocker
{
public:
CursorManager(void);
@ -55,16 +56,16 @@ public:
void ObscureCursor(void);
void SetCursor(int32 token);
void SetCursor(cursor_which which);
void SetCursorSet(const char *path);
ServerCursor *GetCursor(cursor_which which);
cursor_which GetCursorWhich(void);
void ChangeCursor(cursor_which which, int32 token);
void SetDefaults(void);
private:
ServerCursor *_FindCursor(int32 token);
BList *_cursorlist;
TokenHandler _tokenizer;
sem_id _lock;
// System cursor members
ServerCursor *_defaultcsr,

View File

@ -160,6 +160,21 @@ void Decorator::SetFeel(int32 wfeel)
_feel=wfeel;
}
/*
\brief Sets the decorator's font
\param font The new font object to copy from
*/
void Decorator::SetFont(ServerFont *font)
{
if(!font)
return;
if(_layerdata.font)
delete _layerdata.font;
_layerdata.font=new ServerFont(*font);
}
/*!
\brief Sets the decorator's window look
\param wflags New value for the look

View File

@ -31,9 +31,8 @@
#include "ColorUtils.h"
#include "DefaultDecorator.h"
#include "RGBColor.h"
//#define DEBUG_DECORATOR
#include "RectUtils.h"
#include <stdio.h>
#define USE_VIEW_FILL_HACK
@ -44,22 +43,19 @@
DefaultDecorator::DefaultDecorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags)
: Decorator(rect,wlook,wfeel,wflags)
{
taboffset=0;
titlepixelwidth=0;
framecolors=new RGBColor[5];
framecolors[0].SetColor(255,255,255);
framecolors[1].SetColor(216,216,216);
framecolors[2].SetColor(152,152,152);
framecolors[3].SetColor(136,136,136);
framecolors[4].SetColor(96,96,96);
_SetFocus();
// These hard-coded assignments will go bye-bye when the system _colors
// API is implemented
frame_highercol.SetColor(216,216,216);
frame_lowercol.SetColor(110,110,110);
textcol.SetColor(0,0,0);
frame_highcol=frame_lowercol.MakeBlendColor(frame_highercol,0.75);
frame_midcol=frame_lowercol.MakeBlendColor(frame_highercol,0.5);
frame_lowcol=frame_lowercol.MakeBlendColor(frame_highercol,0.25);
_DoLayout();
// This flag is used to determine whether or not we're moving the tab
@ -81,6 +77,7 @@ DefaultDecorator::~DefaultDecorator(void)
#ifdef DEBUG_DECORATOR
printf("DefaultDecorator: ~DefaultDecorator()\n");
#endif
delete [] framecolors;
}
click_type DefaultDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
@ -184,6 +181,21 @@ printf("DefaultDecorator: Do Layout\n");
_borderrect=_frame;
_closerect=_frame;
switch(GetLook())
{
case B_BORDERED_WINDOW_LOOK:
case B_TITLED_WINDOW_LOOK:
case B_DOCUMENT_WINDOW_LOOK:
borderwidth=5;
break;
case B_FLOATING_WINDOW_LOOK:
case B_MODAL_WINDOW_LOOK:
borderwidth=3;
break;
default:
borderwidth=0;
}
textoffset=(_look==B_FLOATING_WINDOW_LOOK)?5:7;
_closerect.left+=(_look==B_FLOATING_WINDOW_LOOK)?2:4;
@ -191,8 +203,22 @@ printf("DefaultDecorator: Do Layout\n");
_closerect.right=_closerect.left+10;
_closerect.bottom=_closerect.top+10;
_borderrect.top+=19;
if(borderwidth)
{
// Set up the border rectangles to handle the window's frame
rightborder=leftborder=topborder=bottomborder=_borderrect;
// We want the rectangles to intersect because of the beveled intersections, so all
// that is necessary is to set the short dimension of each side
leftborder.right=leftborder.left+borderwidth;
rightborder.left=rightborder.right-borderwidth;
topborder.bottom=topborder.top+borderwidth;
bottomborder.top=bottomborder.bottom-borderwidth;
}
_resizerect.top=_resizerect.bottom-18;
_resizerect.left=_resizerect.right-18;
@ -307,7 +333,7 @@ printf("DefaultDecorator: Draw(%.1f,%.1f,%.1f,%.1f)\n",update.left,update.top,up
_layerdata.highcolor=_colors->document_background;
if(_borderrect.Intersects(update))
_driver->FillRect(_borderrect,&_layerdata,(int8*)&solidhigh);
_driver->FillRect(_borderrect & update,&_layerdata,(int8*)&solidhigh);
_DrawFrame(update);
}
@ -318,9 +344,9 @@ void DefaultDecorator::Draw(void)
// things
// Draw the top view's client area - just a hack :)
_layerdata.highcolor=_colors->document_background;
// _layerdata.highcolor=_colors->document_background;
_driver->FillRect(_borderrect,&_layerdata,(int8*)&solidhigh);
// _driver->FillRect(_borderrect,&_layerdata,(int8*)&solidhigh);
DrawFrame();
DrawTab();
@ -354,7 +380,7 @@ void DefaultDecorator::_DrawTab(BRect r)
_layerdata.highcolor=(GetFocus())?_colors->window_tab:_colors->inactive_window_tab;
_driver->FillRect(_tabrect,&_layerdata,(int8*)&solidhigh);
_layerdata.highcolor=frame_lowcol;
_layerdata.highcolor=framecolors[3];
_driver->StrokeLine(_tabrect.LeftBottom(),_tabrect.RightBottom(),&_layerdata,(int8*)&solidhigh);
_DrawTitle(_tabrect);
@ -423,69 +449,154 @@ void DefaultDecorator::DrawBlendedRect(BRect r, bool down)
// _layerdata.highcolor=startcol;
// _driver->FillRect(r,&_layerdata,(int8*)&solidhigh);
_layerdata.highcolor=frame_lowcol;
_layerdata.highcolor=framecolors[3];
_driver->StrokeRect(r,&_layerdata,(int8*)&solidhigh);
}
void DefaultDecorator::_DrawFrame(BRect rect)
void DefaultDecorator::_DrawFrame(BRect invalid)
{
// Duh, draws the window frame, I think. ;)
// We need to test each side to determine whether or not it needs drawn. Additionally,
// we must clip the lines drawn by this function to the invalid rectangle we are given
#ifdef USE_VIEW_FILL_HACK
_driver->FillRect(_borderrect,&_layerdata,(int8*)&solidhigh);
#endif
#ifdef USE_VIEW_FILL_HACK
_driver->FillRect(_borderrect,&_layerdata,(int8*)&solidhigh);
#endif
if(_look==B_NO_BORDER_WINDOW_LOOK)
if(!borderwidth)
return;
BRect r=_borderrect;
// Data specifically for the StrokeLineArray call.
int32 numlines=0, maxlines=20;
_layerdata.highcolor=frame_midcol;
BPoint points[maxlines*2];
RGBColor colors[maxlines];
// For quick calculation of gradients for each side. Top is same as left, right is same as
// bottom
int8 rightindices[borderwidth],leftindices[borderwidth];
if(borderwidth==5)
{
leftindices[0]=2;
leftindices[1]=0;
leftindices[2]=1;
leftindices[3]=3;
leftindices[4]=2;
rightindices[0]=2;
rightindices[1]=0;
rightindices[2]=1;
rightindices[3]=3;
rightindices[4]=4;
}
else
{
// TODO: figure out border colors for floating window look
}
// Right side
if(TestRectIntersection(rightborder,invalid))
{
// We may not have to redraw the entire width of the frame itself. Rare case, but
// it must be accounted for.
int32 startx=(int32) MAX(invalid.left,rightborder.left);
int32 endx=(int32) MIN(invalid.right,rightborder.right);
// We'll need these flags to see if we must include the corners in final line
// calculations
BRect r(rightborder);
r.bottom=r.top+borderwidth;
bool topcorner=TestRectIntersection(invalid,r);
r=rightborder;
r.top=r.bottom-borderwidth;
bool bottomcorner=TestRectIntersection(invalid,r);
// Generate the lines for this side
for(int32 i=startx; i<endx; i++)
{
BPoint start, end;
start.x=end.x=i;
if(topcorner)
{
start.y=rightborder.top+(borderwidth-(i-rightborder.left));
start.y=MAX(start.y,invalid.top);
}
else
start.y=MAX(start.y+borderwidth,invalid.top);
if(bottomcorner)
{
end.y=rightborder.bottom-(borderwidth-(i-rightborder.left));
end.y=MAX(end.y,invalid.top);
}
else
end.y=MAX(end.y-borderwidth,invalid.top);
// Make the appropriate
points[numlines*2]=start;
points[(numlines*2)+1]=end;
colors[numlines]=framecolors[rightindices[endx-i]];
numlines++;
}
}
debugger("");
_driver->StrokeLineArray(points,numlines,colors,&_layerdata);
/* BRect r=_borderrect;
_layerdata.highcolor=framecolors[2];
_driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.right-1,r.top),
&_layerdata,(int8*)&solidhigh);
_layerdata.highcolor=frame_lowcol;
_layerdata.highcolor=framecolors[3];
_driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.left,r.bottom),
&_layerdata,(int8*)&solidhigh);
_layerdata.highcolor=frame_lowercol;
_layerdata.highcolor=framecolors[4];
_driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.right,r.top),
&_layerdata,(int8*)&solidhigh);
_layerdata.highcolor=frame_lowercol;
_layerdata.highcolor=framecolors[4];
_driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.left,r.bottom),
&_layerdata,(int8*)&solidhigh);
r.InsetBy(1,1);
_layerdata.highcolor=frame_highercol;
_layerdata.highcolor=framecolors[0];
_driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.right-1,r.top),
&_layerdata,(int8*)&solidhigh);
_layerdata.highcolor=frame_highercol;
_layerdata.highcolor=framecolors[0];
_driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.left,r.bottom),
&_layerdata,(int8*)&solidhigh);
_layerdata.highcolor=frame_midcol;
_layerdata.highcolor=framecolors[2];
_driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.right,r.top),
&_layerdata,(int8*)&solidhigh);
_layerdata.highcolor=frame_midcol;
_layerdata.highcolor=framecolors[2];
_driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.left,r.bottom),
&_layerdata,(int8*)&solidhigh);
r.InsetBy(1,1);
_layerdata.highcolor=frame_highcol;
_layerdata.highcolor=framecolors[1];
_driver->StrokeRect(r,&_layerdata,(int8*)&solidhigh);
r.InsetBy(1,1);
_layerdata.highcolor=frame_lowercol;
_layerdata.highcolor=framecolors[4];
_driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.right-1,r.top),
&_layerdata,(int8*)&solidhigh);
_layerdata.highcolor=frame_lowercol;
_layerdata.highcolor=framecolors[4];
_driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.left,r.bottom),
&_layerdata,(int8*)&solidhigh);
_layerdata.highcolor=frame_highercol;
_layerdata.highcolor=framecolors[0];
_driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.right,r.top),
&_layerdata,(int8*)&solidhigh);
_layerdata.highcolor=frame_highercol;
_layerdata.highcolor=framecolors[0];
_driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.left,r.bottom),
&_layerdata,(int8*)&solidhigh);
_driver->StrokeRect(_borderrect,&_layerdata,(int8*)&solidhigh);
// Draw the resize thumb if we're supposed to
if(!(_flags & B_NOT_RESIZABLE))
{
@ -501,10 +612,10 @@ _driver->FillRect(_borderrect,&_layerdata,(int8*)&solidhigh);
int steps=(w<h)?w:h;
startcol=frame_highercol.GetColor32();
endcol=frame_lowercol.GetColor32();
startcol=framecolors[0].GetColor32();
endcol=framecolors[4].GetColor32();
halfcol=frame_highercol.MakeBlendColor(frame_lowercol,0.5).GetColor32();
halfcol=framecolors[0].MakeBlendColor(framecolors[4],0.5).GetColor32();
rstep=(startcol.red-halfcol.red)/steps;
gstep=(startcol.green-halfcol.green)/steps;
@ -525,16 +636,18 @@ _driver->FillRect(_borderrect,&_layerdata,(int8*)&solidhigh);
_driver->StrokeLine(BPoint(r.left+steps,r.top+i),
BPoint(r.left+i,r.top+steps),&_layerdata,(int8*)&solidhigh);
}
_layerdata.highcolor=frame_lowercol;
_layerdata.highcolor=framecolors[4];
_driver->StrokeRect(r,&_layerdata,(int8*)&solidhigh);
}
else
{
_layerdata.highcolor=frame_lowercol;
_layerdata.highcolor=framecolors[4];
_driver->StrokeLine(BPoint(r.right,r.top),BPoint(r.right-3,r.top),
&_layerdata,(int8*)&solidhigh);
_driver->StrokeLine(BPoint(r.left,r.bottom),BPoint(r.left,r.bottom-3),
&_layerdata,(int8*)&solidhigh);
}
}
*/
}

View File

@ -59,8 +59,15 @@ protected:
RGBColor frame_highcol, frame_midcol, frame_lowcol, frame_highercol,
frame_lowercol;
RGBColor textcol;
RGBColor *framecolors;
// Individual rects for handling window frame rendering the proper way
BRect rightborder,leftborder,topborder,bottomborder;
uint64 solidhigh, solidlow;
int32 borderwidth;
bool slidetab;
int textoffset;
float titlepixelwidth;

View File

@ -29,7 +29,6 @@
#include FT_CACHE_H
FTC_Manager ftmanager;
FT_Library ftlib;
/*!
\brief Constructor

View File

@ -37,6 +37,8 @@
#include "ServerFont.h"
#include "ServerConfig.h"
extern FTC_Manager ftmanager;
FT_Library ftlib;
FontServer *fontserver;
/*!

View File

@ -7,6 +7,9 @@ UsePrivateHeaders app interface [ FDirName servers app ] ;
UseFreeTypeHeaders ;
SharedLibrary appserver :
areafunc.c
bget.c
BitmapManager.cpp
ColorSet.cpp
Decorator.cpp
DisplayDriver.cpp
@ -17,7 +20,9 @@ SharedLibrary appserver :
ServerBitmap.cpp
ServerCursor.cpp
ServerFont.cpp
SysCursor.cpp
SystemPalette.cpp
TokenHandler.cpp
;
LinkSharedOSLibs libappserver.so : root be
@ -26,11 +31,8 @@ LinkSharedOSLibs libappserver.so : root be
Server app_server :
# Misc. Sources
areafunc.c
Angle.cpp
bget.c
CursorData.cpp
TokenHandler.cpp
PicturePlayer.cpp
PNGDump.cpp
@ -39,7 +41,6 @@ Server app_server :
# Manager Classes
AppServer.cpp
BitmapDriver.cpp
BitmapManager.cpp
CursorManager.cpp
Desktop.cpp
ServerApp.cpp

View File

@ -36,7 +36,7 @@
#include "RectUtils.h"
//#define DEBUG_LAYER
#define DEBUG_REGIONS
//#define DEBUG_REGIONS
#ifdef DEBUG_REGIONS
#include "Desktop.h"
@ -71,9 +71,9 @@ Layer::Layer(BRect frame, const char *name, int32 resize, int32 flags,ServerWind
_topchild=NULL;
_bottomchild=NULL;
_visible=new BRegion(Bounds());
_full=new BRegion(Bounds());
_invalid=new BRegion(Bounds());
_visible=new BRegion(Frame());
_full=new BRegion(Frame());
_invalid=new BRegion(Frame());
_serverwin=win;

View File

@ -337,11 +337,13 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer)
// Attached data:
// 1) port_id reply port
// 2) BRect window frame
// 3) uint32 window flags
// 4) port_id window's message port
// 5) uint32 workspace index
// 6) int32 BHandler token of the window
// 7) const char * title
// 3) uint32 window look
// 4) uint32 window feel
// 5) uint32 window flags
// 6) port_id window's message port
// 7) uint32 workspace index
// 8) int32 BHandler token of the window
// 9) const char * title
// Find the necessary data
port_id reply_port=*((port_id*)index); index+=sizeof(port_id);
@ -483,33 +485,33 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer)
case AS_CREATE_PICTURE:
{
// TODO: Implement
#ifdef DEBUG_SERVERAPP
printf("ServerApp %s: Create Picture unimplemented\n",_signature.String());
#endif
#ifdef DEBUG_SERVERAPP
printf("ServerApp %s: Create Picture unimplemented\n",_signature.String());
#endif
break;
}
case AS_DELETE_PICTURE:
{
// TODO: Implement
#ifdef DEBUG_SERVERAPP
printf("ServerApp %s: Delete Picture unimplemented\n",_signature.String());
#endif
#ifdef DEBUG_SERVERAPP
printf("ServerApp %s: Delete Picture unimplemented\n",_signature.String());
#endif
break;
}
case AS_CLONE_PICTURE:
{
// TODO: Implement
#ifdef DEBUG_SERVERAPP
printf("ServerApp %s: Clone Picture unimplemented\n",_signature.String());
#endif
#ifdef DEBUG_SERVERAPP
printf("ServerApp %s: Clone Picture unimplemented\n",_signature.String());
#endif
break;
}
case AS_DOWNLOAD_PICTURE:
{
// TODO; Implement
#ifdef DEBUG_SERVERAPP
printf("ServerApp %s: Download Picture unimplemented\n",_signature.String());
#endif
#ifdef DEBUG_SERVERAPP
printf("ServerApp %s: Download Picture unimplemented\n",_signature.String());
#endif
break;
}
case AS_SET_SCREEN_MODE:
@ -669,7 +671,7 @@ printf("ServerApp %s: Download Picture unimplemented\n",_signature.String());
default:
{
#ifdef DEBUG_SERVERAPP
printf("ServerApp %s received unhandled message code %lx\n",_signature.String(),code);
printf("ServerApp %s received unhandled message code offset %lx\n",_signature.String(),MsgCodeToString(code));
#endif
break;
}

View File

@ -223,6 +223,7 @@ void ServerWindow::Show(void)
if(_winborder)
{
_winborder->Show();
_winborder->SetFocus(true);
_winborder->UpdateRegions(true);
}
}
@ -261,6 +262,7 @@ void ServerWindow::SetFocus(bool value)
if(_active!=value)
{
_active=value;
_winborder->SetFocus(value);
_winborder->RequestDraw();
}
}
@ -627,7 +629,7 @@ void ServerWindow::DispatchMessage(PortMessage *msg)
}
default:
{
printf("ServerWindow %s received unexpected code %s\n",_title->String(),MsgCodeToString(msg->Code()));
printf("ServerWindow %s received unexpected code - message offset %lx\n",_title->String(),msg->Code()-SERVER_TRUE);
break;
}
}

View File

@ -1040,9 +1040,43 @@ void ViewDriver::StrokeLine(BPoint start, BPoint end, LayerData *d, int8 *pat)
void ViewDriver::StrokeLineArray(BPoint *pts, int32 numlines, RGBColor *colors, LayerData *d)
{
#ifdef DEBUG_DRIVER_MODULE
printf("ViewDriver:: StrokeLineArray unimplemented\n");
#endif
if(!d || numlines==0 || !pts || !colors)
return;
screenwin->Lock();
framebuffer->Lock();
SetLayerData(d);
// Do LineArray stuff here.
// drawview->Sync();
// screenwin->view->Invalidate();
// for now, just print the data and hope we don't crash
printf("ViewDriver::StrokeLineArray(): \n");
BPoint *ptindex=pts;
for(int32 i=0; i<numlines; i++)
{
BPoint pt1=*ptindex;
ptindex+=sizeof(BPoint);
BPoint pt2=*ptindex;
ptindex+=sizeof(BPoint);
rgb_color col=colors[i].GetColor32();
drawview->SetHighColor(col);
drawview->StrokeLine(pt1,pt2,B_SOLID_HIGH);
printf("\tLine (%.1f,%.1f)-(%.1f,%.1f) in color (%d,%d,%d)\n",pt1.x,pt1.y,pt2.x,pt2.y,
col.red,col.green,col.blue);
}
drawview->Sync();
screenwin->view->Invalidate();
framebuffer->Unlock();
screenwin->Unlock();
}
void ViewDriver::StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat, bool is_closed)

View File

@ -37,6 +37,8 @@
#include "WinBorder.h"
#include "AppServer.h" // for new_decorator()
// TODO: Document this file completely
//#define DEBUG_WINBORDER
//#define DEBUG_WINBORDER_MOUSE
//#define DEBUG_WINBORDER_CLICK
@ -72,9 +74,13 @@ void set_is_sliding_tab(bool state) { winborder_private::is_sliding_tab=state; }
WinBorder * get_active_winborder(void) { return winborder_private::active_winborder; }
void set_active_winborder(WinBorder *win) { winborder_private::active_winborder=win; }
WinBorder::WinBorder(BRect r, const char *name, int32 look, int32 feel, int32 flags, ServerWindow *win)
WinBorder::WinBorder(const BRect &r, const char *name, const int32 look, const int32 feel,
const int32 flags, ServerWindow *win)
: Layer(r,name,B_FOLLOW_NONE,flags,win)
{
// unlike BViews, windows start off as hidden, so we need to tweak the hidecount
// assignment made by Layer().
_hidecount=1;
_mbuttons=0;
_kmodifiers=0;
_win=win;
@ -153,7 +159,7 @@ printf("Click: MoveToFront\n");
printf("Click: Close\n");
#endif
_decorator->SetClose(true);
_decorator->Draw();
_decorator->DrawClose();
break;
}
case CLICK_ZOOM:
@ -162,7 +168,7 @@ printf("Click: Close\n");
printf("Click: Zoom\n");
#endif
_decorator->SetZoom(true);
_decorator->Draw();
_decorator->DrawZoom();
break;
}
case CLICK_MINIMIZE:
@ -171,7 +177,7 @@ printf("Click: Zoom\n");
printf("Click: Minimize\n");
#endif
_decorator->SetMinimize(true);
_decorator->Draw();
_decorator->DrawMinimize();
break;
}
case CLICK_DRAG:
@ -357,7 +363,7 @@ void WinBorder::MouseUp(int8 *buffer)
BPoint pt(x,y);
#ifdef DEBUG_WINBORDER_MOUSE
printf("WinBorder %s: MouseUp unimplmented\n",_title->String());
printf("WinBorder %s: MouseUp unimplemented\n",_title->String());
#endif
_mbuttons=0;
@ -374,7 +380,7 @@ printf("WinBorder %s: MouseUp unimplmented\n",_title->String());
case CLICK_CLOSE:
{
_decorator->SetClose(false);
_decorator->Draw();
_decorator->DrawClose();
// call close window stuff here
@ -383,7 +389,7 @@ printf("WinBorder %s: MouseUp unimplmented\n",_title->String());
case CLICK_ZOOM:
{
_decorator->SetZoom(false);
_decorator->Draw();
_decorator->DrawZoom();
// call zoom stuff here
@ -392,7 +398,7 @@ printf("WinBorder %s: MouseUp unimplmented\n",_title->String());
case CLICK_MINIMIZE:
{
_decorator->SetMinimize(false);
_decorator->Draw();
_decorator->DrawMinimize();
// call minimize stuff here
@ -404,6 +410,16 @@ printf("WinBorder %s: MouseUp unimplmented\n",_title->String());
}
}
/*!
\brief Function to pass focus value on to decorator
\param active Focus flag
*/
void WinBorder::SetFocus(const bool &active)
{
if(_decorator)
_decorator->SetFocus(active);
}
void WinBorder::RequestDraw(const BRect &r)
{
#ifdef DEBUG_WINBORDER

View File

@ -38,7 +38,8 @@ class DisplayDriver;
class WinBorder : public Layer
{
public:
WinBorder(BRect r, const char *name, int32 look, int32 feel, int32 flags, ServerWindow *win);
WinBorder(const BRect &r, const char *name, const int32 look, const int32 feel,
const int32 flags, ServerWindow *win);
~WinBorder(void);
void RequestDraw(void);
void RequestDraw(const BRect &r);
@ -53,8 +54,8 @@ public:
void UpdateDecorator(void);
void UpdateFont(void);
void UpdateScreen(void);
void RebuildRegions(bool recursive=true);
void Activate(bool active=false);
void RebuildRegions(const bool &recursive=true);
void SetFocus(const bool &active=false);
ServerWindow *Window(void) { return _win; }
Decorator *GetDecorator(void) { return _decorator; }
protected: