summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-04-01 00:42:33 +0300
committerAndrei Karas <akaras@inbox.ru>2011-04-01 00:42:33 +0300
commit70e506eeae6bde07d0af1f5fb2b2d9797b515c58 (patch)
treeafe33a0b4a3e9854de23ad9b0ca265679946878f /src/gui
parente0803d8066297368d55b297089257a7e857b368a (diff)
downloadmv-70e506eeae6bde07d0af1f5fb2b2d9797b515c58.tar.gz
mv-70e506eeae6bde07d0af1f5fb2b2d9797b515c58.tar.bz2
mv-70e506eeae6bde07d0af1f5fb2b2d9797b515c58.tar.xz
mv-70e506eeae6bde07d0af1f5fb2b2d9797b515c58.zip
Add horisontal and vertical padding for layout object.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/widgets/layout.cpp23
-rw-r--r--src/gui/widgets/layout.h17
2 files changed, 28 insertions, 12 deletions
diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp
index d6204c9f9..ad474cf63 100644
--- a/src/gui/widgets/layout.cpp
+++ b/src/gui/widgets/layout.cpp
@@ -57,7 +57,8 @@ LayoutArray &LayoutCell::getArray()
mType = ARRAY;
mExtent[0] = 1;
mExtent[1] = 1;
- mPadding = 0;
+ mHPadding = 0;
+ mVPadding = 0;
mAlign[0] = FILL;
mAlign[1] = FILL;
return *mArray;
@@ -66,10 +67,10 @@ LayoutArray &LayoutCell::getArray()
void LayoutCell::reflow(int nx, int ny, int nw, int nh)
{
assert(mType != NONE);
- nx += mPadding;
- ny += mPadding;
- nw -= 2 * mPadding;
- nh -= 2 * mPadding;
+ nx += mHPadding;
+ ny += mVPadding;
+ nw -= 2 * mHPadding;
+ nh -= 2 * mVPadding;
if (mType == ARRAY)
mArray->reflow(nx, ny, nw, nh);
else
@@ -202,7 +203,8 @@ LayoutCell &LayoutArray::place(gcn::Widget *widget, int x, int y, int w, int h)
}
cell.mExtent[0] = w;
cell.mExtent[1] = h;
- cell.mPadding = 0;
+ cell.mHPadding = 0;
+ cell.mVPadding = 0;
cell.mAlign[0] = LayoutCell::FILL;
cell.mAlign[1] = LayoutCell::FILL;
int &cs = mSizes[0][x], &rs = mSizes[1][y];
@@ -258,8 +260,9 @@ std::vector<int> LayoutArray::getSizes(int dim, int upp) const
if (cell->mExtent[dim] == 1)
{
int n = (dim == 0 ? gridX : gridY);
- int s = cell->mSize[dim] + cell->mPadding * 2;
- if (s > sizes[n]) sizes[n] = s;
+ int s = cell->mSize[dim] + cell->mVPadding * 2;
+ if (s > sizes[n])
+ sizes[n] = s;
}
}
}
@@ -357,7 +360,7 @@ void Layout::reflow(int &nw, int &nh)
mComputed = true;
}
- nw = (nw == 0 ? mSize[0] + 2 * mPadding : nw);
- nh = (nh == 0 ? mSize[1] + 2 * mPadding : nh);
+ nw = (nw == 0 ? mSize[0] + 2 * mHPadding : nw);
+ nh = (nh == 0 ? mSize[1] + 2 * mVPadding : nh);
LayoutCell::reflow(0, 0, nw, nh);
}
diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h
index 523b77f75..49b4815d7 100644
--- a/src/gui/widgets/layout.h
+++ b/src/gui/widgets/layout.h
@@ -182,7 +182,19 @@ class LayoutCell
* Sets the padding around the cell content.
*/
LayoutCell &setPadding(int p)
- { mPadding = p; return *this; }
+ { mHPadding = p; mVPadding = p; return *this; }
+
+ /**
+ * Sets the vertical padding around the cell content.
+ */
+ LayoutCell &setVPadding(int p)
+ { mVPadding = p; return *this; }
+
+ /**
+ * Sets the horisontal padding around the cell content.
+ */
+ LayoutCell &setHPadding(int p)
+ { mHPadding = p; return *this; }
/**
* Sets the horizontal alignment of the cell content.
@@ -268,7 +280,8 @@ class LayoutCell
void reflow(int nx, int ny, int nw, int nh);
int mSize[2];
- int mPadding;
+ int mHPadding;
+ int mVPadding;
int mExtent[2];
int mAlign[2];
int mNbFill[2];