xref: /haiku/headers/private/interface/HaikuControlLook.h (revision 52c4471a3024d2eb81fe88e2c3982b9f8daa5e56)
1 /*
2  * Copyright 2009-2020 Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _HAIKU_CONTROL_LOOK_H
6 #define _HAIKU_CONTROL_LOOK_H
7 
8 
9 #include <ControlLook.h>
10 
11 
12 class BBitmap;
13 class BControl;
14 class BGradientLinear;
15 class BView;
16 
17 
18 namespace BPrivate {
19 
20 
21 class HaikuControlLook : public BControlLook {
22 public:
23 								HaikuControlLook();
24 	virtual						~HaikuControlLook();
25 
26 	virtual BAlignment			DefaultLabelAlignment() const;
27 	virtual float				DefaultLabelSpacing() const;
28 
29 	virtual	float				DefaultItemSpacing() const;
30 
31 	virtual uint32				Flags(BControl* control) const;
32 
33 	virtual	void				DrawButtonFrame(BView* view, BRect& rect,
34 									const BRect& updateRect,
35 									const rgb_color& base,
36 									const rgb_color& background,
37 									uint32 flags = 0,
38 									uint32 borders = B_ALL_BORDERS);
39 	virtual	void				DrawButtonFrame(BView* view, BRect& rect,
40 									const BRect& updateRect,
41 									float radius,
42 									const rgb_color& base,
43 									const rgb_color& background,
44 									uint32 flags = 0,
45 									uint32 borders = B_ALL_BORDERS);
46 	virtual	void				DrawButtonFrame(BView* view, BRect& rect,
47 									const BRect& updateRect,
48 									float leftTopRadius,
49 									float rightTopRadius,
50 									float leftBottomRadius,
51 									float rightBottomRadius,
52 									const rgb_color& base,
53 									const rgb_color& background,
54 									uint32 flags = 0,
55 									uint32 borders = B_ALL_BORDERS);
56 
57 	virtual	void				DrawButtonBackground(BView* view, BRect& rect,
58 									const BRect& updateRect,
59 									const rgb_color& base,
60 									uint32 flags = 0,
61 									uint32 borders = B_ALL_BORDERS,
62 									orientation orientation = B_HORIZONTAL);
63 	virtual	void				DrawButtonBackground(BView* view, BRect& rect,
64 									const BRect& updateRect,
65 									float radius,
66 									const rgb_color& base,
67 									uint32 flags = 0,
68 									uint32 borders = B_ALL_BORDERS,
69 									orientation orientation = B_HORIZONTAL);
70 	virtual	void				DrawButtonBackground(BView* view, BRect& rect,
71 									const BRect& updateRect,
72 									float leftTopRadius,
73 									float rightTopRadius,
74 									float leftBottomRadius,
75 									float rightBottomRadius,
76 									const rgb_color& base,
77 									uint32 flags = 0,
78 									uint32 borders = B_ALL_BORDERS,
79 									orientation orientation = B_HORIZONTAL);
80 
81 	virtual	void				DrawMenuBarBackground(BView* view, BRect& rect,
82 									const BRect& updateRect,
83 									const rgb_color& base,
84 									uint32 flags = 0,
85 									uint32 borders = B_ALL_BORDERS);
86 
87 	virtual	void				DrawMenuFieldFrame(BView* view, BRect& rect,
88 									const BRect& updateRect,
89 									const rgb_color& base,
90 									const rgb_color& background,
91 									uint32 flags = 0,
92 									uint32 borders = B_ALL_BORDERS);
93 	virtual	void				DrawMenuFieldFrame(BView* view, BRect& rect,
94 									const BRect& updateRect,
95 									float radius,
96 									const rgb_color& base,
97 									const rgb_color& background,
98 									uint32 flags = 0,
99 									uint32 borders = B_ALL_BORDERS);
100 	virtual	void				DrawMenuFieldFrame(BView* view, BRect& rect,
101 									const BRect& updateRect,
102 									float leftTopRadius,
103 									float rightTopRadius,
104 									float leftBottomRadius,
105 									float rightBottomRadius,
106 									const rgb_color& base,
107 									const rgb_color& background,
108 									uint32 flags = 0,
109 									uint32 borders = B_ALL_BORDERS);
110 
111 	virtual	void				DrawMenuFieldBackground(BView* view,
112 									BRect& rect, const BRect& updateRect,
113 									const rgb_color& base, bool popupIndicator,
114 									uint32 flags = 0);
115 	virtual	void				DrawMenuFieldBackground(BView* view,
116 									BRect& rect, const BRect& updateRect,
117 									float radius, const rgb_color& base,
118 									bool popupIndicator, uint32 flags = 0);
119 	virtual	void				DrawMenuFieldBackground(BView* view,
120 									BRect& rect, const BRect& updateRect,
121 									float leftTopRadius,
122 									float rightTopRadius,
123 									float leftBottomRadius,
124 									float rightBottomRadius,
125 									const rgb_color& base,
126 									bool popupIndicator, uint32 flags = 0);
127 	virtual	void				DrawMenuFieldBackground(BView* view,
128 									BRect& rect, const BRect& updateRect,
129 									const rgb_color& base, uint32 flags = 0,
130 									uint32 borders = B_ALL_BORDERS);
131 
132 	virtual	void				DrawMenuBackground(BView* view,
133 									BRect& rect, const BRect& updateRect,
134 									const rgb_color& base, uint32 flags = 0,
135 									uint32 borders = B_ALL_BORDERS);
136 
137 	virtual	void				DrawMenuItemBackground(BView* view,
138 									BRect& rect, const BRect& updateRect,
139 									const rgb_color& base, uint32 flags = 0,
140 									uint32 borders = B_ALL_BORDERS);
141 
142 	virtual	void				DrawStatusBar(BView* view, BRect& rect,
143 									const BRect& updateRect,
144 									const rgb_color& base,
145 									const rgb_color& barColor,
146 									float progressPosition);
147 
148 	virtual	void				DrawCheckBox(BView* view, BRect& rect,
149 									const BRect& updateRect,
150 									const rgb_color& base,
151 									uint32 flags = 0);
152 
153 	virtual	void				DrawRadioButton(BView* view, BRect& rect,
154 									const BRect& updateRect,
155 									const rgb_color& base,
156 									uint32 flags = 0);
157 
158 	virtual	void				DrawScrollBarBorder(BView* view,
159 									BRect rect, const BRect& updateRect,
160 									const rgb_color& base, uint32 flags,
161 									orientation orientation);
162 	virtual	void				DrawScrollBarButton(BView* view,
163 									BRect rect, const BRect& updateRect,
164 									const rgb_color& base, uint32 flags,
165 									int32 direction, orientation orientation,
166 									bool down = false);
167 	virtual	void				DrawScrollBarBackground(BView* view,
168 									BRect& rect1, BRect& rect2,
169 									const BRect& updateRect,
170 									const rgb_color& base, uint32 flags,
171 									orientation orientation);
172 	virtual	void				DrawScrollBarBackground(BView* view,
173 									BRect& rect, const BRect& updateRect,
174 									const rgb_color& base, uint32 flags,
175 									orientation orientation);
176 	virtual	void				DrawScrollBarThumb(BView* view,
177 									BRect& rect, const BRect& updateRect,
178 									const rgb_color& base, uint32 flags,
179 									orientation orientation,
180 									uint32 knobStyle = B_KNOB_NONE);
181 
182 	virtual	void				DrawScrollViewFrame(BView* view,
183 									BRect& rect, const BRect& updateRect,
184 									BRect verticalScrollBarFrame,
185 									BRect horizontalScrollBarFrame,
186 									const rgb_color& base,
187 									border_style borderStyle,
188 									uint32 flags = 0,
189 									uint32 borders = B_ALL_BORDERS);
190 
191 	virtual	void				DrawArrowShape(BView* view,
192 									BRect& rect, const BRect& updateRect,
193 									const rgb_color& base, uint32 direction,
194 									uint32 flags = 0,
195 									float tint = B_DARKEN_MAX_TINT);
196 
197 	virtual	rgb_color			SliderBarColor(const rgb_color& base);
198 
199 	virtual	void				DrawSliderBar(BView* view, BRect rect,
200 									const BRect& updateRect,
201 									const rgb_color& base,
202 									rgb_color leftFillColor,
203 									rgb_color rightFillColor,
204 									float sliderScale, uint32 flags,
205 									orientation orientation);
206 	virtual	void				DrawSliderBar(BView* view, BRect rect,
207 									const BRect& updateRect,
208 									const rgb_color& base, rgb_color fillColor,
209 									uint32 flags, orientation orientation);
210 
211 	virtual	void				DrawSliderThumb(BView* view, BRect& rect,
212 									const BRect& updateRect,
213 									const rgb_color& base, uint32 flags,
214 									orientation orientation);
215 
216 	virtual	void				DrawSliderTriangle(BView* view, BRect& rect,
217 									const BRect& updateRect,
218 									const rgb_color& base, uint32 flags,
219 									orientation orientation);
220 	virtual	void				DrawSliderTriangle(BView* view, BRect& rect,
221 									const BRect& updateRect,
222 									const rgb_color& base,
223 									const rgb_color& fill, uint32 flags,
224 									orientation orientation);
225 
226 	virtual	void				DrawSliderHashMarks(BView* view, BRect& rect,
227 									const BRect& updateRect,
228 									const rgb_color& base, int32 count,
229 									hash_mark_location location,
230 									uint32 flags, orientation orientation);
231 
232 	virtual	void				DrawTabFrame(BView* view, BRect& rect,
233 									const BRect& updateRect,
234 									const rgb_color& base, uint32 flags = 0,
235 									uint32 borders = B_ALL_BORDERS,
236 									border_style borderStyle = B_FANCY_BORDER,
237 									uint32 side = B_TOP_BORDER);
238 	virtual	void				DrawActiveTab(BView* view, BRect& rect,
239 									const BRect& updateRect,
240 									const rgb_color& base, uint32 flags = 0,
241 									uint32 borders = B_ALL_BORDERS,
242 									uint32 side = B_TOP_BORDER,
243 									int32 index = 0, int32 selected = -1,
244 									int32 first = 0, int32 last = 0);
245 	virtual	void				DrawInactiveTab(BView* view, BRect& rect,
246 									const BRect& updateRect,
247 									const rgb_color& base, uint32 flags = 0,
248 									uint32 borders = B_ALL_BORDERS,
249 									uint32 side = B_TOP_BORDER,
250 									int32 index = 0, int32 selected = -1,
251 									int32 first = 0, int32 last = 0);
252 
253 	virtual	void				DrawSplitter(BView* view, BRect& rect,
254 									const BRect& updateRect,
255 									const rgb_color& base,
256 									orientation orientation,
257 									uint32 flags = 0,
258 									uint32 borders = B_ALL_BORDERS);
259 
260 	// various borders
261 
262 	virtual	void				DrawBorder(BView* view, BRect& rect,
263 									const BRect& updateRect,
264 									const rgb_color& base,
265 									border_style borderStyle, uint32 flags = 0,
266 									uint32 borders = B_ALL_BORDERS);
267 
268 	virtual	void				DrawRaisedBorder(BView* view, BRect& rect,
269 									const BRect& updateRect,
270 									const rgb_color& base, uint32 flags = 0,
271 									uint32 borders = B_ALL_BORDERS);
272 
273 	virtual	void				DrawGroupFrame(BView* view, BRect& rect,
274 									const BRect& updateRect,
275 									const rgb_color& base,
276 									uint32 borders = B_ALL_BORDERS);
277 
278 	virtual	void				DrawTextControlBorder(BView* view, BRect& rect,
279 									const BRect& updateRect,
280 									const rgb_color& base, uint32 flags = 0,
281 									uint32 borders = B_ALL_BORDERS);
282 
283 	// aligned labels
284 
285 	virtual	void				DrawLabel(BView* view, const char* label,
286 									BRect rect, const BRect& updateRect,
287 									const rgb_color& base, uint32 flags,
288 									const rgb_color* textColor = NULL);
289 	virtual	void				DrawLabel(BView* view, const char* label,
290 									BRect rect, const BRect& updateRect,
291 									const rgb_color& base, uint32 flags,
292 									const BAlignment& alignment,
293 									const rgb_color* textColor = NULL);
294 	// TODO: Would be nice to have a (non-virtual) version of this method
295 	// which takes an array of labels and locations. That would save some
296 	// setup with the view graphics state.
297 	virtual	void				DrawLabel(BView* view, const char* label,
298 									const rgb_color& base, uint32 flags,
299 									const BPoint& where,
300 									const rgb_color* textColor = NULL);
301 
302 	virtual	void				DrawLabel(BView* view, const char* label,
303 									const BBitmap* icon, BRect rect,
304 									const BRect& updateRect,
305 									const rgb_color& base, uint32 flags,
306 									const BAlignment& alignment,
307 									const rgb_color* textColor = NULL);
308 
309 	virtual	void				GetFrameInsets(frame_type frameType,
310 									uint32 flags, float& _left, float& _top,
311 									float& _right, float& _bottom);
312 	virtual	void				GetBackgroundInsets(
313 									background_type backgroundType,
314 									uint32 flags, float& _left, float& _top,
315 									float& _right, float& _bottom);
316 
317 	virtual	void				DrawButtonWithPopUpBackground(BView* view,
318 									BRect& rect, const BRect& updateRect,
319 									const rgb_color& base,
320 									uint32 flags = 0,
321 									uint32 borders = B_ALL_BORDERS,
322 									orientation orientation = B_HORIZONTAL);
323 	virtual	void				DrawButtonWithPopUpBackground(BView* view,
324 									BRect& rect, const BRect& updateRect,
325 									float radius,
326 									const rgb_color& base,
327 									uint32 flags = 0,
328 									uint32 borders = B_ALL_BORDERS,
329 									orientation orientation = B_HORIZONTAL);
330 	virtual	void				DrawButtonWithPopUpBackground(BView* view,
331 									BRect& rect, const BRect& updateRect,
332 									float leftTopRadius,
333 									float rightTopRadius,
334 									float leftBottomRadius,
335 									float rightBottomRadius,
336 									const rgb_color& base,
337 									uint32 flags = 0,
338 									uint32 borders = B_ALL_BORDERS,
339 									orientation orientation = B_HORIZONTAL);
340 
341 protected:
342 			void				_DrawButtonFrame(BView* view, BRect& rect,
343 									const BRect& updateRect,
344 									float leftTopRadius,
345 									float rightTopRadius,
346 									float leftBottomRadius,
347 									float rightBottomRadius,
348 									const rgb_color& base,
349 									const rgb_color& background,
350 									float contrast, float brightness = 1.0,
351 									uint32 flags = 0,
352 									uint32 borders = B_ALL_BORDERS);
353 
354 			void				_DrawOuterResessedFrame(BView* view,
355 									BRect& rect, const rgb_color& base,
356 									float contrast = 1.0f,
357 									float brightness = 1.0f,
358 									uint32 flags = 0,
359 									uint32 borders = B_ALL_BORDERS);
360 
361 			void				_DrawFrame(BView* view, BRect& rect,
362 									const rgb_color& left,
363 									const rgb_color& top,
364 									const rgb_color& right,
365 									const rgb_color& bottom,
366 									uint32 borders = B_ALL_BORDERS);
367 			void				_DrawFrame(BView* view, BRect& rect,
368 									const rgb_color& left,
369 									const rgb_color& top,
370 									const rgb_color& right,
371 									const rgb_color& bottom,
372 									const rgb_color& rightTop,
373 									const rgb_color& leftBottom,
374 									uint32 borders = B_ALL_BORDERS);
375 
376 			void				_DrawButtonBackground(BView* view, BRect& rect,
377 									const BRect& updateRect,
378 									float leftTopRadius,
379 									float rightTopRadius,
380 									float leftBottomRadius,
381 									float rightBottomRadius,
382 									const rgb_color& base,
383 									bool popupIndicator = false,
384 									uint32 flags = 0,
385 									uint32 borders = B_ALL_BORDERS,
386 									orientation orientation = B_HORIZONTAL);
387 			void				_DrawFlatButtonBackground(BView* view,
388 									BRect& rect, const BRect& updateRect,
389 									const rgb_color& base,
390 									bool popupIndicator = false,
391 									uint32 flags = 0,
392 									uint32 borders = B_ALL_BORDERS,
393 									orientation orientation = B_HORIZONTAL);
394 			void				_DrawNonFlatButtonBackground(BView* view,
395 									BRect& rect, const BRect& updateRect,
396 									BRegion& clipping,
397 									float leftTopRadius,
398 									float rightTopRadius,
399 									float leftBottomRadius,
400 									float rightBottomRadius,
401 									const rgb_color& base,
402 									bool popupIndicator = false,
403 									uint32 flags = 0,
404 									uint32 borders = B_ALL_BORDERS,
405 									orientation orientation = B_HORIZONTAL);
406 
407 			void				_DrawPopUpMarker(BView* view, const BRect& rect,
408 									const rgb_color& base, uint32 flags);
409 
410 			void				_DrawMenuFieldBackgroundOutside(BView* view,
411 									BRect& rect, const BRect& updateRect,
412 									float leftTopRadius,
413 									float rightTopRadius,
414 									float leftBottomRadius,
415 									float rightBottomRadius,
416 									const rgb_color& base,
417 									bool popupIndicator = false,
418 									uint32 flags = 0);
419 
420 			void				_DrawMenuFieldBackgroundInside(BView* view,
421 									BRect& rect, const BRect& updateRect,
422 									float leftTopRadius,
423 									float rightTopRadius,
424 									float leftBottomRadius,
425 									float rightBottomRadius,
426 									const rgb_color& base, uint32 flags = 0,
427 									uint32 borders = B_ALL_BORDERS);
428 
429 	// Rounded corner methods
430 			void				_DrawRoundCornerLeftTop(BView* view,
431 									BRect& cornerRect, const BRect& updateRect,
432 									const rgb_color& background,
433 									const rgb_color& edgeColor,
434 									const rgb_color& frameColor,
435 									const rgb_color& bevelColor,
436 									const BGradientLinear& fillGradient);
437 
438 			void				_DrawRoundCornerFrameLeftTop(BView* view,
439 									BRect& cornerRect, const BRect& updateRect,
440 									const rgb_color& background,
441 									const rgb_color& edgeColor,
442 									const rgb_color& frameColor);
443 
444 			void				_DrawRoundCornerBackgroundLeftTop(BView* view,
445 									BRect& cornerRect, const BRect& updateRect,
446 									const rgb_color& bevelColor,
447 									const BGradientLinear& fillGradient);
448 
449 			void				_DrawRoundCornerRightTop(BView* view,
450 									BRect& cornerRect, const BRect& updateRect,
451 									const rgb_color& background,
452 									const rgb_color& edgeTopColor,
453 									const rgb_color& edgeRightColor,
454 									const rgb_color& frameTopColor,
455 									const rgb_color& frameRightColor,
456 									const rgb_color& bevelTopColor,
457 									const rgb_color& bevelRightColor,
458 									const BGradientLinear& fillGradient);
459 
460 			void				_DrawRoundCornerFrameRightTop(BView* view,
461 									BRect& cornerRect, const BRect& updateRect,
462 									const rgb_color& background,
463 									const rgb_color& edgeTopColor,
464 									const rgb_color& edgeRightColor,
465 									const rgb_color& frameTopColor,
466 									const rgb_color& frameRightColor);
467 
468 			void				_DrawRoundCornerBackgroundRightTop(BView* view,
469 									BRect& cornerRect, const BRect& updateRect,
470 									const rgb_color& bevelTopColor,
471 									const rgb_color& bevelRightColor,
472 									const BGradientLinear& fillGradient);
473 
474 			void				_DrawRoundCornerLeftBottom(BView* view,
475 									BRect& cornerRect, const BRect& updateRect,
476 									const rgb_color& background,
477 									const rgb_color& edgeLeftColor,
478 									const rgb_color& edgeBottomColor,
479 									const rgb_color& frameLeftColor,
480 									const rgb_color& frameBottomColor,
481 									const rgb_color& bevelLeftColor,
482 									const rgb_color& bevelBottomColor,
483 									const BGradientLinear& fillGradient);
484 
485 			void				_DrawRoundCornerFrameLeftBottom(BView* view,
486 									BRect& cornerRect, const BRect& updateRect,
487 									const rgb_color& background,
488 									const rgb_color& edgeLeftColor,
489 									const rgb_color& edgeBottomColor,
490 									const rgb_color& frameLeftColor,
491 									const rgb_color& frameBottomColor);
492 
493 			void				_DrawRoundCornerBackgroundLeftBottom(BView* view,
494 									BRect& cornerRect, const BRect& updateRect,
495 									const rgb_color& bevelLeftColor,
496 									const rgb_color& bevelBottomColor,
497 									const BGradientLinear& fillGradient);
498 
499 			void				_DrawRoundCornerRightBottom(BView* view,
500 									BRect& cornerRect, const BRect& updateRect,
501 									const rgb_color& background,
502 									const rgb_color& edgeColor,
503 									const rgb_color& frameColor,
504 									const rgb_color& bevelColor,
505 									const BGradientLinear& fillGradient);
506 
507 			void				_DrawRoundCornerFrameRightBottom(BView* view,
508 									BRect& cornerRect, const BRect& updateRect,
509 									const rgb_color& background,
510 									const rgb_color& edgeColor,
511 									const rgb_color& frameColor);
512 
513 			void				_DrawRoundCornerBackgroundRightBottom(
514 									BView* view,
515 									BRect& cornerRect, const BRect& updateRect,
516 									const rgb_color& bevelColor,
517 									const BGradientLinear& fillGradient);
518 
519 			void				_DrawRoundBarCorner(BView* view, BRect& rect,
520 									const BRect& updateRect,
521 									const rgb_color& edgeLightColor,
522 									const rgb_color& edgeShadowColor,
523 									const rgb_color& frameLightColor,
524 									const rgb_color& frameShadowColor,
525 									const rgb_color& fillLightColor,
526 									const rgb_color& fillShadowColor,
527 									float leftInset, float topInset,
528 									float rightInset, float bottomInset,
529 									orientation orientation);
530 
531 	// Border color methods
532 			rgb_color			_EdgeLightColor(const rgb_color& base,
533 									float contrast, float brightness,
534 									uint32 flags);
535 
536 			rgb_color			_EdgeShadowColor(const rgb_color& base,
537 									float contrast, float brightness,
538 									uint32 flags);
539 
540 			rgb_color			_FrameLightColor(const rgb_color& base,
541 									uint32 flags);
542 
543 			rgb_color			_FrameShadowColor(const rgb_color& base,
544 									uint32 flags);
545 
546 			rgb_color			_BevelLightColor(const rgb_color& base,
547 									uint32 flags);
548 
549 			rgb_color			_BevelShadowColor(const rgb_color& base,
550 									uint32 flags);
551 
552 	// Background gradient methods
553 			void				_FillGradient(BView* view, const BRect& rect,
554 									const rgb_color& base, float topTint,
555 									float bottomTint,
556 									orientation orientation = B_HORIZONTAL);
557 
558 			void				_FillGlossyGradient(BView* view,
559 									const BRect& rect, const rgb_color& base,
560 									float topTint, float middle1Tint,
561 									float middle2Tint, float bottomTint,
562 									orientation orientation = B_HORIZONTAL);
563 
564 			void				_MakeGradient(BGradientLinear& gradient,
565 									const BRect& rect, const rgb_color& base,
566 									float topTint, float bottomTint,
567 									orientation orientation = B_HORIZONTAL) const;
568 
569 			void				_MakeGlossyGradient(BGradientLinear& gradient,
570 									const BRect& rect, const rgb_color& base,
571 									float topTint, float middle1Tint,
572 									float middle2Tint, float bottomTint,
573 									orientation orientation = B_HORIZONTAL) const;
574 
575 			void				_MakeButtonGradient(BGradientLinear& gradient,
576 									BRect& rect, const rgb_color& base,
577 									uint32 flags, orientation orientation = B_HORIZONTAL) const;
578 
579 			bool				_RadioButtonAndCheckBoxMarkColor(
580 									const rgb_color& base, rgb_color& color,
581 									uint32 flags) const;
582 
583 private:
584 			bool				fCachedOutline;
585 };
586 
587 
588 } // namespace BPrivate
589 
590 #endif // _HAIKU_CONTROL_LOOK_H
591