Refactor BResources::WriteResource to return early in case of errors,
instead of checking permanently if (error == B_OK). Makes the code more
readable and removes some useless checks.
The aspect ratio of the preview was wrong for two reasons:
* The height of the preview was always assumed to be 150 while it actually
depends on the layout.
* The size was then only set using SetExplicitMinSize(), which is not
sufficient to actually change the size to the desired value.
Fixes#11644.
Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
Even though C++ should increment the enum for us, since these IDs
are set and used by things outside of this file, we should hard-code
the numbers.
No functional change (or if there is, it means there's a compiler bug
somewhere.)
* Add new methods
BView::BeginLayer(uint8 opacity)
BView::EndLayer()
* All drawing between begin and end of a layer is redirected onto an
intermediate bitmap. When ending the layer, this bitmap is
composited onto the view with the opacity given when the layer was
started.
* Layers can be nested arbitrarily and will be blended onto each
other in order. There can also be any arbitrary interleaving of
layer begin/end and drawing operations.
* Internally, drawing commands are redirected into a BPicture between
BeginLayer and EndLayer (but client code need not know or care
about this). Client code can also start/end other BPictures while
inside a layer.
* Uses the PictureBoundingBoxPlayer to determine the size of the
layer bitmap before allocating and drawing into it, so it does not
allocate more memory than necessary and -- more importantly -- it
will not alpha-composite more pixels than necessary.
* Drawing mode is always set to B_OP_ALPHA, blend mode to
(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE) while inside layers. This is
necessary for (a) correct compositing output and (b) for
redirection of drawing into the intermediate bitmap, which uses the
renderer_region offset (in B_OP_COPY, the Painter does not use the
AGG renderer methods, it directly accesses the pixel data. This
would access out-of-bounds without the offset, so B_OP_COPY cannot
be allowed.)
To ensure these modes aren't changed, BView::SetDrawingMode()
and BView::SetBlendingMode() are ignored while inside a layer.
* The main motivation behind this new API is WebKit, which internally
expects such a layers functionality to be present. A performant and
reusable implementation of this functionality can only be done
server-side in app_server.
* agg::renderer_region gets an extra feature which allows to
optionally shift the coordinates by a specified offset.
* This allows to shift coordinates at the lowest level, even below
the transformations done by BAffineTransform (which happen in the
painter, right before rasterization).
Needed for layers support: shifts the origin of the layer bitmaps
to their position in the view while keeping all transformations
(BView origin/scale transforms as well as BAffineTransforms)
intact. The offset for the layer bitmaps within their parent view
is determined by the bounding box and is then fixed, it must not
be altered while the layer's BPicture is played into the bitmap.
If this offset were added to the BView origin or as translation in
the BAffineTransform, it would be further transformed by the BView
scale or the other affine transform parameters. Thus, we need
another low-level offset mechanism which is even below
BAffineTransform's transformations.
* Allow shifting the offset of alpha masks without changing the size.
Ideally, we only need to reattach the buffer in the shifted
position, saving the work of reallocating and redrawing the mask
picture. Needed for layers support.
* Another constructor for AlphaMask allows creating a mask with no
picture, it will simply be a single uniform alpha value over the
whole mask.
* No need to even allocate a buffer in this case, we can just use
the feature of clipped_alpha_mask to define an opacity for outside
the mask, and set the buffer size to zero.
* New method DrawState::SetTransformEnabled allows to temporarily
disable all BAffineTransforms in the state stack (up to 'this').
Later, the same method can be used to reenable the transforms.
Needed for layers support: when drawing the finished layer bitmap
onto the view, the affine transforms must not be applied again --
they have already been applied while drawing the bitmap's contents.
* Add PictureBoundingBoxPlayer, a new player for BPictures. Instead
of drawing the picture, it determines an approximate bounding box
of its contained drawing operations.
* To increase performance, the resulting bounding box is an
approximation: it guarantees to always enclose all pixels of the
picture, however not necessarily tightly.
* PictureBoundingBoxPlayer::Play() gets a DrawState which is the
initial state used when playing the picture. The player does not
modify this state (it uses a copy internally), so the method is
idempotent.
* New method DrawState::Squash() uses the combined scale, origin and
transform as the state's own scale, origin, transform.
This can be used when making copies of DrawStates which have
previous states below them in the state stack. The top of stack
DrawState can be copied, squashed and then used just like the
original one with the whole stack below it (except of course
when trying to pop off any earlier state).
* app_server currently does not have any real unit tests, making
changes more difficult and riskier. A new directory unit_tests with
a test add-on is added in app_server's tetsts directory to hold
future unit tests.
* Add test for SimpleTransform class
* Move coordinate conversion into a new class SimpleTransform. It
supports scaling and translation which is sufficient for conversion
between screen, local and pen (drawing) coordinates.
* Because all the overloaded methods for converting
BPoint/BRect/BRegion/etc are now within the single SimpleTransform
class, the interfaces of Canvas, View, DrawState, etc. are slimmed
down. These classes have too many responsibilities, so some will be
factored out into separate classes, this being the first.
* Better reflects the purpose of the class: an interface for things
in which we can draw (e.g. a View)
* Accordingly rename OffscreenContext to OffscreenCanvas
* Add support for macports lib and headers dirs.
* Link libs change for Mac OS X for tool build.
Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
VariablesView:
- Factor out setting up a variable edit request into a helper function.
Adjust table node invocation accordingly.
- Add Edit variable context menu item if appropriate.
- Don't return result of SelectOptionFor(). It's possible to attempt
to edit an enum value that hasn't yet been initialized, in which case
its current value might not map to any of the defined enumerations, and
the resulting error would prevent editing from being allowed.
- According to POSIX, these functions should map to whatever's appropriate
for the platform's intmax_t size, which in our case is a 64-bit integer.
Our (2004) implementation, however, was calling the 32-bit variations of
strto*(), leading to truncation for larger values.
FloatValueFormatter:
- Implement parsing/validation hooks.
FloatValueHandler:
- Implement GetTableCellValueEditor() to accordingly return a
(newly implemented) TableCellFloatEditor. This allows variable
value editing for float/double variables.
FloatValue:
- Store value as variant rather than double so as to be able to
later differentiate between float vs double.
PrimitiveValueNode:
- Construct float nodes with variant value.
VariablesView:
- Intercept table node invocations. If the invocation corresponds to
a writable variable, request a corresponding editor and bring up a
an edit window for it.
- Handle requests from the edit window to write the final updated value
of the variable.
This implements the last missing piece for ticket #9708, except for an
editor for floats.
VariablesView::Listener:
- Add hook for requesting value node value updates.
TeamWindow:
- Implement VariablesView listener hook and forward accordingly to
TeamDebugger.
WriteValueNodeJob:
- Implement async job that creates a ValueWriter to update a variable
value on request.
UserInterfaceListener:
- Add hook for requesting that a node be updated with a new value.
Implement in TeamDebugger by scheduling a WriteValueNodeJob.
VariableEditWindow:
- Implement container window for variable value editors. While
not as ideal as initially intended, this will handle presenting value
editing to the user until more work is done on the table cell editing
aspect of things.
TableCellOptionPopUpEditor:
- Add virtual hook for retrieving the final selected value. Implement
accordingly in Bool and Enumeration editor subclasses.
- Implement calling the edit completion hook upon value changes.
* While it should not be a big problem the
bebook specify to do it after custom operations,
most nodes also follow this way, this commit restore
consistency.