Fix another TODO and move the caching of the decorator footprint region (the border region) form the Window class into the decorator base class. To do so I make some of the public Decorator methods non virtual and introduce new protected virtual methods instead. The non virtual public methods handle the caching now and calling the protected method afterwards.
This has to be taken into account when fixing the other Decorators! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37529 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+113
-17
@@ -49,7 +49,9 @@ Decorator::Decorator(DesktopSettings& settings, BRect rect, window_look look,
|
|||||||
fZoomPressed(false),
|
fZoomPressed(false),
|
||||||
fMinimizePressed(false),
|
fMinimizePressed(false),
|
||||||
fIsFocused(false),
|
fIsFocused(false),
|
||||||
fTitle("")
|
fTitle(""),
|
||||||
|
|
||||||
|
fFootprintValid(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,6 +99,10 @@ Decorator::SetFlags(uint32 flags, BRegion* updateRegion)
|
|||||||
flags |= B_NOT_H_RESIZABLE | B_NOT_V_RESIZABLE;
|
flags |= B_NOT_H_RESIZABLE | B_NOT_V_RESIZABLE;
|
||||||
|
|
||||||
fFlags = flags;
|
fFlags = flags;
|
||||||
|
|
||||||
|
fFootprintValid = false;
|
||||||
|
// the border might have changed (smaller/larger tab)
|
||||||
|
_SetFlags(flags, updateRegion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -105,6 +111,8 @@ Decorator::SetFlags(uint32 flags, BRegion* updateRegion)
|
|||||||
void
|
void
|
||||||
Decorator::FontsChanged(DesktopSettings& settings, BRegion* updateRegion)
|
Decorator::FontsChanged(DesktopSettings& settings, BRegion* updateRegion)
|
||||||
{
|
{
|
||||||
|
fFootprintValid = false;
|
||||||
|
_FontsChanged(settings, updateRegion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -116,6 +124,10 @@ Decorator::SetLook(DesktopSettings& settings, window_look look,
|
|||||||
BRegion* updateRect)
|
BRegion* updateRect)
|
||||||
{
|
{
|
||||||
fLook = look;
|
fLook = look;
|
||||||
|
|
||||||
|
fFootprintValid = false;
|
||||||
|
// the border very likely changed
|
||||||
|
_SetLook(settings, look, updateRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -176,6 +188,12 @@ Decorator::SetTitle(const char* string, BRegion* updateRegion)
|
|||||||
{
|
{
|
||||||
fTitle.SetTo(string);
|
fTitle.SetTo(string);
|
||||||
_DoLayout();
|
_DoLayout();
|
||||||
|
|
||||||
|
fFootprintValid = false;
|
||||||
|
// the border very likely changed
|
||||||
|
|
||||||
|
_SetTitle(string, updateRegion);
|
||||||
|
|
||||||
// TODO: redraw?
|
// TODO: redraw?
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,16 +304,16 @@ Decorator::SetFocus(bool active)
|
|||||||
// #pragma mark - virtual methods
|
// #pragma mark - virtual methods
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Returns the "footprint" of the entire window, including decorator
|
/*! \brief Returns a cached footprint if available otherwise recalculate it
|
||||||
|
|
||||||
This function is required by all subclasses.
|
|
||||||
|
|
||||||
\param region Region to be changed to represent the window's screen
|
|
||||||
footprint
|
|
||||||
*/
|
*/
|
||||||
void
|
const BRegion&
|
||||||
Decorator::GetFootprint(BRegion *region)
|
Decorator::GetFootprint()
|
||||||
{
|
{
|
||||||
|
if (!fFootprintValid) {
|
||||||
|
_GetFootprint(&fFootprint);
|
||||||
|
fFootprintValid = true;
|
||||||
|
}
|
||||||
|
return fFootprint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -366,14 +384,10 @@ Decorator::MoveBy(float x, float y)
|
|||||||
void
|
void
|
||||||
Decorator::MoveBy(BPoint offset)
|
Decorator::MoveBy(BPoint offset)
|
||||||
{
|
{
|
||||||
fZoomRect.OffsetBy(offset);
|
if (fFootprintValid)
|
||||||
fCloseRect.OffsetBy(offset);
|
fFootprint.OffsetBy(offset.x, offset.y);
|
||||||
fMinimizeRect.OffsetBy(offset);
|
|
||||||
fMinimizeRect.OffsetBy(offset);
|
_MoveBy(offset);
|
||||||
fTabRect.OffsetBy(offset);
|
|
||||||
fFrame.OffsetBy(offset);
|
|
||||||
fResizeRect.OffsetBy(offset);
|
|
||||||
fBorderRect.OffsetBy(offset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -394,9 +408,32 @@ Decorator::ResizeBy(float x, float y, BRegion* dirty)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Decorator::ResizeBy(BPoint offset, BRegion* dirty)
|
||||||
|
{
|
||||||
|
fFootprintValid = false;
|
||||||
|
_ResizeBy(offset, dirty);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
Decorator::SetTabLocation(float location, BRegion* updateRegion)
|
||||||
|
{
|
||||||
|
if (_SetTabLocation(location, updateRegion)) {
|
||||||
|
fFootprintValid = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Decorator::SetSettings(const BMessage& settings, BRegion* updateRegion)
|
Decorator::SetSettings(const BMessage& settings, BRegion* updateRegion)
|
||||||
{
|
{
|
||||||
|
if (_SetSettings(settings, updateRegion)) {
|
||||||
|
fFootprintValid = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,3 +617,62 @@ void
|
|||||||
Decorator::_SetFocus()
|
Decorator::_SetFocus()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Decorator::_FontsChanged(DesktopSettings& settings, BRegion* updateRegion)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Decorator::_SetLook(DesktopSettings& settings, window_look look,
|
||||||
|
BRegion* updateRect)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Decorator::_SetFlags(uint32 flags, BRegion* updateRegion)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Decorator::_SetTitle(const char* string, BRegion* updateRegion)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Decorator::_MoveBy(BPoint offset)
|
||||||
|
{
|
||||||
|
fZoomRect.OffsetBy(offset);
|
||||||
|
fCloseRect.OffsetBy(offset);
|
||||||
|
fMinimizeRect.OffsetBy(offset);
|
||||||
|
fMinimizeRect.OffsetBy(offset);
|
||||||
|
fTabRect.OffsetBy(offset);
|
||||||
|
fFrame.OffsetBy(offset);
|
||||||
|
fResizeRect.OffsetBy(offset);
|
||||||
|
fBorderRect.OffsetBy(offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
Decorator::_SetSettings(const BMessage& settings, BRegion* updateRegion)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! \brief Returns the "footprint" of the entire window, including decorator
|
||||||
|
|
||||||
|
This function is required by all subclasses.
|
||||||
|
|
||||||
|
\param region Region to be changed to represent the window's screen
|
||||||
|
footprint
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Decorator::_GetFootprint(BRegion *region)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|||||||
+34
-11
@@ -54,18 +54,18 @@ public:
|
|||||||
inline DrawingEngine* GetDrawingEngine() const
|
inline DrawingEngine* GetDrawingEngine() const
|
||||||
{ return fDrawingEngine; }
|
{ return fDrawingEngine; }
|
||||||
|
|
||||||
virtual void FontsChanged(DesktopSettings& settings,
|
void FontsChanged(DesktopSettings& settings,
|
||||||
BRegion* updateRegion = NULL);
|
BRegion* updateRegion = NULL);
|
||||||
virtual void SetLook(DesktopSettings& settings, window_look look,
|
void SetLook(DesktopSettings& settings, window_look look,
|
||||||
BRegion* updateRegion = NULL);
|
BRegion* updateRegion = NULL);
|
||||||
virtual void SetFlags(uint32 flags,
|
void SetFlags(uint32 flags,
|
||||||
BRegion* updateRegion = NULL);
|
BRegion* updateRegion = NULL);
|
||||||
|
|
||||||
void SetClose(bool pressed);
|
void SetClose(bool pressed);
|
||||||
void SetMinimize(bool pressed);
|
void SetMinimize(bool pressed);
|
||||||
void SetZoom(bool pressed);
|
void SetZoom(bool pressed);
|
||||||
|
|
||||||
virtual void SetTitle(const char* string,
|
void SetTitle(const char* string,
|
||||||
BRegion* updateRegion = NULL);
|
BRegion* updateRegion = NULL);
|
||||||
|
|
||||||
window_look Look() const;
|
window_look Look() const;
|
||||||
@@ -87,26 +87,25 @@ public:
|
|||||||
bool IsFocus()
|
bool IsFocus()
|
||||||
{ return fIsFocused; };
|
{ return fIsFocused; };
|
||||||
|
|
||||||
virtual void GetFootprint(BRegion *region);
|
const BRegion& GetFootprint();
|
||||||
|
|
||||||
virtual click_type Clicked(BPoint where, int32 buttons,
|
virtual click_type Clicked(BPoint where, int32 buttons,
|
||||||
int32 modifiers);
|
int32 modifiers);
|
||||||
|
|
||||||
void MoveBy(float x, float y);
|
void MoveBy(float x, float y);
|
||||||
virtual void MoveBy(BPoint offset);
|
void MoveBy(BPoint offset);
|
||||||
void ResizeBy(float x, float y, BRegion* dirty);
|
void ResizeBy(float x, float y, BRegion* dirty);
|
||||||
virtual void ResizeBy(BPoint offset, BRegion* dirty) = 0;
|
void ResizeBy(BPoint offset, BRegion* dirty);
|
||||||
|
|
||||||
/*! \return true if tab location updated, false if out of bounds
|
/*! \return true if tab location updated, false if out of bounds
|
||||||
or unsupported
|
or unsupported
|
||||||
*/
|
*/
|
||||||
virtual bool SetTabLocation(float location,
|
bool SetTabLocation(float location,
|
||||||
BRegion* /*updateRegion*/ = NULL)
|
BRegion* /*updateRegion*/ = NULL);
|
||||||
{ return false; }
|
|
||||||
virtual float TabLocation() const
|
virtual float TabLocation() const
|
||||||
{ return 0.0; }
|
{ return 0.0; }
|
||||||
|
|
||||||
virtual bool SetSettings(const BMessage& settings,
|
bool SetSettings(const BMessage& settings,
|
||||||
BRegion* updateRegion = NULL);
|
BRegion* updateRegion = NULL);
|
||||||
virtual bool GetSettings(BMessage* settings) const;
|
virtual bool GetSettings(BMessage* settings) const;
|
||||||
|
|
||||||
@@ -135,7 +134,28 @@ protected:
|
|||||||
virtual void _DrawZoom(BRect rect);
|
virtual void _DrawZoom(BRect rect);
|
||||||
virtual void _DrawMinimize(BRect rect);
|
virtual void _DrawMinimize(BRect rect);
|
||||||
|
|
||||||
|
virtual void _FontsChanged(DesktopSettings& settings,
|
||||||
|
BRegion* updateRegion = NULL);
|
||||||
|
virtual void _SetLook(DesktopSettings& settings,
|
||||||
|
window_look look, BRegion* updateRegion = NULL);
|
||||||
|
virtual void _SetFlags(uint32 flags,
|
||||||
|
BRegion* updateRegion = NULL);
|
||||||
|
|
||||||
|
virtual void _SetTitle(const char* string,
|
||||||
|
BRegion* updateRegion = NULL);
|
||||||
|
|
||||||
virtual void _SetFocus();
|
virtual void _SetFocus();
|
||||||
|
virtual void _MoveBy(BPoint offset);
|
||||||
|
virtual void _ResizeBy(BPoint offset, BRegion* dirty) = 0;
|
||||||
|
|
||||||
|
virtual bool _SetTabLocation(float location,
|
||||||
|
BRegion* /*updateRegion*/ = NULL)
|
||||||
|
{ return false; }
|
||||||
|
|
||||||
|
virtual bool _SetSettings(const BMessage& settings,
|
||||||
|
BRegion* updateRegion = NULL);
|
||||||
|
|
||||||
|
virtual void _GetFootprint(BRegion *region);
|
||||||
|
|
||||||
DrawingEngine* fDrawingEngine;
|
DrawingEngine* fDrawingEngine;
|
||||||
DrawState fDrawState;
|
DrawState fDrawState;
|
||||||
@@ -159,6 +179,9 @@ private:
|
|||||||
bool fIsFocused : 1;
|
bool fIsFocused : 1;
|
||||||
|
|
||||||
BString fTitle;
|
BString fTitle;
|
||||||
|
|
||||||
|
BRegion fFootprint;
|
||||||
|
bool fFootprintValid : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DECORATOR_H
|
#endif // DECORATOR_H
|
||||||
|
|||||||
@@ -144,291 +144,6 @@ DefaultDecorator::SetTitle(const char* string, BRegion* updateRegion)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
DefaultDecorator::FontsChanged(DesktopSettings& settings, BRegion* updateRegion)
|
|
||||||
{
|
|
||||||
// get previous extent
|
|
||||||
if (updateRegion != NULL) {
|
|
||||||
BRegion extent;
|
|
||||||
GetFootprint(&extent);
|
|
||||||
updateRegion->Include(&extent);
|
|
||||||
}
|
|
||||||
|
|
||||||
_UpdateFont(settings);
|
|
||||||
_InvalidateBitmaps();
|
|
||||||
_DoLayout();
|
|
||||||
|
|
||||||
if (updateRegion != NULL) {
|
|
||||||
BRegion extent;
|
|
||||||
GetFootprint(&extent);
|
|
||||||
updateRegion->Include(&extent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
fLook = look;
|
|
||||||
|
|
||||||
_UpdateFont(settings);
|
|
||||||
_InvalidateBitmaps();
|
|
||||||
_DoLayout();
|
|
||||||
|
|
||||||
if (updateRegion != NULL) {
|
|
||||||
BRegion extent;
|
|
||||||
GetFootprint(&extent);
|
|
||||||
updateRegion->Include(&extent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
DefaultDecorator::SetFlags(uint32 flags, 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
Decorator::SetFlags(flags, updateRegion);
|
|
||||||
_DoLayout();
|
|
||||||
|
|
||||||
if (updateRegion != NULL) {
|
|
||||||
BRegion extent;
|
|
||||||
GetFootprint(&extent);
|
|
||||||
updateRegion->Include(&extent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
DefaultDecorator::MoveBy(BPoint offset)
|
|
||||||
{
|
|
||||||
STRACE(("DefaultDecorator: Move By (%.1f, %.1f)\n", offset.x, offset.y));
|
|
||||||
// Move all internal rectangles the appropriate amount
|
|
||||||
fFrame.OffsetBy(offset);
|
|
||||||
fCloseRect.OffsetBy(offset);
|
|
||||||
fTabRect.OffsetBy(offset);
|
|
||||||
fResizeRect.OffsetBy(offset);
|
|
||||||
fZoomRect.OffsetBy(offset);
|
|
||||||
fBorderRect.OffsetBy(offset);
|
|
||||||
|
|
||||||
fLeftBorder.OffsetBy(offset);
|
|
||||||
fRightBorder.OffsetBy(offset);
|
|
||||||
fTopBorder.OffsetBy(offset);
|
|
||||||
fBottomBorder.OffsetBy(offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
DefaultDecorator::ResizeBy(BPoint offset, BRegion* dirty)
|
|
||||||
{
|
|
||||||
STRACE(("DefaultDecorator: Resize By (%.1f, %.1f)\n", offset.x, offset.y));
|
|
||||||
// Move all internal rectangles the appropriate amount
|
|
||||||
fFrame.right += offset.x;
|
|
||||||
fFrame.bottom += offset.y;
|
|
||||||
|
|
||||||
// Handle invalidation of resize rect
|
|
||||||
if (dirty && !(fFlags & B_NOT_RESIZABLE)) {
|
|
||||||
BRect realResizeRect;
|
|
||||||
switch (fLook) {
|
|
||||||
case B_DOCUMENT_WINDOW_LOOK:
|
|
||||||
realResizeRect = fResizeRect;
|
|
||||||
// Resize rect at old location
|
|
||||||
dirty->Include(realResizeRect);
|
|
||||||
realResizeRect.OffsetBy(offset);
|
|
||||||
// Resize rect at new location
|
|
||||||
dirty->Include(realResizeRect);
|
|
||||||
break;
|
|
||||||
case B_TITLED_WINDOW_LOOK:
|
|
||||||
case B_FLOATING_WINDOW_LOOK:
|
|
||||||
case B_MODAL_WINDOW_LOOK:
|
|
||||||
case kLeftTitledWindowLook:
|
|
||||||
// The bottom border resize line
|
|
||||||
realResizeRect.Set(fRightBorder.right - kBorderResizeLength, fBottomBorder.top,
|
|
||||||
fRightBorder.right - kBorderResizeLength, fBottomBorder.bottom - 1);
|
|
||||||
// Old location
|
|
||||||
dirty->Include(realResizeRect);
|
|
||||||
realResizeRect.OffsetBy(offset);
|
|
||||||
// New location
|
|
||||||
dirty->Include(realResizeRect);
|
|
||||||
|
|
||||||
// The right border resize line
|
|
||||||
realResizeRect.Set(fRightBorder.left, fBottomBorder.bottom - kBorderResizeLength,
|
|
||||||
fRightBorder.right - 1, fBottomBorder.bottom - kBorderResizeLength);
|
|
||||||
// Old location
|
|
||||||
dirty->Include(realResizeRect);
|
|
||||||
realResizeRect.OffsetBy(offset);
|
|
||||||
// New location
|
|
||||||
dirty->Include(realResizeRect);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fResizeRect.OffsetBy(offset);
|
|
||||||
|
|
||||||
fBorderRect.right += offset.x;
|
|
||||||
fBorderRect.bottom += offset.y;
|
|
||||||
|
|
||||||
fLeftBorder.bottom += offset.y;
|
|
||||||
fTopBorder.right += offset.x;
|
|
||||||
|
|
||||||
fRightBorder.OffsetBy(offset.x, 0.0);
|
|
||||||
fRightBorder.bottom += offset.y;
|
|
||||||
|
|
||||||
fBottomBorder.OffsetBy(0.0, offset.y);
|
|
||||||
fBottomBorder.right += offset.x;
|
|
||||||
|
|
||||||
if (dirty) {
|
|
||||||
if (offset.x > 0.0) {
|
|
||||||
BRect t(fRightBorder.left - offset.x, fTopBorder.top,
|
|
||||||
fRightBorder.right, fTopBorder.bottom);
|
|
||||||
dirty->Include(t);
|
|
||||||
t.Set(fRightBorder.left - offset.x, fBottomBorder.top,
|
|
||||||
fRightBorder.right, fBottomBorder.bottom);
|
|
||||||
dirty->Include(t);
|
|
||||||
dirty->Include(fRightBorder);
|
|
||||||
} else if (offset.x < 0.0) {
|
|
||||||
dirty->Include(BRect(fRightBorder.left, fTopBorder.top,
|
|
||||||
fRightBorder.right, fBottomBorder.bottom));
|
|
||||||
}
|
|
||||||
if (offset.y > 0.0) {
|
|
||||||
BRect t(fLeftBorder.left, fLeftBorder.bottom - offset.y,
|
|
||||||
fLeftBorder.right, fLeftBorder.bottom);
|
|
||||||
dirty->Include(t);
|
|
||||||
t.Set(fRightBorder.left, fRightBorder.bottom - offset.y,
|
|
||||||
fRightBorder.right, fRightBorder.bottom);
|
|
||||||
dirty->Include(t);
|
|
||||||
dirty->Include(fBottomBorder);
|
|
||||||
} else if (offset.y < 0.0) {
|
|
||||||
dirty->Include(fBottomBorder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// resize tab and layout tab items
|
|
||||||
if (fTabRect.IsValid()) {
|
|
||||||
BRect oldTabRect(fTabRect);
|
|
||||||
|
|
||||||
float tabSize;
|
|
||||||
float maxLocation;
|
|
||||||
if (fLook != kLeftTitledWindowLook) {
|
|
||||||
tabSize = fRightBorder.right - fLeftBorder.left;
|
|
||||||
} else {
|
|
||||||
tabSize = fBottomBorder.bottom - fTopBorder.top;
|
|
||||||
}
|
|
||||||
maxLocation = tabSize - fMaxTabSize;
|
|
||||||
if (maxLocation < 0)
|
|
||||||
maxLocation = 0;
|
|
||||||
|
|
||||||
float tabOffset = floorf(fTabLocation * maxLocation);
|
|
||||||
float delta = tabOffset - fTabOffset;
|
|
||||||
fTabOffset = (uint32)tabOffset;
|
|
||||||
if (fLook != kLeftTitledWindowLook)
|
|
||||||
fTabRect.OffsetBy(delta, 0.0);
|
|
||||||
else
|
|
||||||
fTabRect.OffsetBy(0.0, delta);
|
|
||||||
|
|
||||||
if (tabSize < fMinTabSize)
|
|
||||||
tabSize = fMinTabSize;
|
|
||||||
if (tabSize > fMaxTabSize)
|
|
||||||
tabSize = fMaxTabSize;
|
|
||||||
|
|
||||||
if (fLook != kLeftTitledWindowLook && tabSize != fTabRect.Width()) {
|
|
||||||
fTabRect.right = fTabRect.left + tabSize;
|
|
||||||
} else if (fLook == kLeftTitledWindowLook
|
|
||||||
&& tabSize != fTabRect.Height()) {
|
|
||||||
fTabRect.bottom = fTabRect.top + tabSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oldTabRect != fTabRect) {
|
|
||||||
_LayoutTabItems(fTabRect);
|
|
||||||
|
|
||||||
if (dirty) {
|
|
||||||
// NOTE: the tab rect becoming smaller only would
|
|
||||||
// handled be the Desktop anyways, so it is sufficient
|
|
||||||
// to include it into the dirty region in it's
|
|
||||||
// final state
|
|
||||||
BRect redraw(fTabRect);
|
|
||||||
if (delta != 0.0) {
|
|
||||||
redraw = redraw | oldTabRect;
|
|
||||||
if (fLook != kLeftTitledWindowLook)
|
|
||||||
redraw.bottom++;
|
|
||||||
else
|
|
||||||
redraw.right++;
|
|
||||||
}
|
|
||||||
dirty->Include(redraw);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
DefaultDecorator::SetTabLocation(float location, BRegion* updateRegion)
|
|
||||||
{
|
|
||||||
STRACE(("DefaultDecorator: Set Tab Location(%.1f)\n", location));
|
|
||||||
if (!fTabRect.IsValid())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (location < 0)
|
|
||||||
location = 0;
|
|
||||||
|
|
||||||
float maxLocation
|
|
||||||
= fRightBorder.right - fLeftBorder.left - fTabRect.Width();
|
|
||||||
if (location > maxLocation)
|
|
||||||
location = maxLocation;
|
|
||||||
|
|
||||||
float delta = location - fTabOffset;
|
|
||||||
if (delta == 0.0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// redraw old rect (1 pix on the border also must be updated)
|
|
||||||
BRect trect(fTabRect);
|
|
||||||
trect.bottom++;
|
|
||||||
updateRegion->Include(trect);
|
|
||||||
|
|
||||||
fTabRect.OffsetBy(delta, 0);
|
|
||||||
fTabOffset = (int32)location;
|
|
||||||
_LayoutTabItems(fTabRect);
|
|
||||||
|
|
||||||
fTabLocation = maxLocation > 0.0 ? fTabOffset / maxLocation : 0.0;
|
|
||||||
|
|
||||||
// redraw new rect as well
|
|
||||||
trect = fTabRect;
|
|
||||||
trect.bottom++;
|
|
||||||
updateRegion->Include(trect);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
DefaultDecorator::SetSettings(const BMessage& settings, BRegion* updateRegion)
|
|
||||||
{
|
|
||||||
float tabLocation;
|
|
||||||
if (settings.FindFloat("tab location", &tabLocation) == B_OK)
|
|
||||||
return SetTabLocation(tabLocation, updateRegion);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
DefaultDecorator::GetSettings(BMessage* settings) const
|
DefaultDecorator::GetSettings(BMessage* settings) const
|
||||||
{
|
{
|
||||||
@@ -490,40 +205,6 @@ DefaultDecorator::GetSizeLimits(int32* minWidth, int32* minHeight,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
DefaultDecorator::GetFootprint(BRegion* region)
|
|
||||||
{
|
|
||||||
STRACE(("DefaultDecorator: Get Footprint\n"));
|
|
||||||
// This function calculates the decorator's footprint in coordinates
|
|
||||||
// relative to the view. This is most often used to set a Window
|
|
||||||
// object's visible region.
|
|
||||||
if (!region)
|
|
||||||
return;
|
|
||||||
|
|
||||||
region->MakeEmpty();
|
|
||||||
|
|
||||||
if (fLook == B_NO_BORDER_WINDOW_LOOK)
|
|
||||||
return;
|
|
||||||
|
|
||||||
region->Include(fTopBorder);
|
|
||||||
region->Include(fLeftBorder);
|
|
||||||
region->Include(fRightBorder);
|
|
||||||
region->Include(fBottomBorder);
|
|
||||||
|
|
||||||
if (fLook == B_BORDERED_WINDOW_LOOK)
|
|
||||||
return;
|
|
||||||
|
|
||||||
region->Include(fTabRect);
|
|
||||||
|
|
||||||
if (fLook == B_DOCUMENT_WINDOW_LOOK) {
|
|
||||||
// include the rectangular resize knob on the bottom right
|
|
||||||
float knobSize = kResizeKnobSize - fBorderWidth;
|
|
||||||
region->Include(BRect(fFrame.right - knobSize, fFrame.bottom - knobSize,
|
|
||||||
fFrame.right, fFrame.bottom));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
click_type
|
click_type
|
||||||
DefaultDecorator::Clicked(BPoint point, int32 buttons, int32 modifiers)
|
DefaultDecorator::Clicked(BPoint point, int32 buttons, int32 modifiers)
|
||||||
{
|
{
|
||||||
@@ -1085,6 +766,58 @@ DefaultDecorator::_DrawZoom(BRect rect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DefaultDecorator::_FontsChanged(DesktopSettings& settings,
|
||||||
|
BRegion* updateRegion)
|
||||||
|
{
|
||||||
|
// get previous extent
|
||||||
|
if (updateRegion != NULL)
|
||||||
|
updateRegion->Include(&GetFootprint());
|
||||||
|
|
||||||
|
_UpdateFont(settings);
|
||||||
|
_InvalidateBitmaps();
|
||||||
|
_DoLayout();
|
||||||
|
|
||||||
|
if (updateRegion != NULL)
|
||||||
|
updateRegion->Include(&GetFootprint());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
||||||
|
updateRegion->Include(&GetFootprint());
|
||||||
|
|
||||||
|
_UpdateFont(settings);
|
||||||
|
_InvalidateBitmaps();
|
||||||
|
_DoLayout();
|
||||||
|
|
||||||
|
if (updateRegion != NULL)
|
||||||
|
updateRegion->Include(&GetFootprint());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DefaultDecorator::_SetFlags(uint32 flags, BRegion* updateRegion)
|
||||||
|
{
|
||||||
|
// TODO: we could be much smarter about the update region
|
||||||
|
|
||||||
|
// get previous extent
|
||||||
|
if (updateRegion != NULL)
|
||||||
|
updateRegion->Include(&GetFootprint());
|
||||||
|
|
||||||
|
_DoLayout();
|
||||||
|
|
||||||
|
if (updateRegion != NULL)
|
||||||
|
updateRegion->Include(&GetFootprint());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DefaultDecorator::_SetFocus()
|
DefaultDecorator::_SetFocus()
|
||||||
{
|
{
|
||||||
@@ -1122,6 +855,253 @@ DefaultDecorator::_SetColors()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DefaultDecorator::_MoveBy(BPoint offset)
|
||||||
|
{
|
||||||
|
STRACE(("DefaultDecorator: Move By (%.1f, %.1f)\n", offset.x, offset.y));
|
||||||
|
// Move all internal rectangles the appropriate amount
|
||||||
|
fFrame.OffsetBy(offset);
|
||||||
|
fCloseRect.OffsetBy(offset);
|
||||||
|
fTabRect.OffsetBy(offset);
|
||||||
|
fResizeRect.OffsetBy(offset);
|
||||||
|
fZoomRect.OffsetBy(offset);
|
||||||
|
fBorderRect.OffsetBy(offset);
|
||||||
|
|
||||||
|
fLeftBorder.OffsetBy(offset);
|
||||||
|
fRightBorder.OffsetBy(offset);
|
||||||
|
fTopBorder.OffsetBy(offset);
|
||||||
|
fBottomBorder.OffsetBy(offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DefaultDecorator::_ResizeBy(BPoint offset, BRegion* dirty)
|
||||||
|
{
|
||||||
|
STRACE(("DefaultDecorator: Resize By (%.1f, %.1f)\n", offset.x, offset.y));
|
||||||
|
// Move all internal rectangles the appropriate amount
|
||||||
|
fFrame.right += offset.x;
|
||||||
|
fFrame.bottom += offset.y;
|
||||||
|
|
||||||
|
// Handle invalidation of resize rect
|
||||||
|
if (dirty && !(fFlags & B_NOT_RESIZABLE)) {
|
||||||
|
BRect realResizeRect;
|
||||||
|
switch (fLook) {
|
||||||
|
case B_DOCUMENT_WINDOW_LOOK:
|
||||||
|
realResizeRect = fResizeRect;
|
||||||
|
// Resize rect at old location
|
||||||
|
dirty->Include(realResizeRect);
|
||||||
|
realResizeRect.OffsetBy(offset);
|
||||||
|
// Resize rect at new location
|
||||||
|
dirty->Include(realResizeRect);
|
||||||
|
break;
|
||||||
|
case B_TITLED_WINDOW_LOOK:
|
||||||
|
case B_FLOATING_WINDOW_LOOK:
|
||||||
|
case B_MODAL_WINDOW_LOOK:
|
||||||
|
case kLeftTitledWindowLook:
|
||||||
|
// The bottom border resize line
|
||||||
|
realResizeRect.Set(fRightBorder.right - kBorderResizeLength, fBottomBorder.top,
|
||||||
|
fRightBorder.right - kBorderResizeLength, fBottomBorder.bottom - 1);
|
||||||
|
// Old location
|
||||||
|
dirty->Include(realResizeRect);
|
||||||
|
realResizeRect.OffsetBy(offset);
|
||||||
|
// New location
|
||||||
|
dirty->Include(realResizeRect);
|
||||||
|
|
||||||
|
// The right border resize line
|
||||||
|
realResizeRect.Set(fRightBorder.left, fBottomBorder.bottom - kBorderResizeLength,
|
||||||
|
fRightBorder.right - 1, fBottomBorder.bottom - kBorderResizeLength);
|
||||||
|
// Old location
|
||||||
|
dirty->Include(realResizeRect);
|
||||||
|
realResizeRect.OffsetBy(offset);
|
||||||
|
// New location
|
||||||
|
dirty->Include(realResizeRect);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fResizeRect.OffsetBy(offset);
|
||||||
|
|
||||||
|
fBorderRect.right += offset.x;
|
||||||
|
fBorderRect.bottom += offset.y;
|
||||||
|
|
||||||
|
fLeftBorder.bottom += offset.y;
|
||||||
|
fTopBorder.right += offset.x;
|
||||||
|
|
||||||
|
fRightBorder.OffsetBy(offset.x, 0.0);
|
||||||
|
fRightBorder.bottom += offset.y;
|
||||||
|
|
||||||
|
fBottomBorder.OffsetBy(0.0, offset.y);
|
||||||
|
fBottomBorder.right += offset.x;
|
||||||
|
|
||||||
|
if (dirty) {
|
||||||
|
if (offset.x > 0.0) {
|
||||||
|
BRect t(fRightBorder.left - offset.x, fTopBorder.top,
|
||||||
|
fRightBorder.right, fTopBorder.bottom);
|
||||||
|
dirty->Include(t);
|
||||||
|
t.Set(fRightBorder.left - offset.x, fBottomBorder.top,
|
||||||
|
fRightBorder.right, fBottomBorder.bottom);
|
||||||
|
dirty->Include(t);
|
||||||
|
dirty->Include(fRightBorder);
|
||||||
|
} else if (offset.x < 0.0) {
|
||||||
|
dirty->Include(BRect(fRightBorder.left, fTopBorder.top,
|
||||||
|
fRightBorder.right, fBottomBorder.bottom));
|
||||||
|
}
|
||||||
|
if (offset.y > 0.0) {
|
||||||
|
BRect t(fLeftBorder.left, fLeftBorder.bottom - offset.y,
|
||||||
|
fLeftBorder.right, fLeftBorder.bottom);
|
||||||
|
dirty->Include(t);
|
||||||
|
t.Set(fRightBorder.left, fRightBorder.bottom - offset.y,
|
||||||
|
fRightBorder.right, fRightBorder.bottom);
|
||||||
|
dirty->Include(t);
|
||||||
|
dirty->Include(fBottomBorder);
|
||||||
|
} else if (offset.y < 0.0) {
|
||||||
|
dirty->Include(fBottomBorder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// resize tab and layout tab items
|
||||||
|
if (fTabRect.IsValid()) {
|
||||||
|
BRect oldTabRect(fTabRect);
|
||||||
|
|
||||||
|
float tabSize;
|
||||||
|
float maxLocation;
|
||||||
|
if (fLook != kLeftTitledWindowLook) {
|
||||||
|
tabSize = fRightBorder.right - fLeftBorder.left;
|
||||||
|
} else {
|
||||||
|
tabSize = fBottomBorder.bottom - fTopBorder.top;
|
||||||
|
}
|
||||||
|
maxLocation = tabSize - fMaxTabSize;
|
||||||
|
if (maxLocation < 0)
|
||||||
|
maxLocation = 0;
|
||||||
|
|
||||||
|
float tabOffset = floorf(fTabLocation * maxLocation);
|
||||||
|
float delta = tabOffset - fTabOffset;
|
||||||
|
fTabOffset = (uint32)tabOffset;
|
||||||
|
if (fLook != kLeftTitledWindowLook)
|
||||||
|
fTabRect.OffsetBy(delta, 0.0);
|
||||||
|
else
|
||||||
|
fTabRect.OffsetBy(0.0, delta);
|
||||||
|
|
||||||
|
if (tabSize < fMinTabSize)
|
||||||
|
tabSize = fMinTabSize;
|
||||||
|
if (tabSize > fMaxTabSize)
|
||||||
|
tabSize = fMaxTabSize;
|
||||||
|
|
||||||
|
if (fLook != kLeftTitledWindowLook && tabSize != fTabRect.Width()) {
|
||||||
|
fTabRect.right = fTabRect.left + tabSize;
|
||||||
|
} else if (fLook == kLeftTitledWindowLook
|
||||||
|
&& tabSize != fTabRect.Height()) {
|
||||||
|
fTabRect.bottom = fTabRect.top + tabSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oldTabRect != fTabRect) {
|
||||||
|
_LayoutTabItems(fTabRect);
|
||||||
|
|
||||||
|
if (dirty) {
|
||||||
|
// NOTE: the tab rect becoming smaller only would
|
||||||
|
// handled be the Desktop anyways, so it is sufficient
|
||||||
|
// to include it into the dirty region in it's
|
||||||
|
// final state
|
||||||
|
BRect redraw(fTabRect);
|
||||||
|
if (delta != 0.0) {
|
||||||
|
redraw = redraw | oldTabRect;
|
||||||
|
if (fLook != kLeftTitledWindowLook)
|
||||||
|
redraw.bottom++;
|
||||||
|
else
|
||||||
|
redraw.right++;
|
||||||
|
}
|
||||||
|
dirty->Include(redraw);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
DefaultDecorator::_SetTabLocation(float location, BRegion* updateRegion)
|
||||||
|
{
|
||||||
|
STRACE(("DefaultDecorator: Set Tab Location(%.1f)\n", location));
|
||||||
|
if (!fTabRect.IsValid())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (location < 0)
|
||||||
|
location = 0;
|
||||||
|
|
||||||
|
float maxLocation
|
||||||
|
= fRightBorder.right - fLeftBorder.left - fTabRect.Width();
|
||||||
|
if (location > maxLocation)
|
||||||
|
location = maxLocation;
|
||||||
|
|
||||||
|
float delta = location - fTabOffset;
|
||||||
|
if (delta == 0.0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// redraw old rect (1 pix on the border also must be updated)
|
||||||
|
BRect trect(fTabRect);
|
||||||
|
trect.bottom++;
|
||||||
|
updateRegion->Include(trect);
|
||||||
|
|
||||||
|
fTabRect.OffsetBy(delta, 0);
|
||||||
|
fTabOffset = (int32)location;
|
||||||
|
_LayoutTabItems(fTabRect);
|
||||||
|
|
||||||
|
fTabLocation = maxLocation > 0.0 ? fTabOffset / maxLocation : 0.0;
|
||||||
|
|
||||||
|
// redraw new rect as well
|
||||||
|
trect = fTabRect;
|
||||||
|
trect.bottom++;
|
||||||
|
updateRegion->Include(trect);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
DefaultDecorator::_SetSettings(const BMessage& settings, BRegion* updateRegion)
|
||||||
|
{
|
||||||
|
float tabLocation;
|
||||||
|
if (settings.FindFloat("tab location", &tabLocation) == B_OK)
|
||||||
|
return SetTabLocation(tabLocation, updateRegion);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DefaultDecorator::_GetFootprint(BRegion *region)
|
||||||
|
{
|
||||||
|
STRACE(("DefaultDecorator: Get Footprint\n"));
|
||||||
|
// This function calculates the decorator's footprint in coordinates
|
||||||
|
// relative to the view. This is most often used to set a Window
|
||||||
|
// object's visible region.
|
||||||
|
if (!region)
|
||||||
|
return;
|
||||||
|
|
||||||
|
region->MakeEmpty();
|
||||||
|
|
||||||
|
if (fLook == B_NO_BORDER_WINDOW_LOOK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
region->Include(fTopBorder);
|
||||||
|
region->Include(fLeftBorder);
|
||||||
|
region->Include(fRightBorder);
|
||||||
|
region->Include(fBottomBorder);
|
||||||
|
|
||||||
|
if (fLook == B_BORDERED_WINDOW_LOOK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
region->Include(fTabRect);
|
||||||
|
|
||||||
|
if (fLook == B_DOCUMENT_WINDOW_LOOK) {
|
||||||
|
// include the rectangular resize knob on the bottom right
|
||||||
|
float knobSize = kResizeKnobSize - fBorderWidth;
|
||||||
|
region->Include(BRect(fFrame.right - knobSize, fFrame.bottom - knobSize,
|
||||||
|
fFrame.right, fFrame.bottom));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DefaultDecorator::_UpdateFont(DesktopSettings& settings)
|
DefaultDecorator::_UpdateFont(DesktopSettings& settings)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,24 +27,10 @@ public:
|
|||||||
|
|
||||||
virtual void SetTitle(const char* string,
|
virtual void SetTitle(const char* string,
|
||||||
BRegion* updateRegion = NULL);
|
BRegion* updateRegion = NULL);
|
||||||
virtual void FontsChanged(DesktopSettings& settings,
|
|
||||||
BRegion* updateRegion);
|
|
||||||
virtual void SetLook(DesktopSettings& settings,
|
|
||||||
window_look look,
|
|
||||||
BRegion* updateRegion = NULL);
|
|
||||||
virtual void SetFlags(uint32 flags,
|
|
||||||
BRegion* updateRegion = NULL);
|
|
||||||
|
|
||||||
virtual void MoveBy(BPoint offset);
|
|
||||||
virtual void ResizeBy(BPoint offset, BRegion* dirty);
|
|
||||||
|
|
||||||
virtual bool SetTabLocation(float location,
|
|
||||||
BRegion* updateRegion = NULL);
|
|
||||||
virtual float TabLocation() const
|
virtual float TabLocation() const
|
||||||
{ return (float)fTabOffset; }
|
{ return (float)fTabOffset; }
|
||||||
|
|
||||||
virtual bool SetSettings(const BMessage& settings,
|
|
||||||
BRegion* updateRegion = NULL);
|
|
||||||
virtual bool GetSettings(BMessage* settings) const;
|
virtual bool GetSettings(BMessage* settings) const;
|
||||||
|
|
||||||
virtual void Draw(BRect updateRect);
|
virtual void Draw(BRect updateRect);
|
||||||
@@ -53,8 +39,6 @@ public:
|
|||||||
virtual void GetSizeLimits(int32* minWidth, int32* minHeight,
|
virtual void GetSizeLimits(int32* minWidth, int32* minHeight,
|
||||||
int32* maxWidth, int32* maxHeight) const;
|
int32* maxWidth, int32* maxHeight) const;
|
||||||
|
|
||||||
virtual void GetFootprint(BRegion* region);
|
|
||||||
|
|
||||||
virtual click_type Clicked(BPoint pt, int32 buttons,
|
virtual click_type Clicked(BPoint pt, int32 buttons,
|
||||||
int32 modifiers);
|
int32 modifiers);
|
||||||
|
|
||||||
@@ -68,9 +52,28 @@ protected:
|
|||||||
virtual void _DrawTitle(BRect r);
|
virtual void _DrawTitle(BRect r);
|
||||||
virtual void _DrawZoom(BRect r);
|
virtual void _DrawZoom(BRect r);
|
||||||
|
|
||||||
|
virtual void _FontsChanged(DesktopSettings& settings,
|
||||||
|
BRegion* updateRegion);
|
||||||
|
virtual void _SetLook(DesktopSettings& settings,
|
||||||
|
window_look look,
|
||||||
|
BRegion* updateRegion = NULL);
|
||||||
|
virtual void _SetFlags(uint32 flags,
|
||||||
|
BRegion* updateRegion = NULL);
|
||||||
|
|
||||||
virtual void _SetFocus();
|
virtual void _SetFocus();
|
||||||
virtual void _SetColors();
|
virtual void _SetColors();
|
||||||
|
|
||||||
|
virtual void _MoveBy(BPoint offset);
|
||||||
|
virtual void _ResizeBy(BPoint offset, BRegion* dirty);
|
||||||
|
|
||||||
|
virtual bool _SetTabLocation(float location,
|
||||||
|
BRegion* updateRegion = NULL);
|
||||||
|
|
||||||
|
virtual bool _SetSettings(const BMessage& settings,
|
||||||
|
BRegion* updateRegion = NULL);
|
||||||
|
|
||||||
|
virtual void _GetFootprint(BRegion *region);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _UpdateFont(DesktopSettings& settings);
|
void _UpdateFont(DesktopSettings& settings);
|
||||||
void _DrawButtonBitmap(ServerBitmap* bitmap,
|
void _DrawButtonBitmap(ServerBitmap* bitmap,
|
||||||
|
|||||||
@@ -48,7 +48,9 @@ bool
|
|||||||
DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where)
|
DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where)
|
||||||
{
|
{
|
||||||
int32 modifiers = _ExtractModifiers(message);
|
int32 modifiers = _ExtractModifiers(message);
|
||||||
bool inBorderRegion = fWindow->BorderRegion().Contains(where);
|
bool inBorderRegion = false;
|
||||||
|
if (fWindow->Decorator())
|
||||||
|
inBorderRegion = fWindow->Decorator()->GetFootprint().Contains(where);
|
||||||
bool windowModifier =
|
bool windowModifier =
|
||||||
(fWindow->Flags() & B_NO_SERVER_SIDE_WINDOW_MODIFIERS) == 0
|
(fWindow->Flags() & B_NO_SERVER_SIDE_WINDOW_MODIFIERS) == 0
|
||||||
&& (modifiers & (B_COMMAND_KEY | B_CONTROL_KEY | B_OPTION_KEY
|
&& (modifiers & (B_COMMAND_KEY | B_CONTROL_KEY | B_OPTION_KEY
|
||||||
@@ -457,9 +459,7 @@ DefaultWindowBehaviour::_AlterDeltaForSnap(BPoint& delta, bigtime_t now)
|
|||||||
BRect screenFrame = fWindow->Screen()->Frame();
|
BRect screenFrame = fWindow->Screen()->Frame();
|
||||||
|
|
||||||
if (fDecorator) {
|
if (fDecorator) {
|
||||||
BRegion reg;
|
frame = fDecorator->GetFootprint().Frame();
|
||||||
fDecorator->GetFootprint(®);
|
|
||||||
frame = reg.Frame();
|
|
||||||
offsetWithinFrame.x = fWindow->Frame().left - frame.left;
|
offsetWithinFrame.x = fWindow->Frame().left - frame.left;
|
||||||
offsetWithinFrame.y = fWindow->Frame().top - frame.top;
|
offsetWithinFrame.y = fWindow->Frame().top - frame.top;
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-49
@@ -79,12 +79,10 @@ Window::Window(const BRect& frame, const char *name,
|
|||||||
fDirtyRegion(),
|
fDirtyRegion(),
|
||||||
fDirtyCause(0),
|
fDirtyCause(0),
|
||||||
|
|
||||||
fBorderRegion(),
|
|
||||||
fContentRegion(),
|
fContentRegion(),
|
||||||
fEffectiveDrawingRegion(),
|
fEffectiveDrawingRegion(),
|
||||||
|
|
||||||
fVisibleContentRegionValid(false),
|
fVisibleContentRegionValid(false),
|
||||||
fBorderRegionValid(false),
|
|
||||||
fContentRegionValid(false),
|
fContentRegionValid(false),
|
||||||
fEffectiveDrawingRegionValid(false),
|
fEffectiveDrawingRegionValid(false),
|
||||||
|
|
||||||
@@ -221,16 +219,10 @@ Window::GetBorderRegion(BRegion* region)
|
|||||||
// TODO: if someone needs to call this from
|
// TODO: if someone needs to call this from
|
||||||
// the outside, the clipping needs to be readlocked!
|
// the outside, the clipping needs to be readlocked!
|
||||||
|
|
||||||
if (!fBorderRegionValid) {
|
|
||||||
if (fDecorator)
|
if (fDecorator)
|
||||||
fDecorator->GetFootprint(&fBorderRegion);
|
*region = fDecorator->GetFootprint();
|
||||||
else
|
else
|
||||||
fBorderRegion.MakeEmpty();
|
region->MakeEmpty();
|
||||||
|
|
||||||
fBorderRegionValid = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
*region = fBorderRegion;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -293,8 +285,6 @@ Window::MoveBy(int32 x, int32 y)
|
|||||||
// processed yet
|
// processed yet
|
||||||
fDirtyRegion.OffsetBy(x, y);
|
fDirtyRegion.OffsetBy(x, y);
|
||||||
|
|
||||||
if (fBorderRegionValid)
|
|
||||||
fBorderRegion.OffsetBy(x, y);
|
|
||||||
if (fContentRegionValid)
|
if (fContentRegionValid)
|
||||||
fContentRegion.OffsetBy(x, y);
|
fContentRegion.OffsetBy(x, y);
|
||||||
|
|
||||||
@@ -351,7 +341,6 @@ Window::ResizeBy(int32 x, int32 y, BRegion* dirtyRegion)
|
|||||||
fFrame.right += x;
|
fFrame.right += x;
|
||||||
fFrame.bottom += y;
|
fFrame.bottom += y;
|
||||||
|
|
||||||
fBorderRegionValid = false;
|
|
||||||
fContentRegionValid = false;
|
fContentRegionValid = false;
|
||||||
fEffectiveDrawingRegionValid = false;
|
fEffectiveDrawingRegionValid = false;
|
||||||
|
|
||||||
@@ -765,10 +754,6 @@ Window::MouseDown(BMessage* message, BPoint where, int32* _viewToken)
|
|||||||
{
|
{
|
||||||
DesktopSettings desktopSettings(fDesktop);
|
DesktopSettings desktopSettings(fDesktop);
|
||||||
|
|
||||||
// TODO: move into Decorator
|
|
||||||
if (!fBorderRegionValid)
|
|
||||||
GetBorderRegion(&fBorderRegion);
|
|
||||||
|
|
||||||
bool eventEaten = fWindowBehaviour->MouseDown(message, where);
|
bool eventEaten = fWindowBehaviour->MouseDown(message, where);
|
||||||
if (!eventEaten) {
|
if (!eventEaten) {
|
||||||
// click was inside the window contents
|
// click was inside the window contents
|
||||||
@@ -898,12 +883,8 @@ Window::SetTitle(const char* name, BRegion& dirty)
|
|||||||
|
|
||||||
fTitle = name;
|
fTitle = name;
|
||||||
|
|
||||||
if (fDecorator) {
|
if (fDecorator)
|
||||||
fDecorator->SetTitle(name, &dirty);
|
fDecorator->SetTitle(name, &dirty);
|
||||||
|
|
||||||
fBorderRegionValid = false;
|
|
||||||
// the border very likely changed
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -915,7 +896,9 @@ Window::SetFocus(bool focus)
|
|||||||
// so the window thread cannot be
|
// so the window thread cannot be
|
||||||
// accessing fIsFocus
|
// accessing fIsFocus
|
||||||
|
|
||||||
BRegion* dirty = fRegionPool.GetRegion(fBorderRegion);
|
BRegion* dirty = NULL;
|
||||||
|
if (fDecorator)
|
||||||
|
dirty = fRegionPool.GetRegion(fDecorator->GetFootprint());
|
||||||
if (dirty) {
|
if (dirty) {
|
||||||
dirty->IntersectWith(&fVisibleRegion);
|
dirty->IntersectWith(&fVisibleRegion);
|
||||||
fDesktop->MarkDirty(*dirty);
|
fDesktop->MarkDirty(*dirty);
|
||||||
@@ -1028,13 +1011,10 @@ Window::GetSizeLimits(int32* minWidth, int32* maxWidth,
|
|||||||
bool
|
bool
|
||||||
Window::SetTabLocation(float location, BRegion& dirty)
|
Window::SetTabLocation(float location, BRegion& dirty)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
if (fDecorator)
|
||||||
if (fDecorator) {
|
return fDecorator->SetTabLocation(location, &dirty);
|
||||||
ret = fDecorator->SetTabLocation(location, &dirty);
|
|
||||||
// the border region changed if ret is true
|
return false;
|
||||||
fBorderRegionValid = fBorderRegionValid && !ret;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1050,13 +1030,9 @@ Window::TabLocation() const
|
|||||||
bool
|
bool
|
||||||
Window::SetDecoratorSettings(const BMessage& settings, BRegion& dirty)
|
Window::SetDecoratorSettings(const BMessage& settings, BRegion& dirty)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
if (fDecorator)
|
||||||
if (fDecorator) {
|
return fDecorator->SetSettings(settings, &dirty);
|
||||||
ret = fDecorator->SetSettings(settings, &dirty);
|
return false;
|
||||||
// the border region changed if ret is true
|
|
||||||
fBorderRegionValid = fBorderRegionValid && !ret;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1076,7 +1052,6 @@ Window::FontsChanged(BRegion* updateRegion)
|
|||||||
if (fDecorator != NULL) {
|
if (fDecorator != NULL) {
|
||||||
DesktopSettings settings(fDesktop);
|
DesktopSettings settings(fDesktop);
|
||||||
fDecorator->FontsChanged(settings, updateRegion);
|
fDecorator->FontsChanged(settings, updateRegion);
|
||||||
fBorderRegionValid = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1094,8 +1069,6 @@ Window::SetLook(window_look look, BRegion* updateRegion)
|
|||||||
|
|
||||||
fLook = look;
|
fLook = look;
|
||||||
|
|
||||||
fBorderRegionValid = false;
|
|
||||||
// the border very likely changed
|
|
||||||
fContentRegionValid = false;
|
fContentRegionValid = false;
|
||||||
// mabye a resize handle was added...
|
// mabye a resize handle was added...
|
||||||
fEffectiveDrawingRegionValid = false;
|
fEffectiveDrawingRegionValid = false;
|
||||||
@@ -1160,9 +1133,6 @@ Window::SetFlags(uint32 flags, BRegion* updateRegion)
|
|||||||
|
|
||||||
fDecorator->SetFlags(flags, updateRegion);
|
fDecorator->SetFlags(flags, updateRegion);
|
||||||
|
|
||||||
fBorderRegionValid = false;
|
|
||||||
// the border might have changed (smaller/larger tab)
|
|
||||||
|
|
||||||
// we might need to resize the window!
|
// we might need to resize the window!
|
||||||
if (fDecorator) {
|
if (fDecorator) {
|
||||||
fDecorator->GetSizeLimits(&fMinWidth, &fMinHeight, &fMaxWidth, &fMaxHeight);
|
fDecorator->GetSizeLimits(&fMinWidth, &fMinHeight, &fMaxWidth, &fMaxHeight);
|
||||||
@@ -1829,12 +1799,8 @@ Window::_UpdateContentRegion()
|
|||||||
fContentRegion.Set(fFrame);
|
fContentRegion.Set(fFrame);
|
||||||
|
|
||||||
// resize handle
|
// resize handle
|
||||||
if (fDecorator) {
|
if (fDecorator)
|
||||||
if (!fBorderRegionValid)
|
fContentRegion.Exclude(&fDecorator->GetFootprint());
|
||||||
GetBorderRegion(&fBorderRegion);
|
|
||||||
|
|
||||||
fContentRegion.Exclude(&fBorderRegion);
|
|
||||||
}
|
|
||||||
|
|
||||||
fContentRegionValid = true;
|
fContentRegionValid = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -247,7 +247,6 @@ public:
|
|||||||
static uint32 ValidWindowFlags();
|
static uint32 ValidWindowFlags();
|
||||||
static uint32 ValidWindowFlags(window_feel feel);
|
static uint32 ValidWindowFlags(window_feel feel);
|
||||||
|
|
||||||
BRegion& BorderRegion() { return fBorderRegion; }
|
|
||||||
protected:
|
protected:
|
||||||
void _ShiftPartOfRegion(BRegion* region,
|
void _ShiftPartOfRegion(BRegion* region,
|
||||||
BRegion* regionToShift, int32 xOffset,
|
BRegion* regionToShift, int32 xOffset,
|
||||||
@@ -289,12 +288,10 @@ protected:
|
|||||||
uint32 fDirtyCause;
|
uint32 fDirtyCause;
|
||||||
|
|
||||||
// caching local regions
|
// caching local regions
|
||||||
BRegion fBorderRegion;
|
|
||||||
BRegion fContentRegion;
|
BRegion fContentRegion;
|
||||||
BRegion fEffectiveDrawingRegion;
|
BRegion fEffectiveDrawingRegion;
|
||||||
|
|
||||||
bool fVisibleContentRegionValid : 1;
|
bool fVisibleContentRegionValid : 1;
|
||||||
bool fBorderRegionValid : 1;
|
|
||||||
bool fContentRegionValid : 1;
|
bool fContentRegionValid : 1;
|
||||||
bool fEffectiveDrawingRegionValid : 1;
|
bool fEffectiveDrawingRegionValid : 1;
|
||||||
|
|
||||||
@@ -345,8 +342,6 @@ protected:
|
|||||||
uint8 fCause;
|
uint8 fCause;
|
||||||
};
|
};
|
||||||
|
|
||||||
BRegion fDecoratorRegion;
|
|
||||||
|
|
||||||
UpdateSession fUpdateSessions[2];
|
UpdateSession fUpdateSessions[2];
|
||||||
UpdateSession* fCurrentUpdateSession;
|
UpdateSession* fCurrentUpdateSession;
|
||||||
UpdateSession* fPendingUpdateSession;
|
UpdateSession* fPendingUpdateSession;
|
||||||
|
|||||||
Reference in New Issue
Block a user