1 /* 2 * this file is part of the oxygen gtk engine 3 * Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr> 4 * Copyright (c) 2011 Ruslan Kabatsayev <b7.10110111@gmail.com> 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2 of the License, or( at your option ) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free 18 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, 19 * MA 02110-1301, USA. 20 */ 21 22 #include "oxygenwindecooptions.h" 23 #include "oxygenstyle.h" 24 #include "oxygenwindowshadow.h" 25 26 namespace Oxygen 27 { 28 namespace WinDeco 29 { 30 getMetric(Metric wm)31 gint getMetric(Metric wm) 32 { 33 const int frameBorder(Style::instance().settings().frameBorder()); 34 const bool narrowSpacing(false); // TODO: false -> read configuration 35 const bool compositingActive(false); // TODO: implement check for this 36 const bool hideTitleBar(false); // TODO: implement 37 38 switch (wm) 39 { 40 case BorderLeft: 41 case BorderRight: 42 case BorderBottom: 43 { 44 gint border(0); 45 // for now we think that respectWindowState is always true, 46 // and WM will remove borders for maximized windows by default 47 // TODO: impelement respectWindowState 48 if( wm==BorderBottom && frameBorder >= QtSettings::BorderNoSide ) { 49 50 // for tiny border, the convention is to have a larger bottom area in order to 51 // make resizing easier 52 border = std::max(frameBorder,4); 53 } 54 else if( frameBorder < QtSettings::BorderTiny ) { 55 56 border = 0; 57 } 58 else if( compositingActive && frameBorder == QtSettings::BorderTiny ) { 59 60 border = std::max( frameBorder, 3 ); 61 } 62 else { 63 64 border = frameBorder; 65 } 66 67 return border; 68 } 69 70 case BorderTop: 71 { 72 gint topEdge(0); 73 if( frameBorder == QtSettings::BorderNone && hideTitleBar ) 74 { 75 topEdge=0; 76 } 77 else 78 { 79 topEdge=3; // TFRAMESIZE 80 } 81 82 return Style::instance().settings().buttonSize()+topEdge; 83 } 84 85 case ButtonSpacing: 86 { 87 return ( narrowSpacing ? 1 : 3 ); 88 } 89 90 case ButtonMarginTop: 91 case ButtonMarginBottom: 92 { 93 return 0; 94 } 95 96 case ShadowLeft: 97 case ShadowRight: 98 case ShadowTop: 99 case ShadowBottom: 100 { 101 WindowShadow shadow(Style::instance().settings(), Style::instance().helper()); 102 return int(shadow.shadowSize()-4); 103 } 104 105 default: 106 { 107 // -1 means we don't understand the query 108 return -1; 109 } 110 } 111 } 112 getButtonSize()113 int getButtonSize() 114 { 115 // in oxygen all buttons have the same size 116 return Style::instance().settings().buttonSize(); 117 } 118 } 119 } 120