History log of /haiku/src/kits/interface/Gradient.cpp
Revision Date Author Comments
# 779ab335 09-Dec-2020 X512 <danger_mail@list.ru>

use .IsSet() instead if .Get() != NULL

Change-Id: Ia2b7a719fd398e78cc3b11d4f7b02cb81179f65f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3488
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>


# 6d9c0146 11-Aug-2020 Adrien Destugues <pulkomandy@pulkomandy.tk>

BGradient: fix assignment operator, add copy constructor

The BGradient class is a bit strange as it can store any gradient on its
own, butonly the subclasses allow to set some of the fields.

In the asignment operator, the non-base data (which is in an union) was
not copied over.

More importantly, the missing copy constructor led to the default
implementation being used, and BList (used for the color stops) was
being copied using its default copy constructor, resulting in the two
BGradient (original and copy) poinitng to the same stops data. Heap
corruption resulted whenever one of them was deleted.

Having a working copy ocnstructor fixes this. The alternative is making
the copy constructor private or protected to make sure gradients are not
copied, since normally you'd copy only the subclasses, preserving the
C++ type. However there is nothing enforcing that, and manipulating a
BGradient copied from a subclass works just fine.

Change-Id: I28e733eb8a2970b76ae623eabb75ef8435f508af
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3144
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 36ef16bf 27-May-2020 X512 <danger_mail@list.ru>

BGradient: add Flatten, Unflatten methods

Change-Id: I861bab8ae19628d34297c294fd6ce3e5b6c82b34
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2827
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 77b60d22 02-May-2014 Adrien Destugues <pulkomandy@pulkomandy.tk>

Use std::stable_sort instead of mergesort.

* stable_sort is part of the C++ standard, and should work just as well.


# 3dfdd437 02-May-2014 Adrien Destugues <pulkomandy@pulkomandy.tk>

BGradient: preserve order of stops with same offset.

* Use merge sort, which is a stable sort, instead of the qsort used in
BList::SortItems
* This allows setting two stops with the same offset to create a sharp
color change in a gradient. This trick is used to create stripe patterns
with css gradients in some web pages.

Fixes #10733.


# de3e2b51 22-Apr-2014 Adrien Destugues <pulkomandy@pulkomandy.tk>

BGradient: don't allow out of bounds stops.

* They crash app_server if you try to use them, which is not a good idea.
* we could clamp them to 0/255, but reporting the error to the user
seems better.


# 64eb49fd 15-Feb-2009 Stephan Aßmus <superstippi@gmx.de>

* Cleanup in the Gradient department. No fuctional change.
Renamed BGradient::color_step to BGradient::ColorStop
as it's called everywhere else. Also renamed BGradient::gradient_type
to just BGradient::Type. Renamed BGradient::Type() to GetType().
* Simplification of method names in Painter.cpp. Some not yet
complete and yet inactive code to accelerate vertical gradients
(bypassing AGG for this special case).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29214 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 52de6dce 08-Nov-2008 Stephan Aßmus <superstippi@gmx.de>

Moved the gradient_type and color_step structs into the BGradient
class/namespace. Renamed the B_GRADIENT_* types to TYPE_* as the context
is already given.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28564 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b355a208 15-Oct-2008 Stephan Aßmus <superstippi@gmx.de>

patch by Artur Wyszynski:
* Fixed some bugs in the archiving code.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28146 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 991547ef 14-Oct-2008 Stephan Aßmus <superstippi@gmx.de>

Patch by Artur Wyszynski:
* Implemented BGradient, BGradientLinear, BGradientRadial,
BGradientDiamond, BGradientConic and BGradientRadialFocus
new Interface Kit classes.
* Implemented all the (AGG-based) backend necessary in
the app_server to render gradients (Painter, DrawingEngine)
* app_server/View can convert a BGradient layout to screen
coordinates.
* Added BGradient methods of the Fill* methods in BView.
* Implemented a test app and added it to the image as a
demo.
* Adopted Icon-O-Matic and libs/icon in order to avoid
clashing with the new BGradient class. Re-use some
parts where possible.

Awesome work, Artur! Thanks a lot. Now a more modern
looking GUI has just become much easier to implement! :-)

TODO:
* Remove the need to have gradient type twice in the
app_server protocol.
* Refactor some parts of the patch to remove duplicated
code (Painter, DrawingEngine).
* Adopt the BPicture protocol to know about BGradients.
* Review some parts of the BArchivable implementation.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28109 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 77b60d2222904e326718bf0f1e57efc7cd42ada7 02-May-2014 Adrien Destugues <pulkomandy@pulkomandy.tk>

Use std::stable_sort instead of mergesort.

* stable_sort is part of the C++ standard, and should work just as well.


# 3dfdd43723d226c6a6638508563e5aa677503e56 02-May-2014 Adrien Destugues <pulkomandy@pulkomandy.tk>

BGradient: preserve order of stops with same offset.

* Use merge sort, which is a stable sort, instead of the qsort used in
BList::SortItems
* This allows setting two stops with the same offset to create a sharp
color change in a gradient. This trick is used to create stripe patterns
with css gradients in some web pages.

Fixes #10733.


# de3e2b51862c5213818cec2776b3fa1bc43d1bfc 22-Apr-2014 Adrien Destugues <pulkomandy@pulkomandy.tk>

BGradient: don't allow out of bounds stops.

* They crash app_server if you try to use them, which is not a good idea.
* we could clamp them to 0/255, but reporting the error to the user
seems better.


# 64eb49fd247e510f572ead9f2fbec5b39acd3fe9 15-Feb-2009 Stephan Aßmus <superstippi@gmx.de>

* Cleanup in the Gradient department. No fuctional change.
Renamed BGradient::color_step to BGradient::ColorStop
as it's called everywhere else. Also renamed BGradient::gradient_type
to just BGradient::Type. Renamed BGradient::Type() to GetType().
* Simplification of method names in Painter.cpp. Some not yet
complete and yet inactive code to accelerate vertical gradients
(bypassing AGG for this special case).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29214 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 52de6dce94e48d957a3bb96d6b256f45a953f4c2 08-Nov-2008 Stephan Aßmus <superstippi@gmx.de>

Moved the gradient_type and color_step structs into the BGradient
class/namespace. Renamed the B_GRADIENT_* types to TYPE_* as the context
is already given.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28564 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b355a208d1b0dde4b4ef90941e54a5195b9a8788 15-Oct-2008 Stephan Aßmus <superstippi@gmx.de>

patch by Artur Wyszynski:
* Fixed some bugs in the archiving code.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28146 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 991547ef6c1fca650f0fba855206296ef54bc441 14-Oct-2008 Stephan Aßmus <superstippi@gmx.de>

Patch by Artur Wyszynski:
* Implemented BGradient, BGradientLinear, BGradientRadial,
BGradientDiamond, BGradientConic and BGradientRadialFocus
new Interface Kit classes.
* Implemented all the (AGG-based) backend necessary in
the app_server to render gradients (Painter, DrawingEngine)
* app_server/View can convert a BGradient layout to screen
coordinates.
* Added BGradient methods of the Fill* methods in BView.
* Implemented a test app and added it to the image as a
demo.
* Adopted Icon-O-Matic and libs/icon in order to avoid
clashing with the new BGradient class. Re-use some
parts where possible.

Awesome work, Artur! Thanks a lot. Now a more modern
looking GUI has just become much easier to implement! :-)

TODO:
* Remove the need to have gradient type twice in the
app_server protocol.
* Refactor some parts of the patch to remove duplicated
code (Painter, DrawingEngine).
* Adopt the BPicture protocol to know about BGradients.
* Review some parts of the BArchivable implementation.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28109 a95241bf-73f2-0310-859d-f6bbb57e9c96