Added a couple hooks to DisplayDriver

app_server will now display a window. Can't do anything with it, at least not yet.
GUI colors are also used now


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3047 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm 2003-03-30 21:09:39 +00:00
parent f8931e9215
commit 812870fc43
11 changed files with 247 additions and 44 deletions

View File

@ -27,6 +27,7 @@
#include <AppDefs.h> #include <AppDefs.h>
#include <Entry.h> #include <Entry.h>
#include "AppServer.h" #include "AppServer.h"
#include "ColorSet.h"
#include "Desktop.h" #include "Desktop.h"
#include "DisplayDriver.h" #include "DisplayDriver.h"
#include "PortLink.h" #include "PortLink.h"
@ -50,6 +51,9 @@ AppServer *app_server=NULL;
//! Default background color for workspaces //! Default background color for workspaces
RGBColor workspace_default_color(51,102,160); RGBColor workspace_default_color(51,102,160);
//! System-wide GUI color object
ColorSet gui_colorset;
/*! /*!
\brief Constructor \brief Constructor
@ -91,7 +95,12 @@ AppServer::AppServer(void)
printf("Couldn't set fixed to %s, %s %d pt\n",DEFAULT_FIXED_FONT_FAMILY, printf("Couldn't set fixed to %s, %s %d pt\n",DEFAULT_FIXED_FONT_FAMILY,
DEFAULT_FIXED_FONT_STYLE,DEFAULT_FIXED_FONT_SIZE); DEFAULT_FIXED_FONT_STYLE,DEFAULT_FIXED_FONT_SIZE);
fontserver->Unlock(); fontserver->Unlock();
// Get the GUI colors here. For now, we'll just set the defaults
SetDefaultGUIColors(&gui_colorset);
// TODO: load the GUI colors here and set the global set to the values contained therein
// Set up the Desktop // Set up the Desktop
InitDesktop(); InitDesktop();
@ -928,10 +937,17 @@ ServerApp *AppServer::FindApp(const char *sig)
Decorator *new_decorator(BRect rect, const char *title, int32 wlook, int32 wfeel, Decorator *new_decorator(BRect rect, const char *title, int32 wlook, int32 wfeel,
int32 wflags, DisplayDriver *ddriver) int32 wflags, DisplayDriver *ddriver)
{ {
Decorator *dec;
if(!app_server->make_decorator) if(!app_server->make_decorator)
return new DefaultDecorator(rect,wlook,wfeel,wflags); dec=new DefaultDecorator(rect,wlook,wfeel,wflags);
else
dec=app_server->make_decorator(rect,wlook,wfeel,wflags);
gui_colorset.Lock();
dec->SetColors(gui_colorset);
gui_colorset.Unlock();
return app_server->make_decorator(rect,wlook,wfeel,wflags); return dec;
} }
/*! /*!

View File

@ -125,9 +125,7 @@ void ColorSet::SetColors(const ColorSet &cs)
inactive_window_tab_text=cs.inactive_window_tab_text; inactive_window_tab_text=cs.inactive_window_tab_text;
} }
/*! //! Prints all color set elements to stdout
\brief Prints all color set elements to stdout
*/
void ColorSet::PrintToStream(void) void ColorSet::PrintToStream(void)
{ {
printf("panel_background "); panel_background.PrintToStream(); printf("panel_background "); panel_background.PrintToStream();
@ -164,3 +162,41 @@ void ColorSet::PrintToStream(void)
printf("inactive_window_tab "); inactive_window_tab.PrintToStream(); printf("inactive_window_tab "); inactive_window_tab.PrintToStream();
printf("inactive_window_tab_text "); inactive_window_tab_text.PrintToStream(); printf("inactive_window_tab_text "); inactive_window_tab_text.PrintToStream();
} }
/*!
\brief Assigns the default system colors to the passed ColorSet object
\param The ColorSet object to set to defaults
*/
void SetDefaultGUIColors(ColorSet *set)
{
#ifdef DEBUG_COLORSET
printf("Initializing color settings to defaults\n");
#endif
set->panel_background.SetColor(216,216,216);
set->panel_text.SetColor(0,0,0);
set->document_background.SetColor(255,255,255);
set->document_text.SetColor(0,0,0);
set->control_background.SetColor(245,245,245);
set->control_text.SetColor(0,0,0);
set->control_border.SetColor(0,0,0);
set->control_highlight.SetColor(115,120,184);
set->keyboard_navigation_base.SetColor(170,50,184);
set->keyboard_navigation_pulse.SetColor(0,0,0);
set->shine.SetColor(255,255,255);
set->shadow.SetColor(0,0,0);
set->menu_background.SetColor(216,216,216);
set->menu_selected_background.SetColor(115,120,184);
set->menu_text.SetColor(0,0,0);
set->menu_selected_text.SetColor(255,255,255);
set->menu_selected_border.SetColor(0,0,0);
set->tooltip_background.SetColor(255,255,0);
set->tooltip_text.SetColor(0,0,0);
set->success.SetColor(0,255,0);
set->failure.SetColor(255,0,0);
set->window_tab.SetColor(255,203,0);
// important, but not publically accessible GUI colors
set->window_tab_text.SetColor(0,0,0);
set->inactive_window_tab.SetColor(232,232,232);
set->inactive_window_tab_text.SetColor(80,80,80);
}

View File

@ -28,13 +28,14 @@
#ifndef COLORSET_H_ #ifndef COLORSET_H_
#define COLORSET_H_ #define COLORSET_H_
#include <Locker.h>
#include "RGBColor.h" #include "RGBColor.h"
/*! /*!
\class ColorSet ColorSet.h \class ColorSet ColorSet.h
\brief Encapsulates GUI system colors \brief Encapsulates GUI system colors
*/ */
class ColorSet class ColorSet : public BLocker
{ {
public: public:
ColorSet(void); ColorSet(void);
@ -70,13 +71,15 @@ public:
failure, failure,
shine, shine,
shadow, shadow,
window_tab,
// Not all of these guys don't exist in InterfaceDefs.h, but we keep // Not all of these guys don't exist in InterfaceDefs.h, but we keep
// them as part of the color set anyway - they're important nonetheless // them as part of the color set anyway - they're important nonetheless
window_tab,
window_tab_text, window_tab_text,
inactive_window_tab, inactive_window_tab,
inactive_window_tab_text; inactive_window_tab_text;
}; };
void SetDefaultGUIColors(ColorSet *set);
#endif #endif

View File

@ -32,6 +32,7 @@
#include "RGBColor.h" #include "RGBColor.h"
//#define DEBUG_DECORATOR //#define DEBUG_DECORATOR
#define USE_VIEW_FILL_HACK
#ifdef DEBUG_DECORATOR #ifdef DEBUG_DECORATOR
#include <stdio.h> #include <stdio.h>
@ -423,6 +424,10 @@ void DefaultDecorator::_DrawFrame(BRect rect)
{ {
// Duh, draws the window frame, I think. ;) // Duh, draws the window frame, I think. ;)
#ifdef USE_VIEW_FILL_HACK
_driver->FillRect(_borderrect,&_layerdata,(int8*)&solidhigh);
#endif
if(_look==B_NO_BORDER_WINDOW_LOOK) if(_look==B_NO_BORDER_WINDOW_LOOK)
return; return;

View File

@ -25,6 +25,7 @@
// for the server // for the server
// //
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include <Accelerant.h>
#include "DisplayDriver.h" #include "DisplayDriver.h"
#include "ServerCursor.h" #include "ServerCursor.h"
@ -46,6 +47,8 @@ DisplayDriver::DisplayDriver(void)
_is_cursor_hidden=false; _is_cursor_hidden=false;
_is_cursor_obscured=false; _is_cursor_obscured=false;
_cursor=NULL; _cursor=NULL;
_dpms_caps=0;
_dpms_state=B_DPMS_ON;
} }
@ -476,6 +479,15 @@ bool DisplayDriver::DumpToFile(const char *path)
return false; return false;
} }
/*!
\brief Returns a new ServerBitmap containing the contents of the frame buffer
\return A new ServerBitmap containing the contents of the frame buffer or NULL if unsuccessful
*/
ServerBitmap *DisplayDriver::DumpToBitmap(void)
{
return NULL;
}
/*! /*!
\brief Gets the width of a string in pixels \brief Gets the width of a string in pixels
\param string Source null-terminated string \param string Source null-terminated string
@ -582,6 +594,33 @@ void DisplayDriver::GetTruncatedStrings( const char **instrings, int32 stringcou
{ {
} }
/*!
\brief Sets the DPMS state of the driver
\param state The new state for the display. See Accelerant.h
*/
status_t DisplayDriver::SetDPMSState(uint32 state)
{
return B_OK;
}
/*!
\brief Returns the current DPMS state
\return The current DPMS state
*/
uint32 DisplayDriver::GetDPMSState(void)
{
return _dpms_state;
}
/*!
\brief Returns the current DPMS capabilities
\return The current DPMS capabilities
*/
uint32 DisplayDriver::GetDPMSCapabilities(void)
{
return _dpms_caps;
}
/*! /*!
\brief Returns the bit depth for the current screen mode \brief Returns the bit depth for the current screen mode
\return Current number of bits per pixel \return Current number of bits per pixel
@ -722,6 +761,31 @@ void DisplayDriver::_SetBytesPerRow(uint32 bpr)
_bytes_per_row=bpr; _bytes_per_row=bpr;
} }
/*!
\brief Internal DPMS value-setting function
\param state The new capabilities of the driver
_SetDPMSState must be called from within any implementation of SetDPMSState. Note that this
does not actually change the state itself; it just updates the state variable used
to talk with the outside world.
*/
void DisplayDriver::_SetDPMSState(uint32 state)
{
_dpms_caps=state;
}
/*!
\brief Internal DPMS value-setting function
\param state The new capabilities of the driver
_SetDPMSCapabilities must be called at the initialization of the driver so that
GetDPMSCapabilities returns the proper values.
*/
void DisplayDriver::_SetDPMSCapabilities(uint32 caps)
{
_dpms_caps=caps;
}
/*! /*!
\brief Obtains the current cursor for the driver. \brief Obtains the current cursor for the driver.
\return Pointer to the current cursor object. \return Pointer to the current cursor object.

View File

@ -129,6 +129,7 @@ public:
virtual void StrokeLineArray(BPoint *pts, int32 numlines, RGBColor *colors, LayerData *d); virtual void StrokeLineArray(BPoint *pts, int32 numlines, RGBColor *colors, LayerData *d);
virtual void SetMode(int32 mode); virtual void SetMode(int32 mode);
virtual bool DumpToFile(const char *path); virtual bool DumpToFile(const char *path);
virtual ServerBitmap *DumpToBitmap(void);
virtual float StringWidth(const char *string, int32 length, LayerData *d); virtual float StringWidth(const char *string, int32 length, LayerData *d);
virtual float StringHeight(const char *string, int32 length, LayerData *d); virtual float StringHeight(const char *string, int32 length, LayerData *d);
@ -141,7 +142,10 @@ public:
virtual void GetHasGlyphs(const char *string, int32 charcount, bool *hasarray); virtual void GetHasGlyphs(const char *string, int32 charcount, bool *hasarray);
virtual void GetTruncatedStrings( const char **instrings, int32 stringcount, uint32 mode, virtual void GetTruncatedStrings( const char **instrings, int32 stringcount, uint32 mode,
float maxwidth, char **outstrings); float maxwidth, char **outstrings);
virtual status_t SetDPMSState(uint32 state);
uint32 GetDPMSState(void);
uint32 GetDPMSCapabilities(void);
uint8 GetDepth(void); uint8 GetDepth(void);
uint16 GetHeight(void); uint16 GetHeight(void);
uint16 GetWidth(void); uint16 GetWidth(void);
@ -157,6 +161,8 @@ protected:
void _SetWidth(uint16 w); void _SetWidth(uint16 w);
void _SetMode(int32 m); void _SetMode(int32 m);
void _SetBytesPerRow(uint32 bpr); void _SetBytesPerRow(uint32 bpr);
void _SetDPMSCapabilities(uint32 caps);
void _SetDPMSState(uint32 state);
ServerCursor *_GetCursor(void); ServerCursor *_GetCursor(void);
private: private:
@ -169,6 +175,8 @@ private:
bool _is_cursor_hidden; bool _is_cursor_hidden;
bool _is_cursor_obscured; bool _is_cursor_obscured;
ServerCursor *_cursor; ServerCursor *_cursor;
uint32 _dpms_state;
uint32 _dpms_caps;
}; };
#endif #endif

View File

@ -33,8 +33,9 @@
#include "ServerWindow.h" #include "ServerWindow.h"
#include "PortLink.h" #include "PortLink.h"
#include "TokenHandler.h" #include "TokenHandler.h"
#include "RectUtils.h"
//#define DEBUG_LAYER #define DEBUG_LAYER
//! TokenHandler object used to provide IDs for all Layers and, thus, BViews //! TokenHandler object used to provide IDs for all Layers and, thus, BViews
TokenHandler view_token_handler; TokenHandler view_token_handler;
@ -78,6 +79,7 @@ Layer::Layer(BRect frame, const char *name, int32 resize, int32 flags,ServerWind
_hidecount=0; _hidecount=0;
_is_dirty=false; _is_dirty=false;
_is_updating=false; _is_updating=false;
_regions_invalid=false;
_level=0; _level=0;
_layerdata=new LayerData; _layerdata=new LayerData;
@ -519,6 +521,78 @@ bool Layer::IsDirty(void) const
return (!_invalid)?true:false; return (!_invalid)?true:false;
} }
/*!
\brief Forces a repaint if there are invalid areas
\param force_update Force an update. False by default.
*/
void Layer::UpdateIfNeeded(bool force_update)
{
#ifdef DEBUG_LAYER
printf("Layer: %s: UpdateIfNeeded(%s)\n",_name->String(),
force_update?"force update":"don't force update");
#endif
Layer *child;
if(IsHidden())
return;
if(force_update)
{
if(_invalid)
RequestDraw(_invalid->Frame());
else
RequestDraw();
}
else
{
if(_invalid)
RequestDraw(_invalid->Frame());
}
for(child=_bottomchild; child!=NULL; child=child->_uppersibling)
child->UpdateIfNeeded(force_update);
_is_dirty=false;
}
/*!
\brief Marks the layer as needing a region rebuild if intersecting the given rect
\param rect The rectangle for checking to see if the layer needs to be rebuilt
*/
void Layer::MarkModified(BRect rect)
{
#ifdef DEBUG_LAYER
printf("Layer: %s: MarkModified(%.1f%.1f,%.1f,%.1f)\n",_name->String(),
rect.left,rect.top,rect.right,rect.bottom);
#endif
if(TestRectIntersection(Bounds(),rect))
_regions_invalid=true;
Layer *child;
for(child=_bottomchild; child!=NULL; child=child->_uppersibling)
child->MarkModified(rect.OffsetByCopy(-child->_frame.left,-child->_frame.top));
}
/*!
\brief Rebuilds the layer's regions and updates the screen as needed
\param force Force an update
*/
void Layer::UpdateRegions(bool force)
{
#ifdef DEBUG_LAYER
printf("Layer: %s: UpdateRegions(%s)\n",_name->String(),
force?"force update":"don't force update");
#endif
if(force)
{
RebuildRegions(true);
// MoveChildren();
// InvalidateNewAreas();
}
if( (_regions_invalid && (_parent==NULL) && _invalid) || force)
UpdateIfNeeded(force);
}
//! Show the layer. Operates just like the BView call with the same name //! Show the layer. Operates just like the BView call with the same name
void Layer::Show(void) void Layer::Show(void)
{ {
@ -529,14 +603,23 @@ printf("Layer: %s: Show\n",_name->String());
return; return;
_hidecount--; _hidecount--;
if(_hidecount==0)
{ if(_hidecount>0)
BRegion *reg=new BRegion(ConvertToParent(_visible)); return;
_parent->_visible->Exclude(reg);
delete reg; BRegion *reg=new BRegion(ConvertToParent(_visible));
_is_dirty=true; _parent->_visible->Exclude(reg);
} delete reg;
_is_dirty=true;
_parent->_is_dirty=true;
Layer *sibling;
for (sibling=_parent->_bottomchild; sibling!=NULL; sibling=sibling->_uppersibling)
{
if(TestRectIntersection(sibling->_frame,_frame))
sibling->MarkModified(_frame.OffsetByCopy(-sibling->_frame.left,-sibling->_frame.top));
}
Layer *child; Layer *child;
for(child=_topchild; child!=NULL; child=child->_lowersibling) for(child=_topchild; child!=NULL; child=child->_lowersibling)
child->Show(); child->Show();
@ -712,6 +795,7 @@ printf("Layer: %s: Rebuild Regions (%s)\n",_name->String(),include_children?"inc
lay->RebuildRegions(true); lay->RebuildRegions(true);
} }
} }
_regions_invalid=false;
} }
//! Prints all relevant layer data to stdout //! Prints all relevant layer data to stdout

View File

@ -72,6 +72,9 @@ public:
virtual void RequestDraw(const BRect &r); virtual void RequestDraw(const BRect &r);
virtual void RequestDraw(void); virtual void RequestDraw(void);
bool IsDirty(void) const; bool IsDirty(void) const;
void UpdateIfNeeded(bool force_update=false);
void MarkModified(BRect rect);
void UpdateRegions(bool force=false);
void Show(void); void Show(void);
void Hide(void); void Hide(void);
@ -99,6 +102,7 @@ public:
protected: protected:
friend RootLayer; friend RootLayer;
friend WinBorder; friend WinBorder;
BRect _frame; BRect _frame;
@ -121,6 +125,7 @@ protected:
uint8 _hidecount; uint8 _hidecount;
bool _is_dirty; bool _is_dirty;
bool _is_updating; bool _is_updating;
bool _regions_invalid;
LayerData *_layerdata; LayerData *_layerdata;
PortLink *_portlink; PortLink *_portlink;
}; };

View File

@ -185,7 +185,10 @@ void ServerWindow::Show(void)
printf("ServerWindow %s: Show\n",_title->String()); printf("ServerWindow %s: Show\n",_title->String());
#endif #endif
if(_winborder) if(_winborder)
{
_winborder->Show(); _winborder->Show();
_winborder->UpdateRegions(true);
}
} }
//! Hides the window's WinBorder //! Hides the window's WinBorder

View File

@ -37,7 +37,7 @@
#include "WinBorder.h" #include "WinBorder.h"
#include "AppServer.h" // for new_decorator() #include "AppServer.h" // for new_decorator()
//#define DEBUG_WINBORDER #define DEBUG_WINBORDER
//#define DEBUG_WINBORDER_MOUSE //#define DEBUG_WINBORDER_MOUSE
#ifdef DEBUG_WINBORDER #ifdef DEBUG_WINBORDER
@ -81,6 +81,8 @@ WinBorder::WinBorder(BRect r, const char *name, int32 look, int32 feel, int32 fl
_vresizewin=false; _vresizewin=false;
_decorator=new_decorator(r,name,look,feel,flags,GetGfxDriver()); _decorator=new_decorator(r,name,look,feel,flags,GetGfxDriver());
_decorator->SetDriver(GetGfxDriver());
#ifdef DEBUG_WINBORDER #ifdef DEBUG_WINBORDER
printf("WinBorder %s:\n",_title->String()); printf("WinBorder %s:\n",_title->String());
printf("\tFrame: (%.1f,%.1f,%.1f,%.1f)\n",r.left,r.top,r.right,r.bottom); printf("\tFrame: (%.1f,%.1f,%.1f,%.1f)\n",r.left,r.top,r.right,r.bottom);
@ -311,20 +313,6 @@ printf("WinBorder %s: MouseUp unimplmented\n",_title->String());
*/ */
} }
void WinBorder::Draw(BRect update_rect)
{
#ifdef DEBUG_WINBORDER
printf("WinBorder %s: Draw\n",_title->String());
#endif
if(_update && _visible!=NULL)
_is_updating=true;
_decorator->Draw(update_rect);
if(_update && _visible!=NULL)
_is_updating=false;
}
void WinBorder::RequestDraw(const BRect &r) void WinBorder::RequestDraw(const BRect &r)
{ {
#ifdef DEBUG_WINBORDER #ifdef DEBUG_WINBORDER
@ -335,18 +323,10 @@ printf("WinBorder %s: RequestDraw\n",_title->String());
void WinBorder::RequestDraw(void) void WinBorder::RequestDraw(void)
{ {
#ifdef DEBUG_WINBORDER
printf("WinBorder %s::RequestDraw\n",_title->String()); printf("WinBorder %s::RequestDraw\n",_title->String());
if(_invalid) #endif
{ _decorator->Draw();
//printf("drew something\n");
// for(int32 i=0; i<invalid->CountRects();i++)
// _decorator->Draw(ConvertToTop(invalid->RectAt(i)));
_decorator->Draw();
delete _invalid;
_invalid=NULL;
_is_dirty=false;
}
} }
void WinBorder::MoveBy(BPoint pt) void WinBorder::MoveBy(BPoint pt)

View File

@ -49,7 +49,6 @@ public:
void MouseDown(int8 *buffer); void MouseDown(int8 *buffer);
void MouseMoved(int8 *buffer); void MouseMoved(int8 *buffer);
void MouseUp(int8 *buffer); void MouseUp(int8 *buffer);
void Draw(BRect update);
void UpdateColors(void); void UpdateColors(void);
void UpdateDecorator(void); void UpdateDecorator(void);
void UpdateFont(void); void UpdateFont(void);