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:
@@ -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,
|
||||||
|
|||||||
@@ -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,
|
||||||
// used for archiving
|
B_VIEW_VIEW_COLOR_BIT = 0x00010000,
|
||||||
|
B_VIEW_PATTERN_BIT = 0x00020000,
|
||||||
|
|
||||||
|
// 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;
|
|
||||||
|
|
||||||
drawing_mode drawingMode;
|
void UpdateServerFontState(BPrivate::PortLink &link);
|
||||||
// clipping region for our view
|
void UpdateServerState(BPrivate::PortLink &link);
|
||||||
BRegion clippingRegion;
|
|
||||||
// local coordinate system
|
public:
|
||||||
BPoint coordSysOrigin;
|
BPoint pen_location;
|
||||||
// line modes
|
float pen_size;
|
||||||
join_mode lineJoin;
|
|
||||||
cap_mode lineCap;
|
rgb_color high_color;
|
||||||
float miterLimit;
|
rgb_color low_color;
|
||||||
// alpha blending
|
|
||||||
source_alpha alphaSrcMode;
|
// This one is not affected by pop state/push state
|
||||||
alpha_function alphaFncMode;
|
rgb_color view_color;
|
||||||
// scale
|
|
||||||
float scale;
|
::pattern pattern;
|
||||||
// font aliasing. Used for printing only!
|
|
||||||
bool fontAliasing;
|
::drawing_mode drawing_mode;
|
||||||
// flags used for synchronization with app_server
|
BRegion clipping_region;
|
||||||
uint16 flags;
|
BPoint origin;
|
||||||
// flags used for archiving
|
|
||||||
uint16 archivingFlags;
|
// line modes
|
||||||
|
join_mode line_join;
|
||||||
|
cap_mode line_cap;
|
||||||
|
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_ */
|
||||||
|
|||||||
+490
-536
File diff suppressed because it is too large
Load Diff
@@ -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(),
|
||||||
|
|||||||
@@ -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",
|
||||||
|
fTitle, fCurrentLayer->Name()));
|
||||||
|
|
||||||
float x, y;
|
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",
|
||||||
|
fTitle, fCurrentLayer->Name()));
|
||||||
|
|
||||||
float newWidth, newHeight;
|
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();
|
|
||||||
lowColor = fCurrentLayer->fLayerData->LowColor().GetColor32();
|
|
||||||
viewColor = fCurrentLayer->ViewColor().GetColor32();
|
|
||||||
|
|
||||||
fLink.StartMessage(SERVER_TRUE);
|
|
||||||
fLink.Attach(&highColor, sizeof(rgb_color));
|
|
||||||
fLink.Attach(&lowColor, sizeof(rgb_color));
|
|
||||||
fLink.Attach(&viewColor, sizeof(rgb_color));
|
|
||||||
fLink.Flush();
|
|
||||||
|
|
||||||
|
case AS_LAYER_GET_HIGH_COLOR:
|
||||||
|
DTRACE(("ServerWindow %s: Message AS_LAYER_GET_HIGH_COLOR: Layer: %s\n",
|
||||||
|
Title(), fCurrentLayer->Name()));
|
||||||
|
|
||||||
|
fLink.StartMessage(SERVER_TRUE);
|
||||||
|
fLink.Attach<rgb_color>(fCurrentLayer->fLayerData->HighColor().GetColor32());
|
||||||
|
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()));
|
||||||
|
|||||||
Reference in New Issue
Block a user