xref: /haiku/headers/private/interface/HaikuControlLook.h (revision 4a55cc230cf7566cadcbb23b1928eefff8aea9a2)
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 	virtual float				GetScrollBarWidth(
341 									orientation orientation = B_VERTICAL);
342 
343 protected:
344 			void				_DrawButtonFrame(BView* view, BRect& rect,
345 									const BRect& updateRect,
346 									float leftTopRadius,
347 									float rightTopRadius,
348 									float leftBottomRadius,
349 									float rightBottomRadius,
350 									const rgb_color& base,
351 									const rgb_color& background,
352 									float contrast, float brightness = 1.0,
353 									uint32 flags = 0,
354 									uint32 borders = B_ALL_BORDERS);
355 
356 			void				_DrawOuterResessedFrame(BView* view,
357 									BRect& rect, const rgb_color& base,
358 									float contrast = 1.0f,
359 									float brightness = 1.0f,
360 									uint32 flags = 0,
361 									uint32 borders = B_ALL_BORDERS);
362 
363 			void				_DrawFrame(BView* view, BRect& rect,
364 									const rgb_color& left,
365 									const rgb_color& top,
366 									const rgb_color& right,
367 									const rgb_color& bottom,
368 									uint32 borders = B_ALL_BORDERS);
369 			void				_DrawFrame(BView* view, BRect& rect,
370 									const rgb_color& left,
371 									const rgb_color& top,
372 									const rgb_color& right,
373 									const rgb_color& bottom,
374 									const rgb_color& rightTop,
375 									const rgb_color& leftBottom,
376 									uint32 borders = B_ALL_BORDERS);
377 
378 			void				_DrawButtonBackground(BView* view, BRect& rect,
379 									const BRect& updateRect,
380 									float leftTopRadius,
381 									float rightTopRadius,
382 									float leftBottomRadius,
383 									float rightBottomRadius,
384 									const rgb_color& base,
385 									bool popupIndicator = false,
386 									uint32 flags = 0,
387 									uint32 borders = B_ALL_BORDERS,
388 									orientation orientation = B_HORIZONTAL);
389 			void				_DrawFlatButtonBackground(BView* view,
390 									BRect& rect, const BRect& updateRect,
391 									const rgb_color& base,
392 									bool popupIndicator = false,
393 									uint32 flags = 0,
394 									uint32 borders = B_ALL_BORDERS,
395 									orientation orientation = B_HORIZONTAL);
396 			void				_DrawNonFlatButtonBackground(BView* view,
397 									BRect& rect, const BRect& updateRect,
398 									BRegion& clipping,
399 									float leftTopRadius,
400 									float rightTopRadius,
401 									float leftBottomRadius,
402 									float rightBottomRadius,
403 									const rgb_color& base,
404 									bool popupIndicator = false,
405 									uint32 flags = 0,
406 									uint32 borders = B_ALL_BORDERS,
407 									orientation orientation = B_HORIZONTAL);
408 
409 			void				_DrawPopUpMarker(BView* view, const BRect& rect,
410 									const rgb_color& base, uint32 flags);
411 
412 			void				_DrawMenuFieldBackgroundOutside(BView* view,
413 									BRect& rect, const BRect& updateRect,
414 									float leftTopRadius,
415 									float rightTopRadius,
416 									float leftBottomRadius,
417 									float rightBottomRadius,
418 									const rgb_color& base,
419 									bool popupIndicator = false,
420 									uint32 flags = 0);
421 
422 			void				_DrawMenuFieldBackgroundInside(BView* view,
423 									BRect& rect, const BRect& updateRect,
424 									float leftTopRadius,
425 									float rightTopRadius,
426 									float leftBottomRadius,
427 									float rightBottomRadius,
428 									const rgb_color& base, uint32 flags = 0,
429 									uint32 borders = B_ALL_BORDERS);
430 
431 	// Rounded corner methods
432 			void				_DrawRoundCornerLeftTop(BView* view,
433 									BRect& cornerRect, const BRect& updateRect,
434 									const rgb_color& background,
435 									const rgb_color& edgeColor,
436 									const rgb_color& frameColor,
437 									const rgb_color& bevelColor,
438 									const BGradientLinear& fillGradient);
439 
440 			void				_DrawRoundCornerFrameLeftTop(BView* view,
441 									BRect& cornerRect, const BRect& updateRect,
442 									const rgb_color& background,
443 									const rgb_color& edgeColor,
444 									const rgb_color& frameColor);
445 
446 			void				_DrawRoundCornerBackgroundLeftTop(BView* view,
447 									BRect& cornerRect, const BRect& updateRect,
448 									const rgb_color& bevelColor,
449 									const BGradientLinear& fillGradient);
450 
451 			void				_DrawRoundCornerRightTop(BView* view,
452 									BRect& cornerRect, const BRect& updateRect,
453 									const rgb_color& background,
454 									const rgb_color& edgeTopColor,
455 									const rgb_color& edgeRightColor,
456 									const rgb_color& frameTopColor,
457 									const rgb_color& frameRightColor,
458 									const rgb_color& bevelTopColor,
459 									const rgb_color& bevelRightColor,
460 									const BGradientLinear& fillGradient);
461 
462 			void				_DrawRoundCornerFrameRightTop(BView* view,
463 									BRect& cornerRect, const BRect& updateRect,
464 									const rgb_color& background,
465 									const rgb_color& edgeTopColor,
466 									const rgb_color& edgeRightColor,
467 									const rgb_color& frameTopColor,
468 									const rgb_color& frameRightColor);
469 
470 			void				_DrawRoundCornerBackgroundRightTop(BView* view,
471 									BRect& cornerRect, const BRect& updateRect,
472 									const rgb_color& bevelTopColor,
473 									const rgb_color& bevelRightColor,
474 									const BGradientLinear& fillGradient);
475 
476 			void				_DrawRoundCornerLeftBottom(BView* view,
477 									BRect& cornerRect, const BRect& updateRect,
478 									const rgb_color& background,
479 									const rgb_color& edgeLeftColor,
480 									const rgb_color& edgeBottomColor,
481 									const rgb_color& frameLeftColor,
482 									const rgb_color& frameBottomColor,
483 									const rgb_color& bevelLeftColor,
484 									const rgb_color& bevelBottomColor,
485 									const BGradientLinear& fillGradient);
486 
487 			void				_DrawRoundCornerFrameLeftBottom(BView* view,
488 									BRect& cornerRect, const BRect& updateRect,
489 									const rgb_color& background,
490 									const rgb_color& edgeLeftColor,
491 									const rgb_color& edgeBottomColor,
492 									const rgb_color& frameLeftColor,
493 									const rgb_color& frameBottomColor);
494 
495 			void				_DrawRoundCornerBackgroundLeftBottom(BView* view,
496 									BRect& cornerRect, const BRect& updateRect,
497 									const rgb_color& bevelLeftColor,
498 									const rgb_color& bevelBottomColor,
499 									const BGradientLinear& fillGradient);
500 
501 			void				_DrawRoundCornerRightBottom(BView* view,
502 									BRect& cornerRect, const BRect& updateRect,
503 									const rgb_color& background,
504 									const rgb_color& edgeColor,
505 									const rgb_color& frameColor,
506 									const rgb_color& bevelColor,
507 									const BGradientLinear& fillGradient);
508 
509 			void				_DrawRoundCornerFrameRightBottom(BView* view,
510 									BRect& cornerRect, const BRect& updateRect,
511 									const rgb_color& background,
512 									const rgb_color& edgeColor,
513 									const rgb_color& frameColor);
514 
515 			void				_DrawRoundCornerBackgroundRightBottom(
516 									BView* view,
517 									BRect& cornerRect, const BRect& updateRect,
518 									const rgb_color& bevelColor,
519 									const BGradientLinear& fillGradient);
520 
521 			void				_DrawRoundBarCorner(BView* view, BRect& rect,
522 									const BRect& updateRect,
523 									const rgb_color& edgeLightColor,
524 									const rgb_color& edgeShadowColor,
525 									const rgb_color& frameLightColor,
526 									const rgb_color& frameShadowColor,
527 									const rgb_color& fillLightColor,
528 									const rgb_color& fillShadowColor,
529 									float leftInset, float topInset,
530 									float rightInset, float bottomInset,
531 									orientation orientation);
532 
533 	// Border color methods
534 			rgb_color			_EdgeLightColor(const rgb_color& base,
535 									float contrast, float brightness,
536 									uint32 flags);
537 
538 			rgb_color			_EdgeShadowColor(const rgb_color& base,
539 									float contrast, float brightness,
540 									uint32 flags);
541 
542 			rgb_color			_FrameLightColor(const rgb_color& base,
543 									uint32 flags);
544 
545 			rgb_color			_FrameShadowColor(const rgb_color& base,
546 									uint32 flags);
547 
548 			rgb_color			_BevelLightColor(const rgb_color& base,
549 									uint32 flags);
550 
551 			rgb_color			_BevelShadowColor(const rgb_color& base,
552 									uint32 flags);
553 
554 	// Background gradient methods
555 			void				_FillGradient(BView* view, const BRect& rect,
556 									const rgb_color& base, float topTint,
557 									float bottomTint,
558 									orientation orientation = B_HORIZONTAL);
559 
560 			void				_FillGlossyGradient(BView* view,
561 									const BRect& rect, const rgb_color& base,
562 									float topTint, float middle1Tint,
563 									float middle2Tint, float bottomTint,
564 									orientation orientation = B_HORIZONTAL);
565 
566 			void				_MakeGradient(BGradientLinear& gradient,
567 									const BRect& rect, const rgb_color& base,
568 									float topTint, float bottomTint,
569 									orientation orientation = B_HORIZONTAL) const;
570 
571 			void				_MakeGlossyGradient(BGradientLinear& gradient,
572 									const BRect& rect, const rgb_color& base,
573 									float topTint, float middle1Tint,
574 									float middle2Tint, float bottomTint,
575 									orientation orientation = B_HORIZONTAL) const;
576 
577 			void				_MakeButtonGradient(BGradientLinear& gradient,
578 									BRect& rect, const rgb_color& base,
579 									uint32 flags, orientation orientation = B_HORIZONTAL) const;
580 
581 			bool				_RadioButtonAndCheckBoxMarkColor(
582 									const rgb_color& base, rgb_color& color,
583 									uint32 flags) const;
584 
585 private:
586 			bool				fCachedOutline;
587 };
588 
589 
590 } // namespace BPrivate
591 
592 #endif // _HAIKU_CONTROL_LOOK_H
593