diff options
author | rathnor <rathnor> | 2003-09-11 13:17:14 (GMT) |
---|---|---|
committer | rathnor <rathnor> | 2003-09-11 13:17:14 (GMT) |
commit | 01af61822de502b9457c975f3ec4015a2619686c (patch) | |
tree | fcca41910a7ef4b02454659598856207bd1fd7a7 /src | |
parent | 7056c000e24960d27dd92d6ddc0466acfb97749b (diff) | |
download | fluxbox-01af61822de502b9457c975f3ec4015a2619686c.zip fluxbox-01af61822de502b9457c975f3ec4015a2619686c.tar.bz2 |
add gravity translate
Diffstat (limited to 'src')
-rw-r--r-- | src/FbWinFrame.cc | 65 | ||||
-rw-r--r-- | src/FbWinFrame.hh | 4 |
2 files changed, 66 insertions, 3 deletions
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index 0d40122..045ca03 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc | |||
@@ -19,7 +19,7 @@ | |||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. | 20 | // DEALINGS IN THE SOFTWARE. |
21 | 21 | ||
22 | // $Id: FbWinFrame.cc,v 1.45 2003/09/10 21:43:54 fluxgen Exp $ | 22 | // $Id: FbWinFrame.cc,v 1.46 2003/09/11 13:17:14 rathnor Exp $ |
23 | 23 | ||
24 | #include "FbWinFrame.hh" | 24 | #include "FbWinFrame.hh" |
25 | 25 | ||
@@ -1106,3 +1106,66 @@ void FbWinFrame::updateTransparent() { | |||
1106 | m_grip_right.updateTransparent(); | 1106 | m_grip_right.updateTransparent(); |
1107 | m_handle.updateTransparent(); | 1107 | m_handle.updateTransparent(); |
1108 | } | 1108 | } |
1109 | |||
1110 | |||
1111 | // this function translates its arguments according to win_gravity | ||
1112 | // if win_gravity is negative, it does an inverse translation | ||
1113 | void FbWinFrame::gravityTranslate(int &x, int &y, int win_gravity, bool move_frame) { | ||
1114 | bool invert = false; | ||
1115 | if (win_gravity < 0) { | ||
1116 | invert = true; | ||
1117 | win_gravity = -win_gravity; // make +ve | ||
1118 | } | ||
1119 | |||
1120 | /* Ok, so, gravity says which point of the frame is put where the | ||
1121 | * corresponding bit of window would have been | ||
1122 | * Thus, x,y always refers to where top left of the WINDOW would be placed | ||
1123 | * but given that we're wrapping it in a frame, we actually place | ||
1124 | * it so that the given reference point is in the same spot as the | ||
1125 | * window's reference point would have been. | ||
1126 | * i.e. east gravity says that the centre of the right hand side of the | ||
1127 | * frame is placed where the centre of the rhs of the window would | ||
1128 | * have been if there was no frame. | ||
1129 | * Hope that makes enough sense. | ||
1130 | * | ||
1131 | * If you get confused with the calculations, draw a picture. | ||
1132 | * | ||
1133 | */ | ||
1134 | |||
1135 | // We calculate offsets based on the gravity and frame aspects | ||
1136 | // and at the end apply those offsets +ve or -ve depending on 'invert' | ||
1137 | |||
1138 | int x_offset = 0; | ||
1139 | int y_offset = 0; | ||
1140 | |||
1141 | // Start with X offset | ||
1142 | switch (win_gravity) { | ||
1143 | case NorthWest: | ||
1144 | case North: | ||
1145 | case NorthEast: | ||
1146 | // no offset, since the top point is still the same | ||
1147 | break; | ||
1148 | case SouthWest: | ||
1149 | case South: | ||
1150 | case SouthEast: | ||
1151 | case Static: | ||
1152 | case Center: | ||
1153 | // window shifted down by height of titlebar | ||
1154 | x_offset -= m_titlebar.height() + m_titlebar.borderWidth(); | ||
1155 | break; | ||
1156 | } | ||
1157 | |||
1158 | // no Y offset, since we don't have a frame down there | ||
1159 | |||
1160 | if (invert) { | ||
1161 | x_offset = -x_offset; | ||
1162 | y_offset = -y_offset; | ||
1163 | } | ||
1164 | |||
1165 | x += x_offset; | ||
1166 | y += y_offset; | ||
1167 | |||
1168 | if (move_frame && (x_offset != 0 || y_offset != 0)) { | ||
1169 | move(x() + x_offset, y() + y_offset); | ||
1170 | } | ||
1171 | } | ||
diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh index e4c5ca2..6906f2a 100644 --- a/src/FbWinFrame.hh +++ b/src/FbWinFrame.hh | |||
@@ -19,7 +19,7 @@ | |||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. | 20 | // DEALINGS IN THE SOFTWARE. |
21 | 21 | ||
22 | // $Id: FbWinFrame.hh,v 1.16 2003/09/11 13:15:58 rathnor Exp $ | 22 | // $Id: FbWinFrame.hh,v 1.17 2003/09/11 13:17:14 rathnor Exp $ |
23 | 23 | ||
24 | #ifndef FBWINFRAME_HH | 24 | #ifndef FBWINFRAME_HH |
25 | #define FBWINFRAME_HH | 25 | #define FBWINFRAME_HH |
@@ -123,7 +123,7 @@ public: | |||
123 | 123 | ||
124 | // this function translates its arguments according to win_gravity | 124 | // this function translates its arguments according to win_gravity |
125 | // if win_gravity is negative, it does an inverse translation | 125 | // if win_gravity is negative, it does an inverse translation |
126 | void gravityTranslate(int &x, int &y, int win_gravity); | 126 | void gravityTranslate(int &x, int &y, int win_gravity, bool move_frame = false); |
127 | 127 | ||
128 | void setBorderWidth(unsigned int borderW); | 128 | void setBorderWidth(unsigned int borderW); |
129 | 129 | ||