Rewrote the push/pop state and ViewAttr stuff:

- it now seems to work finally correctly
- renamed ViewAttr to ViewState and put it into the BPrivate namespace
- some refactoring (moved some private BView methods to ViewState)
- renamed AS_LAYER_MOVETO/RESIZETO to *_TO (note the underscore)
- exchanged BView::originX/Y with fParentOffset (BPoint)
- divided AS_LAYER_GET_COLORS into separate ones for high/low/view color
- BView::SetPattern() now actually works as expected (ie. updates
  only if necessary)
- exchanged the ViewAttr::flags with ViewState::valid_flags which inverses
  the previous logic (which wasn't even used consistently)
- fState was initialized twice (incorrectly by the ViewAttr constructor,
  and then again correctly by initCachedState()) - now the ViewState
  constructor does the job alone, but correctly
- BView::PushState() no longer resets the state (it did so only locally
  anyway...)
- cleanup


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13325 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-06-28 18:56:55 +00:00
parent f479b4974a
commit 80a230b10e
5 changed files with 589 additions and 606 deletions
+5 -3
View File
@@ -265,7 +265,9 @@ enum {
AS_LAYER_SET_HIGH_COLOR, AS_LAYER_SET_HIGH_COLOR,
AS_LAYER_SET_LOW_COLOR, AS_LAYER_SET_LOW_COLOR,
AS_LAYER_SET_VIEW_COLOR, AS_LAYER_SET_VIEW_COLOR,
AS_LAYER_GET_COLORS, AS_LAYER_GET_HIGH_COLOR,
AS_LAYER_GET_LOW_COLOR,
AS_LAYER_GET_VIEW_COLOR,
AS_LAYER_PRINT_ALIASING, AS_LAYER_PRINT_ALIASING,
AS_LAYER_CLIP_TO_PICTURE, AS_LAYER_CLIP_TO_PICTURE,
AS_LAYER_GET_CLIP_REGION, AS_LAYER_GET_CLIP_REGION,
@@ -287,8 +289,8 @@ enum {
AS_LAYER_INVAL_RECT, AS_LAYER_INVAL_RECT,
AS_LAYER_INVAL_REGION, AS_LAYER_INVAL_REGION,
AS_LAYER_INVERT_RECT, AS_LAYER_INVERT_RECT,
AS_LAYER_MOVETO, AS_LAYER_MOVE_TO,
AS_LAYER_RESIZETO, AS_LAYER_RESIZE_TO,
AS_LAYER_SET_STATE, AS_LAYER_SET_STATE,
AS_LAYER_SET_FONT_STATE, AS_LAYER_SET_FONT_STATE,
AS_LAYER_GET_STATE, AS_LAYER_GET_STATE,
+55 -41
View File
@@ -23,8 +23,8 @@ struct shape_data {
enum { enum {
B_VIEW_FONT_BIT = 0x00000001, B_VIEW_FONT_BIT = 0x00000001,
B_VIEW_COLORS_BIT = 0x00000002, B_VIEW_HIGH_COLOR_BIT = 0x00000002,
B_VIEW_DRAW_MODE_BIT = 0x00000004, B_VIEW_DRAWING_MODE_BIT = 0x00000004,
B_VIEW_CLIP_REGION_BIT = 0x00000008, B_VIEW_CLIP_REGION_BIT = 0x00000008,
B_VIEW_LINE_MODES_BIT = 0x00000010, B_VIEW_LINE_MODES_BIT = 0x00000010,
B_VIEW_BLENDING_BIT = 0x00000020, B_VIEW_BLENDING_BIT = 0x00000020,
@@ -33,56 +33,70 @@ enum {
B_VIEW_COORD_BIT = 0x00000100, B_VIEW_COORD_BIT = 0x00000100,
B_VIEW_ORIGIN_BIT = 0x00000200, B_VIEW_ORIGIN_BIT = 0x00000200,
B_VIEW_PEN_SIZE_BIT = 0x00000400, B_VIEW_PEN_SIZE_BIT = 0x00000400,
B_VIEW_PEN_LOC_BIT = 0x00000800, B_VIEW_PEN_LOCATION_BIT = 0x00000800,
B_VIEW_LOW_COLOR_BIT = 0x00008000,
B_VIEW_VIEW_COLOR_BIT = 0x00010000,
B_VIEW_PATTERN_BIT = 0x00020000,
// used for archiving // these used for archiving only
B_VIEW_RESIZE_BIT = 0x00001000, B_VIEW_RESIZE_BIT = 0x00001000,
B_VIEW_FLAGS_BIT = 0x00002000, B_VIEW_FLAGS_BIT = 0x00002000,
B_VIEW_EVMASK_BIT = 0x00004000 B_VIEW_EVENT_MASK_BIT = 0x00004000
}; };
// JB: Is there any reason why this can't be a struct ? namespace BPrivate {
//struct _view_attr_{
class ViewAttr
{
public:
ViewAttr(void);
BFont font;
uint16 fontFlags;
BPoint penPosition; class ViewState {
float penSize; public:
ViewState();
rgb_color highColor; bool IsValid(uint32 bit) { return valid_flags & bit; }
rgb_color lowColor;
// TODO: viewColor, is NOT part of a view state! Have this as a member of BView.
rgb_color viewColor;
pattern patt; void UpdateServerFontState(BPrivate::PortLink &link);
void UpdateServerState(BPrivate::PortLink &link);
drawing_mode drawingMode; public:
// clipping region for our view BPoint pen_location;
BRegion clippingRegion; float pen_size;
// local coordinate system
BPoint coordSysOrigin; rgb_color high_color;
// line modes rgb_color low_color;
join_mode lineJoin;
cap_mode lineCap; // This one is not affected by pop state/push state
float miterLimit; rgb_color view_color;
// alpha blending
source_alpha alphaSrcMode; ::pattern pattern;
alpha_function alphaFncMode;
// scale ::drawing_mode drawing_mode;
float scale; BRegion clipping_region;
// font aliasing. Used for printing only! BPoint origin;
bool fontAliasing;
// flags used for synchronization with app_server // line modes
uint16 flags; join_mode line_join;
// flags used for archiving cap_mode line_cap;
uint16 archivingFlags; float miter_limit;
// alpha blending
source_alpha alpha_source_mode;
alpha_function alpha_function_mode;
float scale;
// fonts
BFont font;
uint16 font_flags;
bool font_aliasing;
// font aliasing. Used for printing only!
// flags used for synchronization with app_server
uint32 valid_flags;
// flags used for archiving
uint32 archiving_flags;
}; };
} // namespace BPrivate
struct _array_hdr_{ struct _array_hdr_{
float startX; float startX;
float startY; float startY;
@@ -100,4 +114,4 @@ struct _array_data_{
_array_hdr_* array; _array_hdr_* array;
}; };
#endif #endif /* _VIEWAUX_H_ */
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -833,10 +833,10 @@ BWindow::DispatchMessage(BMessage *msg, BHandler *target)
msg->FindFloat("height", i, &height); msg->FindFloat("height", i, &height);
if ((view = findView(top_view, token))) { if ((view = findView(top_view, token))) {
// update the views offset in parent // update the views offset in parent
if (view->originX != frameLeftTop.x || view->originY != frameLeftTop.y) { if (view->LeftTop() != frameLeftTop) {
//printf("updating position (%.1f, %.1f): %s\n", frameLeftTop.x, frameLeftTop.y, view->Name()); //printf("updating position (%.1f, %.1f): %s\n", frameLeftTop.x, frameLeftTop.y, view->Name());
view->originX = frameLeftTop.x; view->fParentOffset = frameLeftTop;
view->originY = frameLeftTop.y;
// optionally call FrameMoved // optionally call FrameMoved
if (view->fFlags & B_FRAME_EVENTS) { if (view->fFlags & B_FRAME_EVENTS) {
STRACE(("Calling BView(%s)::FrameMoved( %.1f, %.1f )\n", view->Name(), STRACE(("Calling BView(%s)::FrameMoved( %.1f, %.1f )\n", view->Name(),
+31 -18
View File
@@ -621,11 +621,12 @@ myRootLayer->Unlock();
myRootLayer->SetEventMaskLayer(fCurrentLayer, mask, options); myRootLayer->SetEventMaskLayer(fCurrentLayer, mask, options);
break; break;
} }
case AS_LAYER_MOVETO: case AS_LAYER_MOVE_TO:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_MOVETO: Layer name: %s\n", fTitle, fCurrentLayer->Name())); STRACE(("ServerWindow %s: Message AS_LAYER_MOVE_TO: Layer name: %s\n",
float x, y; fTitle, fCurrentLayer->Name()));
float x, y;
link.Read<float>(&x); link.Read<float>(&x);
link.Read<float>(&y); link.Read<float>(&y);
@@ -635,11 +636,12 @@ myRootLayer->Unlock();
fCurrentLayer->MoveBy(offsetX, offsetY); fCurrentLayer->MoveBy(offsetX, offsetY);
break; break;
} }
case AS_LAYER_RESIZETO: case AS_LAYER_RESIZE_TO:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_RESIZETO: Layer name: %s\n", fTitle, fCurrentLayer->Name())); STRACE(("ServerWindow %s: Message AS_LAYER_RESIZE_TO: Layer name: %s\n",
float newWidth, newHeight; fTitle, fCurrentLayer->Name()));
float newWidth, newHeight;
link.Read<float>(&newWidth); link.Read<float>(&newWidth);
link.Read<float>(&newHeight); link.Read<float>(&newHeight);
@@ -854,23 +856,34 @@ myRootLayer->Lock();
myRootLayer->Unlock(); myRootLayer->Unlock();
break; break;
} }
case AS_LAYER_GET_COLORS:
{
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_COLORS: Layer: %s\n", Title(), fCurrentLayer->Name()));
rgb_color highColor, lowColor, viewColor;
highColor = fCurrentLayer->fLayerData->HighColor().GetColor32(); case AS_LAYER_GET_HIGH_COLOR:
lowColor = fCurrentLayer->fLayerData->LowColor().GetColor32(); DTRACE(("ServerWindow %s: Message AS_LAYER_GET_HIGH_COLOR: Layer: %s\n",
viewColor = fCurrentLayer->ViewColor().GetColor32(); Title(), fCurrentLayer->Name()));
fLink.StartMessage(SERVER_TRUE); fLink.StartMessage(SERVER_TRUE);
fLink.Attach(&highColor, sizeof(rgb_color)); fLink.Attach<rgb_color>(fCurrentLayer->fLayerData->HighColor().GetColor32());
fLink.Attach(&lowColor, sizeof(rgb_color));
fLink.Attach(&viewColor, sizeof(rgb_color));
fLink.Flush(); fLink.Flush();
break; break;
}
case AS_LAYER_GET_LOW_COLOR:
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_LOW_COLOR: Layer: %s\n",
Title(), fCurrentLayer->Name()));
fLink.StartMessage(SERVER_TRUE);
fLink.Attach<rgb_color>(fCurrentLayer->fLayerData->LowColor().GetColor32());
fLink.Flush();
break;
case AS_LAYER_GET_VIEW_COLOR:
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_VIEW_COLOR: Layer: %s\n",
Title(), fCurrentLayer->Name()));
fLink.StartMessage(SERVER_TRUE);
fLink.Attach<rgb_color>(fCurrentLayer->ViewColor().GetColor32());
fLink.Flush();
break;
case AS_LAYER_SET_BLEND_MODE: case AS_LAYER_SET_BLEND_MODE:
{ {
DTRACE(("ServerWindow %s: Message AS_LAYER_SET_BLEND_MODE: Layer: %s\n", Title(), fCurrentLayer->Name())); DTRACE(("ServerWindow %s: Message AS_LAYER_SET_BLEND_MODE: Layer: %s\n", Title(), fCurrentLayer->Name()));