Commit Graph

286 Commits

Author SHA1 Message Date
Adrien Destugues
3a2b67b5ae Support for configuring screen backlight
Accelerant interface:
Introduce new hooks B_SET_BRIGHTNESS and B_GET_BRIGHTNESS. Brightness is
a float in the 0..1 range.

App_server:
Forward brightness things between BScreen and the accelerant.

intel_extreme:
Implement the hooks. Note that this only works for laptop panels, but
the driver will pretend to support it in other cases as well.

Screen preferences:
If the accelerant supports the B_GET_BRIGHTNESS hook, allow to set
brightness with a slider. Otherwise, the slidere is hidden and these
changes aren't visible.
2017-11-21 09:12:18 +01:00
Augustin Cavalier
db68ff23c6 Interface Kit: Make BControlLook a proper pure-virtual base class.
All of its prior functionality has been moved into HaikuControlLook.
This paves the way for customizeable control looks, which I intend to implement
in the future as part of decorators.

This is being pushed now because libbe ABI was already broken due to the
Notifications changes, so this is riding that so we only have to do a mass
rebuild once.
2017-09-30 21:12:33 -04:00
John Scipione
3705d40cd9 BSpinner: Set min value then max value
... reverse this to avoid confusion, you'll see why in next commit.

No functional change intended in this commit, functional change is in the
next commit.
2017-01-12 14:15:44 -08:00
John Scipione
81364c9d82 BColorMenuItem: add custom color menufield
http://insightfactory.tumblr.com/image/142366356207

* Make the color box a rectangle with proportions of golden ratio.
* Override GetContentSize() to make menu item area larger.
* Label should never truncate since I make sure there is enough room.
* Draw the label using BMenuItem parent class
* Carefully adjust the spacing so that there is an attractive amount of
  padding between the checkmark and color box and the color box and label.

Add _AddMenu method to BMenuField that adds BColorMenuItem as its
base menu item. This shows the BColorMenuItem in the closed state.

Create BPrivate::MenuItemPrivate

Add a SetSubmenu() method to MenuItemPrivate that gives you
the ability to add a submenu after creating the object. This
method should be public

Skip disabled items

Color gets updated even if you select an item in a submenu
2016-07-31 19:42:39 -07:00
John Scipione
e8d4db8e0b MenuPrivate: Add SetItemMargins() method 2016-07-31 19:42:39 -07:00
John Scipione
61dfdec415 BMenu and friends: style fixes
BMenuBar: style fix: msg => message

MenuPrivate: style fixes

MenuItem: 80 char limit style fix

MenuBar: tiny style fix

Menu: tiny style fix, indentation

Menu: Small refactor

Implement _SetIgnoreHidden() in header
Change on to ignoreHidden
Change on in _SetStickyMode to sticky

_BMCItem_: tiny whitespace style fix

Menu: style fixes, rename msgr => messenger

BMenu: style fix, pointer != NULL

BMenu::Archive rename ret to status

Also check pointer against NULL explicitly

BMenuItem style fixes: rename abbreviation, pointer style
2016-07-31 19:42:39 -07:00
John Scipione
c4ec640b46 WindowInfo: spaces => tabs 2016-03-31 14:39:49 -07:00
looncraz
f9f16ddb2c BAbstractSpinner Colors
Adopted parent colors for the text view - should not have done so.
Disabled colors were incorrect, so I also corrected those in this patch.

Fixes #12574.

Signed-off-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>
2016-01-10 18:51:04 +13:00
Augustin Cavalier
1d11475790 BAboutWindow: Put the AboutView and StripeView into BPrivate.
To avoid name clashes. Possibly fixes the HaikuDepot crashes.
2016-01-06 15:08:34 -05:00
looncraz
7f9368cae5 Set*UIColor, etc.
The inseparable changes necessary to support live color updating across the
system in a sane, safe, and performant manner.

BView gains:

HasSystemColors()
HasDefaultColors()
AdoptSystemColors()
AdoptParentColors()
AdoptViewColor(BView*)
SetViewUIColor(color_which, float tint)
SetHighUIColor(...
SetLowUIColor(...
ViewUIColor(float* tint)
HighUIColor(...
LowUIColor(...
DelayedInvalidate()

BWindow gains a simple helper method:
IsOffscreenWindow()

BMessage gains:

AddColor()
FindColor()
GetColor()
HasColor()            * allegedly this API is deprecated, but I implemented it anyway
ReplaceColor()
SetColor()

Previous private ColorTools methods are made public and moved into GraphicsDefs:

mix_color, blend_color, disable_color

These are fully compatible with BeOS dan0 R5.1 methods and are just code cleanup
of BeOS example code under the OpenTracker license.

In addition, four new colors are created:
B_LINK_TEXT_COLOR
B_LINK_HOVER_COLOR
B_LINK_ACTIVE_COLOR
B_LINK_VISITED_COLOR

These changes are documented in their proper user documentation files.

In addition, due to a history rewrite, B_FOLLOW_LEFT_TOP has been defined and
used in lieu of B_FOLLOW_TOP | B_FOLLOW_LEFT and is included in this commit.

On the app_server side, the following has changed:

Add DelayedMessage - a system by which messages can be sent at a scheduled time,
and can also be merged according to set rules.  A single thread is used to service the
message queue and multiple recipients can be set for each message.
Desktop gains the ability to add message ports to a DelayedMessage so that
said messages can target either all applications or all windows, as needed.

Desktop maintains a BMessage which is used to queue up all pending color changes
and the delayed messaging system is used to enact these changes after a short
period of time has passed.  This prevents abuse and allows the system to merge
repeated set_ui_color events into one event for client applications, improving
performance drastically.

In addition, B_COLORS_UPDATED is sent to the BApplication, which forwards the message
to each BWindow.  This is done to improve performance over having the app_server
independently informing each window.

Decorator changes are live now, which required some reworking.

Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
2016-01-04 06:48:22 -05:00
Julian Harnath
b54b3ae511 app_server: add a cache for AlphaMasks
* If the same shape alpha mask is set again and again, we now keep
  the rendered masks in a cache. On certain websites, WebKit sets
  the same shape for clipping hundreds of times, which uses a lot
  of time to render the masks.

* When a shape mask was generated, we put it into AlphaMaskCache.
  The constructor for ShapeAlphaMask is made private and a factory
  method is used for instantiation instead, which transparently
  looks up in the cache whether a suitable mask was already generated
  before (so the entire caching is encapsulated inside the AlphaMask
  class).

* When taking a mask out of the cache, we still create a new
  AlphaMask instance. However, the new instance will share the
  mask bitmap with the previously generated instance (aside from
  the rendering of their bitmap, AlphaMask instances are pretty
  lightweight). Shape masks are only seen as identical when
  their shape is the same, the inverse flag, and they have the
  same parent mask.

* Cache is limited to a fixed size of currently 8 MiB, using a
  simple random replacement scheme. An LRU scheme can be added in
  the future if necessary. Counting of bytes for the cache size
  includes parent masks of masks in the cache, even if the parent
  itself is not cached. A reference counter for "indirect" cache
  references keeps track of which masks are not part of the cache,
  but still need to be added to the cache byte size.

* For now, only for ShapeAlphaMasks, other mask types can be added
  as necessary.
2015-11-14 16:09:52 +01:00
Julian Harnath
25dbf74b8e BView: add methods for affine translation/scaling/rotation
* BView::TranslateBy(), BView::ScaleBy() and BView::RotateBy()
  allow to conveniently modify the current affine transformation.
  This makes it unnecessary to first read the current transform,
  modify it, and then set it again.
  Uses the new Pre...() methods of BAffineTransform.

* Also, remove setting the transform "through" to the BView even
  while recording a BPicture, as this now results in transforms
  being applied more than once.
2015-11-10 23:34:08 +01:00
Julian Harnath
4bd6f322bb app_server/Interface Kit: add new clipping API
* Add new clipping API for rectangles (ClipToRect, ClipToInverseRect)
  and shapes (ClipToShape, ClipToInverseShape)

* Works with affine transforms and automatically switches from fast
  region-based clipping to alpha-mask based clipping as necessary.

* Always self-intersecting, i.e. no state push required to further
  narrow down the clipping region. All of the 4 new methods can be
  mixed in any order.
2015-11-10 23:33:54 +01:00
Julian Harnath
ab12093685 BShape: move bounding box method to shape_data
* Makes it easier to get the bounding box from inside app_server
2015-11-10 23:12:30 +01:00
Julian Harnath
6109a2086d Merge branch 'app_server'
Conflicts:
	src/kits/interface/PicturePlayer.cpp
	src/servers/app/ServerPicture.cpp

In addition, the following files were also adapted to master branch
BPicture changes during the merge:
	src/kits/interface/PicturePlayer.h
	src/servers/app/PictureBoundingBoxPlayer.cpp
2015-11-10 23:09:54 +01:00
Stefano Ceccherini
ce27f9612e Implement ClipToPicture inside a BPicture. Not working yet.
BView::ClipToPicture doesn't work anymore, when nested inside a BPicture,
This happened when its implementation was moved server-side.
2015-09-05 21:35:54 +02:00
Michael Lotz
eec73693e0 PicturePlayer: Rework to be more safe against corrupted data.
This introduces a more sane API (currently private) that allows for
safer and possibly more efficient implementations:

* It uses a struct of named and typed function pointers instead of just
  a void pointer array. This adds type safety to the callbacks so the
  compiler can figure out if things match up before subtle bugs get
  introduced.
* It provides bounds for all strings/buffers passed to the callbacks.
* It uses const references instead of implicitly copying arguments.
* It folds stroke_x/fill_x pairs into draw_x functions with a fill
  argument to reduce the amount of functions needed.
* It uses unsigned values where negative values make no sense.

The old API has been implemented on top of the new one using adapter
functions. It makes copies of all data passed to the callbacks which
effectively keeps the picture data from being modified. This matches
with the R5 behaviour.

This also reimplements the buffer parsing to be safe against corrupted
data by validating that the types actually fit in the provided sizes
and buffers (using a templated reader).

Since this class is used from the app_server with user provided data,
making it more safe is important even though it comes with a slight
overhead (replicating R5 behaviour, i.e. crashing the app_server when
corrupted data is fed, doesn't seem very appropriate here).
2015-09-05 16:09:31 +02:00
Julian Harnath
71cc4d4998 Merge branch 'master' into app_server
Conflicts:
	src/kits/app/Roster.cpp
2015-09-01 20:07:21 +02:00
John Scipione
a0ba79fbff Split BSpinner into BAbstractSpinner and...
2 concrete classes which are currently implemented:
* BSpinner (works on int32s)
* BDecimalSpinner (works on doubles)

In addition BAbstractSpinner now inherits from BControl instead of
BView/BInvoker. This allowed for code simplification at the cost of needing to
cast for the decimal version because SetValue(int32 value) comes from BControl.

Also, add a spinner_button_style enum with 3 options:
* SPINNER_BUTTON_HORIZONTAL_ARROWS
* SPINNER_BUTTON_VERTICAL_ARROWS
* SPINNER_BUTTON_PLUS_MINUS

which sets the spinner arrows to either use horizontal arrows (left/right)
vertical arrows, (up/down), or +/- symbols (the default).

If the spinner button is using horizontal arrows you can decrement and increment
the spinner value by pushing control+left/right, otherwise you can increment and
decrement by pushing up or down. The reason for needing control is so that you
can move the cursor in the textbox otherwise.

Switch the 3 apps that are currently using BSpinners to use the integer variety
in Deskbar preferences, WebPostive preferences, and Screen preferences.
2015-08-22 15:15:08 -07:00
John Scipione
d122938346 Spinner: Generalize actions into methods
Add an Increment(), Decrement(), and SetValueFromText() method.

These can be overridden by derived classes.
2015-08-22 15:15:07 -07:00
John Scipione
a9385e8e2e Spinner: Move ValueChanged up
... along with the other hook methods
2015-08-22 15:15:06 -07:00
John Scipione
adba4ce988 Add BSpinner class based on GCI2013 work 2015-08-22 15:15:03 -07:00
Julian Harnath
551438b9be app_server: add new BView layers API
* 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.
2015-07-25 16:35:52 +02:00
Rene Gollent
df459da6ed {Tree,Table}: Add cell rect accessor.
BColumnListView:
- Add helper method for getting the visible rect of a given field.
  Refactor SuggestTextPosition to use it.

{Tree,Table}:
- Add wrapper to retrieve table cell rect using the aforementioned
  BCLV helper.
2015-07-17 23:12:39 -04:00
Augustin Cavalier
c432a83bf3 TabView: Add TabViewPrivate class, actually fix non-layout SetView.
Thanks to Axel and Stephan for reviewing!
2015-07-14 11:04:39 -04:00
Janus
85b350edda BColumnListView: BRow height is proportional to font size.
* Add a BRow default constructor that use font size to compute height.
* Min height size for Title and Row are decoupled.
* The font ratio for Title and Row are decoupled.
* For small font use min height (set to usual 16.0).
* Better baseline formula.
* Fixes #11944.
2015-04-05 16:58:00 +00:00
John Scipione
2c3505de79 PictureDataWriter: Style fixes only
No functional change intended
2015-03-16 20:19:52 -04:00
Augustin Cavalier
7dc141827a Delete old rgb_color operators that are no longer needed. 2015-02-28 12:54:31 -05:00
John Scipione
35384ab425 MenuPrivate: Add a SetLayout() method to MenuPrivate
that allows you to set the menu_layout of the menu after construction.
2015-02-20 14:35:36 -05:00
John Scipione
09d0a76b7b MenuPrivate: Style fixes to MenuPrivate.h 2015-02-20 14:24:46 -05:00
Axel Dörfler
b617d006f9 ViewPrivate.h: minor cleanup, no functional change. 2015-02-13 22:33:57 +01:00
John Scipione
539dc1bc53 A bunch of style fixes
No functional changes intended
2014-12-02 19:23:51 -05:00
John Scipione
db1ef05aef BShape: Style fixes for docs 2014-07-14 19:02:44 -04:00
Adrien Destugues
9576c4b742 BRegion scaling: fix semantics to avoid holes/overlaps
Thanks to Stippi for pointing this out.
2014-06-19 19:23:29 +02:00
Adrien Destugues
669ac9d6f5 BRegion: add ScaleBy method.
* Is there a reason to not have it?
2014-06-19 18:05:14 +02:00
John Scipione
9ce450b9c2 AboutWindow: Move to Interface Kit (still private) 2014-03-25 14:17:19 -04:00
Adrien Destugues
eb43166326 app_server & interface kit: support fill rules.
* BView gets SetFillRule/FillRule methods. The fill rule is part of the
view state.
* The B_NONZERO rule is the default. This is what we implemented before.
* The B_EVEN_ODD rule is the other common possibility for this, and
we need to support it to help WebKit to render properly.
2014-03-11 17:27:42 +01:00
John Scipione
14aa801ae9 Update DecorInfo to scan for decorators
Look in system and user packaged and non-packaged decorator directories.
2014-02-20 19:31:49 -05:00
Stephan Aßmus
a6db6bd40f Added WIP support for affine transformations to BViews.
Everything untested, but compiles, so it must work. The idea is to introduce
BAffineTransform additionally to the existing Origin and Scale properties of
BViews. One may use it in parallel or as an alternative. Painter in app_server
is not yet aware of the additional transformation. It is however already used
to transform drawing coordinates. It probably needs to work differently,
perhaps only in Painter and AGGTextRenderer.
2014-02-04 22:53:06 +01:00
Ingo Weinhold
f0c3101151 BControl: Move icon code to separate class BIcon 2013-12-22 15:17:53 +01:00
Stephan Aßmus
ed6f171aa6 BColumnListView: Enable invalidating rows, fix SetField()
* Seems like there was no easy way to simply invalidate
   a given BRow. Introduced BColumnListView::InvalidateRow().
 * BRow::SetField() tried to invalidate the row, but invalidated
   the listview instead of the BOutlineView responsible for
   drawing the list contents. Use the new InvaalidateRow().
2013-09-17 14:42:03 +02:00
Ingo Weinhold
cf70d345b2 Merge remote-tracking branch 'haiku/master' into package-management
This reverts 8f7f28a7c3 (OpenGL: Upgrade
to
Mesa 9.2).

Conflicts:
	build/jam/BuildFeatures
	build/jam/HaikuImage
	build/jam/OptionalPackages
	build/scripts/build_cross_tools_gcc4
	src/add-ons/opengl/swpipe/Jamfile
	src/apps/diskusage/Jamfile
	src/kits/tracker/ContainerWindow.cpp
	src/kits/tracker/DeskWindow.cpp
	src/kits/tracker/Jamfile
2013-09-13 01:02:28 +02:00
Ingo Weinhold
88f12ad84f Add private BViewPort class
* It simplifies putting regular layout-aware views or layout items into
  a BScrollView.
* Not quite complete yet: Height-for-width support is missing, but that
  also requires fixing BScrollView in this respect. Scroll bar auto-hide
  support would be nice as well.
2013-09-11 04:51:03 +02:00
John Scipione
3dd9ff2b5d BMCMenuBar: Refactor MakeFocus()
Get rid of unused fRunner variable.

It is very basic now, it just works.

Also, renamed msg to message in MessageReceived() and
declared MakeFocus() above it (alphabetically).
2013-08-25 00:09:28 -04:00
John Scipione
408c0ee4cd MenuField: enable/disable the menu field when...
the child menu bar or the child menu bar's menu is enabled/disabled.

This means that there is just one status we have to check, the menu
fields, and the child menus agree. This change takes practical form
in the Backgrounds preflet which disables the placement menu when
the image is set to "None", but, only the menu got disabled and not the
parent menu field so the label was erroneously still drawn as enabled.
2013-08-20 18:15:13 -04:00
John Scipione
1c95f72222 Don't set MaxContentWidth on the menu bar of a BMenuField
Fixes #9816

It is no longer necessary, or even desirable for us to set the max
content width of the menu bar of a BMenuField now that BMenuItem
truncation and BMenuField sizing are working.

The user may, however, wish to set the max content width of the menu
bar of a BMenuField themselves like so:

menuField->MenuBar()->SetMaxContentWidth(width);

and the Interface Kit will automatically deduct the left and right
margins from the width including the space used by the drop down arrow.
2013-06-07 03:25:36 -04:00
John Scipione
ca3a1c0451 BMenuField: If fixed size always set max content width
When you resize, also set max content width.

Create a SetMaxContentWidth() method that includes the margins.
2013-05-30 00:05:17 -04:00
John Scipione
92c12506ac Move kMinMenuBarWidth to MenuField.cpp 2013-05-30 00:05:16 -04:00
John Scipione
a1cf3ead5f Resize menu field if below minimum width in auto-size mode
... cancelling the normal item truncation behavior.
This funcationality comes from BeOS R5, we need to reproduce it for
backwards compat. KeymapSwitcher depends on it at least.

Minimum width is 20px, was set in last commit, comes from BeOS R5.
2013-05-30 00:05:16 -04:00
John Scipione
6031e62420 Move constants to BMCPrivate.h and refactor
We use these constants in both MenuField.cpp and BMCPrivate.cpp

Incorporate kMarginWidth into kPopUpIndicatorWidth.

A small code simplication in FrameResized() along with replacing bare numbers
with magic constants.
2013-05-30 00:05:15 -04:00