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
+57 -43
View File
@@ -23,8 +23,8 @@ struct shape_data {
enum {
B_VIEW_FONT_BIT = 0x00000001,
B_VIEW_COLORS_BIT = 0x00000002,
B_VIEW_DRAW_MODE_BIT = 0x00000004,
B_VIEW_HIGH_COLOR_BIT = 0x00000002,
B_VIEW_DRAWING_MODE_BIT = 0x00000004,
B_VIEW_CLIP_REGION_BIT = 0x00000008,
B_VIEW_LINE_MODES_BIT = 0x00000010,
B_VIEW_BLENDING_BIT = 0x00000020,
@@ -33,56 +33,70 @@ enum {
B_VIEW_COORD_BIT = 0x00000100,
B_VIEW_ORIGIN_BIT = 0x00000200,
B_VIEW_PEN_SIZE_BIT = 0x00000400,
B_VIEW_PEN_LOC_BIT = 0x00000800,
// used for archiving
B_VIEW_PEN_LOCATION_BIT = 0x00000800,
B_VIEW_LOW_COLOR_BIT = 0x00008000,
B_VIEW_VIEW_COLOR_BIT = 0x00010000,
B_VIEW_PATTERN_BIT = 0x00020000,
// these used for archiving only
B_VIEW_RESIZE_BIT = 0x00001000,
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 ?
//struct _view_attr_{
class ViewAttr
{
public:
ViewAttr(void);
BFont font;
uint16 fontFlags;
namespace BPrivate {
BPoint penPosition;
float penSize;
class ViewState {
public:
ViewState();
rgb_color highColor;
rgb_color lowColor;
// TODO: viewColor, is NOT part of a view state! Have this as a member of BView.
rgb_color viewColor;
pattern patt;
bool IsValid(uint32 bit) { return valid_flags & bit; }
drawing_mode drawingMode;
// clipping region for our view
BRegion clippingRegion;
// local coordinate system
BPoint coordSysOrigin;
// line modes
join_mode lineJoin;
cap_mode lineCap;
float miterLimit;
// alpha blending
source_alpha alphaSrcMode;
alpha_function alphaFncMode;
// scale
float scale;
// font aliasing. Used for printing only!
bool fontAliasing;
// flags used for synchronization with app_server
uint16 flags;
// flags used for archiving
uint16 archivingFlags;
void UpdateServerFontState(BPrivate::PortLink &link);
void UpdateServerState(BPrivate::PortLink &link);
public:
BPoint pen_location;
float pen_size;
rgb_color high_color;
rgb_color low_color;
// This one is not affected by pop state/push state
rgb_color view_color;
::pattern pattern;
::drawing_mode drawing_mode;
BRegion clipping_region;
BPoint origin;
// 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_{
float startX;
float startY;
@@ -100,4 +114,4 @@ struct _array_data_{
_array_hdr_* array;
};
#endif
#endif /* _VIEWAUX_H_ */