1b960e451SClemens Zeidler/*
27f9368caSlooncraz * Copyright 2010-2015, Haiku, Inc.
3b960e451SClemens Zeidler * Distributed under the terms of the MIT License.
4b960e451SClemens Zeidler *
5b960e451SClemens Zeidler * Authors:
6b960e451SClemens Zeidler *		Clemens Zeidler <haiku@clemens-zeidler.de>
7e3ab8648SIngo Weinhold *		Ingo Weinhold <ingo_weinhold@gmx.de>
8b960e451SClemens Zeidler */
9b960e451SClemens Zeidler
10638d9c80SIngo Weinhold
11b960e451SClemens Zeidler#include "SATDecorator.h"
12b960e451SClemens Zeidler
13b960e451SClemens Zeidler#include <new>
14b960e451SClemens Zeidler
15b960e451SClemens Zeidler#include <GradientLinear.h>
16b960e451SClemens Zeidler#include <WindowPrivate.h>
17b960e451SClemens Zeidler
18b960e451SClemens Zeidler#include "DrawingEngine.h"
1963bf94e2SClemens Zeidler#include "SATWindow.h"
20b960e451SClemens Zeidler
21b960e451SClemens Zeidler
2219f43b9fSClemens Zeidler//#define DEBUG_SATDECORATOR
23b960e451SClemens Zeidler#ifdef DEBUG_SATDECORATOR
24b960e451SClemens Zeidler#	define STRACE(x) debug_printf x
25b960e451SClemens Zeidler#else
26b960e451SClemens Zeidler#	define STRACE(x) ;
27b960e451SClemens Zeidler#endif
28b960e451SClemens Zeidler
29b960e451SClemens Zeidler
30106fe8b3SJohn Scipionestatic const rgb_color kFrameColors[4] = {
31106fe8b3SJohn Scipione	{ 152, 152, 152, 255 },
32106fe8b3SJohn Scipione	{ 240, 240, 240, 255 },
33106fe8b3SJohn Scipione	{ 152, 152, 152, 255 },
34106fe8b3SJohn Scipione	{ 108, 108, 108, 255 }
35106fe8b3SJohn Scipione};
36106fe8b3SJohn Scipione
37e3ab8648SIngo Weinholdstatic const rgb_color kHighlightFrameColors[6] = {
38b7a1df80SClemens Zeidler	{ 52, 52, 52, 255 },
39b7a1df80SClemens Zeidler	{ 140, 140, 140, 255 },
40b7a1df80SClemens Zeidler	{ 124, 124, 124, 255 },
41b7a1df80SClemens Zeidler	{ 108, 108, 108, 255 },
42b7a1df80SClemens Zeidler	{ 52, 52, 52, 255 },
43b7a1df80SClemens Zeidler	{ 8, 8, 8, 255 }
44e3ab8648SIngo Weinhold};
45e3ab8648SIngo Weinhold
467f9368caSlooncrazSATDecorator::SATDecorator(DesktopSettings& settings, BRect frame,
477f9368caSlooncraz							Desktop* desktop)
48b960e451SClemens Zeidler	:
497f9368caSlooncraz	DefaultDecorator(settings, frame, desktop)
507ca71ab6SIngo Weinhold{
517ca71ab6SIngo Weinhold}
527ca71ab6SIngo Weinhold
537ca71ab6SIngo Weinhold
547f9368caSlooncrazvoid
557f9368caSlooncrazSATDecorator::UpdateColors(DesktopSettings& settings)
567f9368caSlooncraz{
577f9368caSlooncraz	DefaultDecorator::UpdateColors(settings);
587f9368caSlooncraz
597f9368caSlooncraz	// Called during construction, and during any changes
607f9368caSlooncraz	fHighlightTabColor		= tint_color(fFocusTabColor, B_DARKEN_2_TINT);
617f9368caSlooncraz	fHighlightTabColorLight	= tint_color(fHighlightTabColor,
627f9368caSlooncraz								(B_LIGHTEN_MAX_TINT + B_LIGHTEN_2_TINT) / 2);
637f9368caSlooncraz	fHighlightTabColorBevel	= tint_color(fHighlightTabColor, B_LIGHTEN_2_TINT);
647f9368caSlooncraz	fHighlightTabColorShadow= tint_color(fHighlightTabColor,
657f9368caSlooncraz								(B_DARKEN_1_TINT + B_NO_TINT) / 2);
667f9368caSlooncraz}
677f9368caSlooncraz
687f9368caSlooncraz
69e3ab8648SIngo Weinholdvoid
702b602c73SIngo WeinholdSATDecorator::GetComponentColors(Component component, uint8 highlight,
71bdfe478eSClemens Zeidler	ComponentColors _colors, Decorator::Tab* _tab)
72e3ab8648SIngo Weinhold{
73bdfe478eSClemens Zeidler	DefaultDecorator::Tab* tab = static_cast<DefaultDecorator::Tab*>(_tab);
74ae0218edSAdrien Destugues
75ae0218edSAdrien Destugues	// Get the standard colors from the DefaultDecorator
76ae0218edSAdrien Destugues	DefaultDecorator::GetComponentColors(component, highlight, _colors, tab);
77ae0218edSAdrien Destugues
78ae0218edSAdrien Destugues	// Now we need to make some changes if the Stack and tile highlight is used
79ae0218edSAdrien Destugues	if (highlight != HIGHLIGHT_STACK_AND_TILE)
80bdfe478eSClemens Zeidler		return;
81bdfe478eSClemens Zeidler
82bdfe478eSClemens Zeidler	if (tab && tab->isHighlighted == false
83bdfe478eSClemens Zeidler		&& (component == COMPONENT_TAB || component == COMPONENT_CLOSE_BUTTON
84bdfe478eSClemens Zeidler			|| component == COMPONENT_ZOOM_BUTTON)) {
852b602c73SIngo Weinhold		return;
862b602c73SIngo Weinhold	}
872b602c73SIngo Weinhold
88e3ab8648SIngo Weinhold	switch (component) {
8909b19da8SIngo Weinhold		case COMPONENT_TAB:
90ad110011SIngo Weinhold			_colors[COLOR_TAB_FRAME_LIGHT] = kFrameColors[0];
91ad110011SIngo Weinhold			_colors[COLOR_TAB_FRAME_DARK] = kFrameColors[3];
927f9368caSlooncraz			_colors[COLOR_TAB] = fHighlightTabColor;
937f9368caSlooncraz			_colors[COLOR_TAB_LIGHT] = fHighlightTabColorLight;
947f9368caSlooncraz			_colors[COLOR_TAB_BEVEL] = fHighlightTabColorBevel;
957f9368caSlooncraz			_colors[COLOR_TAB_SHADOW] = fHighlightTabColorShadow;
967f9368caSlooncraz			_colors[COLOR_TAB_TEXT] = fFocusTextColor;
97e3ab8648SIngo Weinhold			break;
98e3ab8648SIngo Weinhold
9906aa76e2SIngo Weinhold		case COMPONENT_CLOSE_BUTTON:
10006aa76e2SIngo Weinhold		case COMPONENT_ZOOM_BUTTON:
1017f9368caSlooncraz			_colors[COLOR_BUTTON] = fHighlightTabColor;
1027f9368caSlooncraz			_colors[COLOR_BUTTON_LIGHT] = fHighlightTabColorLight;
10306aa76e2SIngo Weinhold			break;
10406aa76e2SIngo Weinhold
10509b19da8SIngo Weinhold		case COMPONENT_LEFT_BORDER:
10609b19da8SIngo Weinhold		case COMPONENT_RIGHT_BORDER:
10709b19da8SIngo Weinhold		case COMPONENT_TOP_BORDER:
10809b19da8SIngo Weinhold		case COMPONENT_BOTTOM_BORDER:
10909b19da8SIngo Weinhold		case COMPONENT_RESIZE_CORNER:
110e3ab8648SIngo Weinhold		default:
111e3ab8648SIngo Weinhold			_colors[0] = kHighlightFrameColors[0];
112e3ab8648SIngo Weinhold			_colors[1] = kHighlightFrameColors[1];
113e3ab8648SIngo Weinhold			_colors[2] = kHighlightFrameColors[2];
114e3ab8648SIngo Weinhold			_colors[3] = kHighlightFrameColors[3];
115e3ab8648SIngo Weinhold			_colors[4] = kHighlightFrameColors[4];
116e3ab8648SIngo Weinhold			_colors[5] = kHighlightFrameColors[5];
117e3ab8648SIngo Weinhold			break;
118e3ab8648SIngo Weinhold	}
119e3ab8648SIngo Weinhold}
120e3ab8648SIngo Weinhold
121e3ab8648SIngo Weinhold
12263bf94e2SClemens ZeidlerSATWindowBehaviour::SATWindowBehaviour(Window* window, StackAndTile* sat)
12363bf94e2SClemens Zeidler	:
12463bf94e2SClemens Zeidler	DefaultWindowBehaviour(window),
12563bf94e2SClemens Zeidler
12663bf94e2SClemens Zeidler	fStackAndTile(sat)
12763bf94e2SClemens Zeidler{
12863bf94e2SClemens Zeidler}
12963bf94e2SClemens Zeidler
13063bf94e2SClemens Zeidler
13163bf94e2SClemens Zeidlerbool
13263bf94e2SClemens ZeidlerSATWindowBehaviour::AlterDeltaForSnap(Window* window, BPoint& delta,
13363bf94e2SClemens Zeidler	bigtime_t now)
13463bf94e2SClemens Zeidler{
13563bf94e2SClemens Zeidler	if (DefaultWindowBehaviour::AlterDeltaForSnap(window, delta, now) == true)
13663bf94e2SClemens Zeidler		return true;
13763bf94e2SClemens Zeidler
13863bf94e2SClemens Zeidler	SATWindow* satWindow = fStackAndTile->GetSATWindow(window);
13963bf94e2SClemens Zeidler	if (satWindow == NULL)
14063bf94e2SClemens Zeidler		return false;
14163bf94e2SClemens Zeidler	SATGroup* group = satWindow->GetGroup();
14263bf94e2SClemens Zeidler	if (group == NULL)
14363bf94e2SClemens Zeidler		return false;
14463bf94e2SClemens Zeidler
14563bf94e2SClemens Zeidler	BRect groupFrame = group->WindowAt(0)->CompleteWindowFrame();
14663bf94e2SClemens Zeidler	for (int32 i = 1; i < group->CountItems(); i++)
14763bf94e2SClemens Zeidler		groupFrame = groupFrame | group->WindowAt(i)->CompleteWindowFrame();
14863bf94e2SClemens Zeidler
14933dd44daSClemens Zeidler	return fMagneticBorder.AlterDeltaForSnap(window->Screen(),
15063bf94e2SClemens Zeidler		groupFrame, delta, now);
15163bf94e2SClemens Zeidler}
152