* You can now change the look of a window on the fly.

* renamed some Decorator functions like GetLook() to Look().
* renamed _look to fLook and _flags to fFlags.
* removed the feel from decorators - they don't need to know
  or care about the feel.
* the DefaultDecorator didn't allow resizing of modal windows.
* DefaultDecorator::SetTitle() no longer clears the passed
  in updateRegion, it just fills it (so that you can call
  more than one of these methods after the other, and still
  get a correct update region).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15266 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-12-01 14:56:01 +00:00
parent 57be286609
commit 85f8bb71c7
9 changed files with 205 additions and 183 deletions
+14 -15
View File
@@ -48,15 +48,16 @@ typedef enum {
class Decorator { class Decorator {
public: public:
Decorator(DesktopSettings& settings, BRect rect, Decorator(DesktopSettings& settings, BRect rect,
int32 look, int32 feel, int32 flags); window_look look, uint32 flags);
virtual ~Decorator(); virtual ~Decorator();
void SetColors(const ColorSet &cset); void SetColors(const ColorSet &cset);
void SetDriver(DrawingEngine *driver); void SetDriver(DrawingEngine *driver);
void SetFlags(int32 wflags);
void SetFeel(int32 wfeel);
void SetFont(ServerFont *font); void SetFont(ServerFont *font);
void SetLook(int32 wlook);
virtual void SetLook(DesktopSettings& settings,
window_look look, BRegion* updateRegion = NULL);
virtual void SetFlags(uint32 flags, BRegion* updateRegion = NULL);
void SetClose(bool pressed); void SetClose(bool pressed);
void SetMinimize(bool pressed); void SetMinimize(bool pressed);
@@ -64,17 +65,16 @@ class Decorator {
virtual void SetTitle(const char* string, BRegion* updateRegion = NULL); virtual void SetTitle(const char* string, BRegion* updateRegion = NULL);
int32 GetLook() const; window_look Look() const;
int32 GetFeel() const; uint32 Flags() const;
int32 GetFlags() const;
const char* GetTitle() const; const char* Title() const;
// we need to know its border(frame). WinBorder's _frame rect // we need to know its border(frame). WinBorder's _frame rect
// must expand to include Decorator borders. Otherwise we can't // must expand to include Decorator borders. Otherwise we can't
// draw the border. We also add GetTabRect because I feel we'll need it // draw the border. We also add TabRect because I feel we'll need it
BRect GetBorderRect() const; BRect BorderRect() const;
BRect GetTabRect() const; BRect TabRect() const;
bool GetClose(); bool GetClose();
bool GetMinimize(); bool GetMinimize();
@@ -140,9 +140,8 @@ class Decorator {
DrawingEngine* _driver; DrawingEngine* _driver;
DrawState fDrawState; DrawState fDrawState;
int32 _look; window_look fLook;
int32 _feel; uint32 fFlags;
int32 _flags;
BRect _zoomrect; BRect _zoomrect;
BRect _closerect; BRect _closerect;
@@ -165,6 +164,6 @@ class Decorator {
// add-on stuff // add-on stuff
typedef float get_version(void); typedef float get_version(void);
typedef Decorator* create_decorator(DesktopSettings& desktopSettings, BRect rect, typedef Decorator* create_decorator(DesktopSettings& desktopSettings, BRect rect,
int32 look, int32 feel, int32 flags); window_look look, uint32 flags);
#endif /* _DECORATOR_H_ */ #endif /* _DECORATOR_H_ */
+6 -6
View File
@@ -39,7 +39,7 @@ class DecorInfo {
const char* Name() const { return fName.String(); } const char* Name() const { return fName.String(); }
Decorator* Instantiate(Desktop* desktop, BRect rect, const char* title, Decorator* Instantiate(Desktop* desktop, BRect rect, const char* title,
int32 look, int32 feel, int32 flags); window_look look, uint32 flags);
private: private:
image_id fID; image_id fID;
@@ -73,16 +73,16 @@ DecorInfo::~DecorInfo()
Decorator * Decorator *
DecorInfo::Instantiate(Desktop* desktop, BRect rect, const char *title, DecorInfo::Instantiate(Desktop* desktop, BRect rect, const char *title,
int32 look, int32 feel, int32 flags) window_look look, uint32 flags)
{ {
DesktopSettings settings(desktop); DesktopSettings settings(desktop);
Decorator *decorator; Decorator *decorator;
try { try {
if (fAllocator != NULL) if (fAllocator != NULL)
decorator = fAllocator(settings, rect, look, feel, flags); decorator = fAllocator(settings, rect, look, flags);
else else
decorator = new DefaultDecorator(settings, rect, look, feel, flags); decorator = new DefaultDecorator(settings, rect, look, flags);
} catch (...) { } catch (...) {
return NULL; return NULL;
} }
@@ -192,7 +192,7 @@ DecorManager::RescanDecorators()
Decorator * Decorator *
DecorManager::AllocateDecorator(Desktop* desktop, BRect rect, const char *title, DecorManager::AllocateDecorator(Desktop* desktop, BRect rect, const char *title,
int32 look, int32 feel, int32 flags) window_look look, uint32 flags)
{ {
// Create a new instance of the current decorator. Ownership is that of the caller // Create a new instance of the current decorator. Ownership is that of the caller
@@ -202,7 +202,7 @@ DecorManager::AllocateDecorator(Desktop* desktop, BRect rect, const char *title,
return NULL; return NULL;
} }
return fCurrentDecor->Instantiate(desktop, rect, title, look, feel, flags); return fCurrentDecor->Instantiate(desktop, rect, title, look, flags);
} }
+2 -2
View File
@@ -27,8 +27,8 @@ class DecorManager : public BLocker {
void RescanDecorators(); void RescanDecorators();
Decorator* AllocateDecorator(Desktop* desktop, BRect rect, Decorator* AllocateDecorator(Desktop* desktop, BRect rect,
const char *title, int32 look, int32 feel, const char *title, window_look look,
int32 flags); uint32 flags);
int32 CountDecorators() const; int32 CountDecorators() const;
+48 -66
View File
@@ -28,32 +28,33 @@
Does general initialization of internal data members and creates a colorset Does general initialization of internal data members and creates a colorset
object. object.
*/ */
Decorator::Decorator(DesktopSettings& settings, BRect rect, int32 look, Decorator::Decorator(DesktopSettings& settings, BRect rect,
int32 feel, int32 flags) window_look look, uint32 flags)
: _colors(new ColorSet()), :
_driver(NULL), _colors(new ColorSet()),
fDrawState(), _driver(NULL),
fDrawState(),
_look(look), fLook(look),
_feel(feel), fFlags(flags),
_flags(flags),
_zoomrect(), _zoomrect(),
_closerect(), _closerect(),
_minimizerect(), _minimizerect(),
_tabrect(), _tabrect(),
_frame(rect), _frame(rect),
_resizerect(), _resizerect(),
_borderrect(), _borderrect(),
fClosePressed(false), fClosePressed(false),
fZoomPressed(false), fZoomPressed(false),
fMinimizePressed(false), fMinimizePressed(false),
fIsFocused(false), fIsFocused(false),
fTitle("") fTitle("")
{ {
} }
/*! /*!
\brief Destructor \brief Destructor
@@ -64,6 +65,7 @@ Decorator::~Decorator()
delete _colors; delete _colors;
} }
/*! /*!
\brief Updates the decorator's color set \brief Updates the decorator's color set
\param cset The color set to update from \param cset The color set to update from
@@ -75,6 +77,7 @@ Decorator::SetColors(const ColorSet &cset)
_SetColors(); _SetColors();
} }
/*! /*!
\brief Assigns a display driver to the decorator \brief Assigns a display driver to the decorator
\param driver A valid DrawingEngine object \param driver A valid DrawingEngine object
@@ -90,32 +93,21 @@ Decorator::SetDriver(DrawingEngine *driver)
} }
} }
/*!
\brief Sets the decorator's window flags
\param wflags New value for the flags
While this call will not update the screen, it will affect how future
updates work and immediately affects input handling.
*/
void
Decorator::SetFlags(int32 wflags)
{
_flags = wflags;
}
/*! /*!
\brief Sets the decorator's window feel \brief Sets the decorator's window flags
\param wflags New value for the feel \param flags New value for the flags
While this call will not update the screen, it will affect how future While this call will not update the screen, it will affect how future
updates work and immediately affects input handling. updates work and immediately affects input handling.
*/ */
void void
Decorator::SetFeel(int32 wfeel) Decorator::SetFlags(uint32 flags, BRegion* updateRegion)
{ {
_feel = wfeel; fFlags = flags;
} }
/* /*
\brief Sets the decorator's font \brief Sets the decorator's font
\param font The new font object to copy from \param font The new font object to copy from
@@ -123,25 +115,23 @@ Decorator::SetFeel(int32 wfeel)
void void
Decorator::SetFont(ServerFont *font) Decorator::SetFont(ServerFont *font)
{ {
if (font) { if (font)
fDrawState.SetFont(*font); fDrawState.SetFont(*font);
}
} }
/*! /*!
\brief Sets the decorator's window look \brief Sets the decorator's window look
\param wflags New value for the look \param look New value for the look
While this call will not update the screen, it will affect how future
updates work and immediately affects input handling.
*/ */
void void
Decorator::SetLook(int32 wlook) Decorator::SetLook(DesktopSettings& settings, window_look look,
BRegion* updateRect)
{ {
_look = wlook; fLook = look;
// TODO: relayout and redraw, no?
} }
/*! /*!
\brief Sets the close button's value. \brief Sets the close button's value.
\param is_down Whether the button is down or not \param is_down Whether the button is down or not
@@ -208,60 +198,52 @@ Decorator::SetTitle(const char* string, BRegion* updateRegion)
\brief Returns the decorator's window look \brief Returns the decorator's window look
\return the decorator's window look \return the decorator's window look
*/ */
int32 window_look
Decorator::GetLook() const Decorator::Look() const
{ {
return _look; return fLook;
} }
/*!
\brief Returns the decorator's window feel
\return the decorator's window feel
*/
int32
Decorator::GetFeel() const
{
return _feel;
}
/*! /*!
\brief Returns the decorator's window flags \brief Returns the decorator's window flags
\return the decorator's window flags \return the decorator's window flags
*/ */
int32 uint32
Decorator::GetFlags() const Decorator::Flags() const
{ {
return _flags; return fFlags;
} }
/*! /*!
\brief Returns the decorator's title \brief Returns the decorator's title
\return the decorator's title \return the decorator's title
*/ */
const char* const char*
Decorator::GetTitle() const Decorator::Title() const
{ {
return fTitle.String(); return fTitle.String();
} }
/*! /*!
\brief Returns the decorator's border rectangle \brief Returns the decorator's border rectangle
\return the decorator's border rectangle \return the decorator's border rectangle
*/ */
BRect BRect
Decorator::GetBorderRect() const Decorator::BorderRect() const
{ {
return _borderrect; return _borderrect;
} }
/*! /*!
\brief Returns the decorator's tab rectangle \brief Returns the decorator's tab rectangle
\return the decorator's tab rectangle \return the decorator's tab rectangle
*/ */
BRect BRect
Decorator::GetTabRect() const Decorator::TabRect() const
{ {
return _tabrect; return _tabrect;
} }
+85 -87
View File
@@ -36,19 +36,15 @@
#endif #endif
DefaultDecorator::DefaultDecorator(DesktopSettings& settings, BRect rect, // TODO: get rid of DesktopSettings here, and introduce private accessor
int32 look, int32 feel, int32 flags) // methods to the Decorator base class
: Decorator(settings, rect, look, feel, flags)
{
ServerFont font;
if (_look == B_FLOATING_WINDOW_LOOK)
settings.GetDefaultPlainFont(font);
else
settings.GetDefaultBoldFont(font);
font.SetFlags(B_FORCE_ANTIALIASING);
font.SetSpacing(B_STRING_SPACING); DefaultDecorator::DefaultDecorator(DesktopSettings& settings, BRect rect,
SetFont(&font); window_look look, uint32 flags)
: Decorator(settings, rect, look, flags)
{
DefaultDecorator::SetLook(settings, look);
fFrameColors = new RGBColor[6]; fFrameColors = new RGBColor[6];
fFrameColors[0].SetColor(152, 152, 152); fFrameColors[0].SetColor(152, 152, 152);
@@ -57,7 +53,7 @@ DefaultDecorator::DefaultDecorator(DesktopSettings& settings, BRect rect,
fFrameColors[3].SetColor(136, 136, 136); fFrameColors[3].SetColor(136, 136, 136);
fFrameColors[4].SetColor(152, 152, 152); fFrameColors[4].SetColor(152, 152, 152);
fFrameColors[5].SetColor(96, 96, 96); fFrameColors[5].SetColor(96, 96, 96);
// Set appropriate colors based on the current focus value. In this case, each decorator // Set appropriate colors based on the current focus value. In this case, each decorator
// defaults to not having the focus. // defaults to not having the focus.
_SetFocus(); _SetFocus();
@@ -83,14 +79,14 @@ DefaultDecorator::~DefaultDecorator()
void void
DefaultDecorator::SetTitle(const char* string, BRegion* updateRegion) DefaultDecorator::SetTitle(const char* string, BRegion* updateRegion)
{ {
BRect rect = GetTabRect(); BRect rect = TabRect();
Decorator::SetTitle(string); Decorator::SetTitle(string);
if (updateRegion == NULL) if (updateRegion == NULL)
return; return;
BRect updatedRect = GetTabRect(); BRect updatedRect = TabRect();
if (rect.left > updatedRect.left) if (rect.left > updatedRect.left)
rect.left = updatedRect.left; rect.left = updatedRect.left;
if (rect.right < updatedRect.right) if (rect.right < updatedRect.right)
@@ -99,14 +95,54 @@ DefaultDecorator::SetTitle(const char* string, BRegion* updateRegion)
rect.bottom++; rect.bottom++;
// the border will look differently when the title is adjacent // the border will look differently when the title is adjacent
updateRegion->Set(rect); updateRegion->Include(rect);
}
void
DefaultDecorator::SetLook(DesktopSettings& settings,
window_look look, BRegion* updateRegion)
{
// TODO: we could be much smarter about the update region
// get previous extent
if (updateRegion != NULL) {
BRegion extent;
GetFootprint(&extent);
updateRegion->Include(&extent);
}
ServerFont font;
if (look == B_FLOATING_WINDOW_LOOK)
settings.GetDefaultPlainFont(font);
else
settings.GetDefaultBoldFont(font);
font.SetFlags(B_FORCE_ANTIALIASING);
font.SetSpacing(B_STRING_SPACING);
SetFont(&font);
Decorator::SetLook(settings, look, updateRegion);
_DoLayout();
if (updateRegion != NULL) {
BRegion extent;
GetFootprint(&extent);
updateRegion->Include(&extent);
}
}
void
DefaultDecorator::SetFlags(uint32 flags, BRegion* updateRegion)
{
} }
void void
DefaultDecorator::MoveBy(float x, float y) DefaultDecorator::MoveBy(float x, float y)
{ {
MoveBy(BPoint(x,y)); MoveBy(BPoint(x, y));
} }
@@ -219,7 +255,7 @@ DefaultDecorator::GetFootprint(BRegion *region)
region->MakeEmpty(); region->MakeEmpty();
if (_look == B_NO_BORDER_WINDOW_LOOK) if (fLook == B_NO_BORDER_WINDOW_LOOK)
return; return;
region->Include(fLeftBorder); region->Include(fLeftBorder);
@@ -227,78 +263,37 @@ DefaultDecorator::GetFootprint(BRegion *region)
region->Include(fTopBorder); region->Include(fTopBorder);
region->Include(fBottomBorder); region->Include(fBottomBorder);
if (_look == B_BORDERED_WINDOW_LOOK) if (fLook == B_BORDERED_WINDOW_LOOK)
return; return;
region->Include(_tabrect); region->Include(_tabrect);
if (_look == B_DOCUMENT_WINDOW_LOOK) { if (fLook == B_DOCUMENT_WINDOW_LOOK) {
// include the rectangular resize knob on the bottom right // include the rectangular resize knob on the bottom right
region->Include(BRect(_frame.right - 13.0f, _frame.bottom - 13.0f, region->Include(BRect(_frame.right - 13.0f, _frame.bottom - 13.0f,
_frame.right, _frame.bottom)); _frame.right, _frame.bottom));
} }
} }
click_type click_type
DefaultDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers) DefaultDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
{ {
#ifdef DEBUG_DECORATOR #ifdef DEBUG_DECORATOR
printf("DefaultDecorator: Clicked\n"); printf("DefaultDecorator: Clicked\n");
printf("\tPoint: (%.1f,%.1f)\n",pt.x,pt.y); printf("\tPoint: (%.1f,%.1f)\n", pt.x,pt.y);
printf("\tButtons:\n"); printf("\tButtons: %ld, Modifiers: 0x%lx\n", buttons, modifiers);
if (buttons == 0) {
printf("\t\tNone\n");
} else {
if(buttons & B_PRIMARY_MOUSE_BUTTON)
printf("\t\tPrimary\n");
if(buttons & B_SECONDARY_MOUSE_BUTTON)
printf("\t\tSecondary\n");
if(buttons & B_TERTIARY_MOUSE_BUTTON)
printf("\t\tTertiary\n");
}
printf("\tModifiers:\n");
if (modifiers == 0) {
printf("\t\tNone\n");
} else {
if(modifiers & B_CAPS_LOCK)
printf("\t\tCaps Lock\n");
if(modifiers & B_NUM_LOCK)
printf("\t\tNum Lock\n");
if(modifiers & B_SCROLL_LOCK)
printf("\t\tScroll Lock\n");
if(modifiers & B_LEFT_COMMAND_KEY)
printf("\t\t Left Command\n");
if(modifiers & B_RIGHT_COMMAND_KEY)
printf("\t\t Right Command\n");
if(modifiers & B_LEFT_CONTROL_KEY)
printf("\t\tLeft Control\n");
if(modifiers & B_RIGHT_CONTROL_KEY)
printf("\t\tRight Control\n");
if(modifiers & B_LEFT_OPTION_KEY)
printf("\t\tLeft Option\n");
if(modifiers & B_RIGHT_OPTION_KEY)
printf("\t\tRight Option\n");
if(modifiers & B_LEFT_SHIFT_KEY)
printf("\t\tLeft Shift\n");
if(modifiers & B_RIGHT_SHIFT_KEY)
printf("\t\tRight Shift\n");
if(modifiers & B_MENU_KEY)
printf("\t\tMenu\n");
}
#endif // DEBUG_DECORATOR #endif // DEBUG_DECORATOR
// In checking for hit test stuff, we start with the smallest rectangles the user might // In checking for hit test stuff, we start with the smallest rectangles the user might
// be clicking on and gradually work our way out into larger rectangles. // be clicking on and gradually work our way out into larger rectangles.
if (!(_flags & B_NOT_CLOSABLE) && _closerect.Contains(pt)) if (!(fFlags & B_NOT_CLOSABLE) && _closerect.Contains(pt))
return DEC_CLOSE; return DEC_CLOSE;
if (!(_flags & B_NOT_ZOOMABLE) && _zoomrect.Contains(pt)) if (!(fFlags & B_NOT_ZOOMABLE) && _zoomrect.Contains(pt))
return DEC_ZOOM; return DEC_ZOOM;
if (_look == B_DOCUMENT_WINDOW_LOOK && _resizerect.Contains(pt)) if (fLook == B_DOCUMENT_WINDOW_LOOK && _resizerect.Contains(pt))
return DEC_RESIZE; return DEC_RESIZE;
// Clicking in the tab? // Clicking in the tab?
@@ -316,14 +311,16 @@ DefaultDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
if (fLeftBorder.Contains(pt) || fRightBorder.Contains(pt) if (fLeftBorder.Contains(pt) || fRightBorder.Contains(pt)
|| fTopBorder.Contains(pt) || fBottomBorder.Contains(pt)) { || fTopBorder.Contains(pt) || fBottomBorder.Contains(pt)) {
// check resize area // check resize area
if (!(_flags & B_NOT_RESIZABLE) && if (!(fFlags & B_NOT_RESIZABLE)
(_look == B_TITLED_WINDOW_LOOK || _look == B_FLOATING_WINDOW_LOOK)) { && (fLook == B_TITLED_WINDOW_LOOK
|| fLook == B_FLOATING_WINDOW_LOOK
|| fLook == B_MODAL_WINDOW_LOOK)) {
BRect temp(BPoint(fBottomBorder.right - 18, fBottomBorder.bottom - 18), BRect temp(BPoint(fBottomBorder.right - 18, fBottomBorder.bottom - 18),
fBottomBorder.RightBottom()); fBottomBorder.RightBottom());
if (temp.Contains(pt)) if (temp.Contains(pt))
return DEC_RESIZE; return DEC_RESIZE;
} }
// NOTE: On R5, windows are not moved to back if clicked inside the resize area with // NOTE: On R5, windows are not moved to back if clicked inside the resize area with
// the second mouse button. So we check this after the check above // the second mouse button. So we check this after the check above
if (buttons == B_SECONDARY_MOUSE_BUTTON) if (buttons == B_SECONDARY_MOUSE_BUTTON)
@@ -336,6 +333,7 @@ DefaultDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
return DEC_NONE; return DEC_NONE;
} }
void void
DefaultDecorator::_DoLayout() DefaultDecorator::_DoLayout()
{ {
@@ -345,7 +343,7 @@ DefaultDecorator::_DoLayout()
bool hasTab = false; bool hasTab = false;
switch (GetLook()) { switch (Look()) {
case B_MODAL_WINDOW_LOOK: case B_MODAL_WINDOW_LOOK:
fBorderWidth = 5; fBorderWidth = 5;
break; break;
@@ -374,7 +372,7 @@ DefaultDecorator::_DoLayout()
fTabOffset = 0; fTabOffset = 0;
// distance from one item of the tab bar to another. // distance from one item of the tab bar to another.
// In this case the text and close/zoom rects // In this case the text and close/zoom rects
fTextOffset = (_look == B_FLOATING_WINDOW_LOOK) ? 10 : 18; fTextOffset = (fLook == B_FLOATING_WINDOW_LOOK) ? 10 : 18;
font_height fontHeight; font_height fontHeight;
fDrawState.Font().GetHeight(fontHeight); fDrawState.Font().GetHeight(fontHeight);
@@ -387,7 +385,7 @@ DefaultDecorator::_DoLayout()
_frame.top - fBorderWidth); _frame.top - fBorderWidth);
// format tab rect for a floating window - make the rect smaller // format tab rect for a floating window - make the rect smaller
if (_look == B_FLOATING_WINDOW_LOOK) { if (fLook == B_FLOATING_WINDOW_LOOK) {
_tabrect.InsetBy(0, 2); _tabrect.InsetBy(0, 2);
_tabrect.OffsetBy(0, 2); _tabrect.OffsetBy(0, 2);
} }
@@ -398,13 +396,13 @@ DefaultDecorator::_DoLayout()
// fMinTabWidth contains just the room for the buttons // fMinTabWidth contains just the room for the buttons
fMinTabWidth = 4.0 + fTextOffset; fMinTabWidth = 4.0 + fTextOffset;
if (!(_flags & B_NOT_CLOSABLE)) if (!(fFlags & B_NOT_CLOSABLE))
fMinTabWidth += offset + size; fMinTabWidth += offset + size;
if (!(_flags & B_NOT_ZOOMABLE)) if (!(fFlags & B_NOT_ZOOMABLE))
fMinTabWidth += offset + size; fMinTabWidth += offset + size;
// fMaxTabWidth contains fMinWidth + the width required for the title // fMaxTabWidth contains fMinWidth + the width required for the title
fMaxTabWidth = _driver ? _driver->StringWidth(GetTitle(), strlen(GetTitle()), fMaxTabWidth = _driver ? _driver->StringWidth(Title(), strlen(Title()),
&fDrawState) : 0.0; &fDrawState) : 0.0;
if (fMaxTabWidth > 0.0) if (fMaxTabWidth > 0.0)
fMaxTabWidth += fTextOffset; fMaxTabWidth += fTextOffset;
@@ -466,7 +464,7 @@ STRACE(("_DrawFrame(%f,%f,%f,%f)\n", invalid.left, invalid.top,
_driver->FillRect(_frame, fDrawState.HighColor()); _driver->FillRect(_frame, fDrawState.HighColor());
#endif #endif
if (_look == B_NO_BORDER_WINDOW_LOOK) if (fLook == B_NO_BORDER_WINDOW_LOOK)
return; return;
if (fBorderWidth <= 0) if (fBorderWidth <= 0)
@@ -474,7 +472,7 @@ STRACE(("_DrawFrame(%f,%f,%f,%f)\n", invalid.left, invalid.top,
// Draw the border frame // Draw the border frame
BRect r = BRect(fTopBorder.LeftTop(), fBottomBorder.RightBottom()); BRect r = BRect(fTopBorder.LeftTop(), fBottomBorder.RightBottom());
switch (_look) { switch (fLook) {
case B_TITLED_WINDOW_LOOK: case B_TITLED_WINDOW_LOOK:
case B_DOCUMENT_WINDOW_LOOK: case B_DOCUMENT_WINDOW_LOOK:
case B_MODAL_WINDOW_LOOK: { case B_MODAL_WINDOW_LOOK: {
@@ -543,11 +541,11 @@ STRACE(("_DrawFrame(%f,%f,%f,%f)\n", invalid.left, invalid.top,
} }
// Draw the resize thumb if we're supposed to // Draw the resize thumb if we're supposed to
if (!(_flags & B_NOT_RESIZABLE)) { if (!(fFlags & B_NOT_RESIZABLE)) {
r = _resizerect; r = _resizerect;
switch (_look){ switch (fLook){
case B_DOCUMENT_WINDOW_LOOK: { case B_DOCUMENT_WINDOW_LOOK: {
// Explicitly locking the driver is normally unnecessary. However, we need to do // Explicitly locking the driver is normally unnecessary. However, we need to do
@@ -637,9 +635,9 @@ DefaultDecorator::_DrawTab(BRect r)
_DrawTitle(_tabrect); _DrawTitle(_tabrect);
// Draw the buttons if we're supposed to // Draw the buttons if we're supposed to
if (!(_flags & B_NOT_CLOSABLE)) if (!(fFlags & B_NOT_CLOSABLE))
_DrawClose(_closerect); _DrawClose(_closerect);
if (!(_flags & B_NOT_ZOOMABLE)) if (!(fFlags & B_NOT_ZOOMABLE))
_DrawZoom(_zoomrect); _DrawZoom(_zoomrect);
} }
@@ -774,7 +772,7 @@ DefaultDecorator::_DrawBlendedRect(BRect r, bool down)
void void
DefaultDecorator::_GetButtonSizeAndOffset(const BRect& tabRect, float* offset, float* size) const DefaultDecorator::_GetButtonSizeAndOffset(const BRect& tabRect, float* offset, float* size) const
{ {
*offset = _look == B_FLOATING_WINDOW_LOOK ? 4.0 : 5.0; *offset = fLook == B_FLOATING_WINDOW_LOOK ? 4.0 : 5.0;
// "+ 2" so that the rects are centered within the solid area // "+ 2" so that the rects are centered within the solid area
// (without the 2 pixels for the top border) // (without the 2 pixels for the top border)
*size = tabRect.Height() - 2.0 * *offset + 2.0; *size = tabRect.Height() - 2.0 * *offset + 2.0;
@@ -789,7 +787,7 @@ DefaultDecorator::_LayoutTabItems(const BRect& tabRect)
_GetButtonSizeAndOffset(tabRect, &offset, &size); _GetButtonSizeAndOffset(tabRect, &offset, &size);
// calulate close rect based on the tab rectangle // calulate close rect based on the tab rectangle
if (GetFlags() & B_NOT_CLOSABLE) { if (Flags() & B_NOT_CLOSABLE) {
_closerect.Set(tabRect.left + offset, tabRect.top + offset, _closerect.Set(tabRect.left + offset, tabRect.top + offset,
tabRect.left + offset, tabRect.top + offset + size); tabRect.left + offset, tabRect.top + offset + size);
} else { } else {
@@ -798,7 +796,7 @@ DefaultDecorator::_LayoutTabItems(const BRect& tabRect)
} }
// calulate zoom rect based on the tab rectangle // calulate zoom rect based on the tab rectangle
if (GetFlags() & B_NOT_ZOOMABLE) { if (Flags() & B_NOT_ZOOMABLE) {
_zoomrect.Set(tabRect.right, tabRect.top + offset, _zoomrect.Set(tabRect.right, tabRect.top + offset,
tabRect.right, tabRect.top + offset + size); tabRect.right, tabRect.top + offset + size);
} else { } else {
@@ -811,7 +809,7 @@ DefaultDecorator::_LayoutTabItems(const BRect& tabRect)
// truncated for no apparent reason - OTOH the title does // truncated for no apparent reason - OTOH the title does
// also not appear perfectly in the middle // also not appear perfectly in the middle
float width = (_zoomrect.left - _closerect.right) - fTextOffset * 2 + 2; float width = (_zoomrect.left - _closerect.right) - fTextOffset * 2 + 2;
fTruncatedTitle = GetTitle(); fTruncatedTitle = Title();
fDrawState.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_END, width); fDrawState.Font().TruncateString(&fTruncatedTitle, B_TRUNCATE_END, width);
fTruncatedTitleLength = fTruncatedTitle.Length(); fTruncatedTitleLength = fTruncatedTitle.Length();
} }
+4 -1
View File
@@ -19,10 +19,13 @@ class Desktop;
class DefaultDecorator: public Decorator { class DefaultDecorator: public Decorator {
public: public:
DefaultDecorator(DesktopSettings& settings, BRect frame, DefaultDecorator(DesktopSettings& settings, BRect frame,
int32 look, int32 feel, int32 flags); window_look look, uint32 flags);
virtual ~DefaultDecorator(); virtual ~DefaultDecorator();
virtual void SetTitle(const char* string, BRegion* updateRegion = NULL); virtual void SetTitle(const char* string, BRegion* updateRegion = NULL);
virtual void SetLook(DesktopSettings& settings,
window_look look, BRegion* updateRegion = NULL);
virtual void SetFlags(uint32 flags, BRegion* updateRegion = NULL);
virtual void MoveBy(float x, float y); virtual void MoveBy(float x, float y);
virtual void MoveBy(BPoint pt); virtual void MoveBy(BPoint pt);
+19
View File
@@ -563,11 +563,19 @@ RootLayer::ResizeWindowBy(WindowLayer* window, float x, float y)
void void
RootLayer::SetWindowLook(WindowLayer *window, window_look newLook) RootLayer::SetWindowLook(WindowLayer *window, window_look newLook)
{ {
if (window->Look() == newLook)
return;
BAutolock _(fAllRegionsLock); BAutolock _(fAllRegionsLock);
BRegion changed; BRegion changed;
window->SetLook(newLook, window->Parent() ? &changed : NULL); window->SetLook(newLook, window->Parent() ? &changed : NULL);
if (window->Parent() != NULL) {
MarkForRebuild(changed);
TriggerRebuild();
}
_WindowsChanged(changed); _WindowsChanged(changed);
if (changed.CountRects() > 0) { if (changed.CountRects() > 0) {
@@ -580,6 +588,9 @@ RootLayer::SetWindowLook(WindowLayer *window, window_look newLook)
void void
RootLayer::SetWindowFeel(WindowLayer *window, window_feel newFeel) RootLayer::SetWindowFeel(WindowLayer *window, window_feel newFeel)
{ {
if (window->Feel() == newFeel)
return;
BAutolock _(fAllRegionsLock); BAutolock _(fAllRegionsLock);
window->SetFeel(newFeel); window->SetFeel(newFeel);
@@ -591,11 +602,19 @@ RootLayer::SetWindowFeel(WindowLayer *window, window_feel newFeel)
void void
RootLayer::SetWindowFlags(WindowLayer *window, uint32 newFlags) RootLayer::SetWindowFlags(WindowLayer *window, uint32 newFlags)
{ {
if (window->WindowFlags() == newFlags)
return;
BAutolock _(fAllRegionsLock); BAutolock _(fAllRegionsLock);
BRegion changed; BRegion changed;
window->SetWindowFlags(newFlags, window->Parent() ? &changed : NULL); window->SetWindowFlags(newFlags, window->Parent() ? &changed : NULL);
if (window->Parent() != NULL) {
MarkForRebuild(changed);
TriggerRebuild();
}
_WindowsChanged(changed); _WindowsChanged(changed);
if (changed.CountRects() > 0) { if (changed.CountRects() > 0) {
+26 -5
View File
@@ -95,8 +95,8 @@ WindowLayer::WindowLayer(const BRect &frame,
fFlags = B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE; fFlags = B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE;
if (fLook != B_NO_BORDER_WINDOW_LOOK) { if (fLook != B_NO_BORDER_WINDOW_LOOK) {
fDecorator = gDecorManager.AllocateDecorator(window->App()->GetDesktop(), frame, fDecorator = gDecorManager.AllocateDecorator(window->Desktop(), frame,
name, fLook, fFeel, fWindowFlags); name, fLook, fWindowFlags);
if (fDecorator) if (fDecorator)
fDecorator->GetSizeLimits(&fMinWidth, &fMinHeight, &fMaxWidth, &fMaxHeight); fDecorator->GetSizeLimits(&fMinWidth, &fMinHeight, &fMaxWidth, &fMaxHeight);
} }
@@ -110,8 +110,8 @@ WindowLayer::WindowLayer(const BRect &frame,
uint16 width, height; uint16 width, height;
uint32 colorSpace; uint32 colorSpace;
float frequency; float frequency;
if (window->App()->GetDesktop()->ScreenAt(0)) { if (window->Desktop()->ScreenAt(0)) {
window->App()->GetDesktop()->ScreenAt(0)->GetMode(width, height, colorSpace, frequency); window->Desktop()->ScreenAt(0)->GetMode(width, height, colorSpace, frequency);
// TODO: MOVE THIS AWAY!!! RemoveBy contains calls to virtual methods! Also, there is not TopLayer()! // TODO: MOVE THIS AWAY!!! RemoveBy contains calls to virtual methods! Also, there is not TopLayer()!
fFrame.OffsetTo(B_ORIGIN); fFrame.OffsetTo(B_ORIGIN);
WindowLayer::ResizeBy(width - frame.Width(), height - frame.Height()); WindowLayer::ResizeBy(width - frame.Width(), height - frame.Height());
@@ -669,7 +669,28 @@ WindowLayer::SupportsFront()
void void
WindowLayer::SetLook(window_look look, BRegion* updateRegion) WindowLayer::SetLook(window_look look, BRegion* updateRegion)
{ {
// TODO: implement settings window look if (fDecorator == NULL && look != B_NO_BORDER_WINDOW_LOOK) {
// we need a new decorator
fDecorator = gDecorManager.AllocateDecorator(Window()->Desktop(), Frame(),
Name(), fLook, fWindowFlags);
}
fLook = look;
fRebuildDecRegion = true;
if (fDecorator != NULL) {
DesktopSettings settings(Window()->Desktop());
fDecorator->SetLook(settings, look, updateRegion);
// TODO: we might need to resize the window!
//fDecorator->GetSizeLimits(&fMinWidth, &fMinHeight, &fMaxWidth, &fMaxHeight);
}
if (look == B_NO_BORDER_WINDOW_LOOK) {
// we don't need a decorator for this window
delete fDecorator;
fDecorator = NULL;
}
} }
+1 -1
View File
@@ -108,7 +108,7 @@ WorkspacesLayer::_DrawWindow(const BRect& workspaceFrame,
BPoint offset = window->Frame().LeftTop() - windowPosition; BPoint offset = window->Frame().LeftTop() - windowPosition;
BRect frame = _WindowFrame(workspaceFrame, screenFrame, window->Frame(), BRect frame = _WindowFrame(workspaceFrame, screenFrame, window->Frame(),
windowPosition); windowPosition);
BRect tabFrame = window->GetDecorator()->GetTabRect(); BRect tabFrame = window->GetDecorator()->TabRect();
tabFrame = _WindowFrame(workspaceFrame, screenFrame, tabFrame = _WindowFrame(workspaceFrame, screenFrame,
tabFrame, tabFrame.LeftTop() - offset); tabFrame, tabFrame.LeftTop() - offset);