summaryrefslogtreecommitdiffstats
path: root/ui/views/layout
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-17 12:18:08 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-17 12:18:08 +0000
commit4d08b0ce74cf85382e81f87a6b204c11040b6f67 (patch)
treef9ca40970c48dc9fe40570278cbcedd5e7b8b327 /ui/views/layout
parent89f2916fa0ba8c1c4158ef88baa6a0f2a7354867 (diff)
downloadchromium_src-4d08b0ce74cf85382e81f87a6b204c11040b6f67.zip
chromium_src-4d08b0ce74cf85382e81f87a6b204c11040b6f67.tar.gz
chromium_src-4d08b0ce74cf85382e81f87a6b204c11040b6f67.tar.bz2
views: Change GridLayout to store a gfx::Insets instead of pure integers.
TEST=views_unittests R=sky@chromium.org Review URL: https://codereview.chromium.org/11412009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168403 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views/layout')
-rw-r--r--ui/views/layout/grid_layout.cc22
-rw-r--r--ui/views/layout/grid_layout.h10
2 files changed, 10 insertions, 22 deletions
diff --git a/ui/views/layout/grid_layout.cc b/ui/views/layout/grid_layout.cc
index f30cc45..b257201 100644
--- a/ui/views/layout/grid_layout.cc
+++ b/ui/views/layout/grid_layout.cc
@@ -662,10 +662,6 @@ GridLayout::GridLayout(View* host)
current_row_(-1),
next_column_(0),
current_row_col_set_(NULL),
- top_inset_(0),
- bottom_inset_(0),
- left_inset_(0),
- right_inset_(0),
adding_view_(false) {
DCHECK(host);
}
@@ -685,14 +681,11 @@ GridLayout* GridLayout::CreatePanel(View* host) {
}
void GridLayout::SetInsets(int top, int left, int bottom, int right) {
- top_inset_ = top;
- bottom_inset_ = bottom;
- left_inset_ = left;
- right_inset_ = right;
+ insets_.Set(top, left, bottom, right);
}
void GridLayout::SetInsets(const gfx::Insets& insets) {
- SetInsets(insets.top(), insets.left(), insets.bottom(), insets.right());
+ insets_ = insets;
}
ColumnSet* GridLayout::AddColumnSet(int id) {
@@ -822,12 +815,12 @@ void GridLayout::Layout(View* host) {
View* view = (*i)->view;
DCHECK(view);
int x = column_set->columns_[view_state->start_col]->Location() +
- left_inset_;
+ insets_.left();
int width = column_set->GetColumnWidth(view_state->start_col,
view_state->col_span);
CalculateSize(view_state->pref_width, view_state->h_align,
&x, &width);
- int y = rows_[view_state->start_row]->Location() + top_inset_;
+ int y = rows_[view_state->start_row]->Location() + insets_.top();
int height = LayoutElement::TotalSize(view_state->start_row,
view_state->row_span, &rows_);
if (view_state->v_align == BASELINE && view_state->baseline != -1) {
@@ -872,14 +865,15 @@ void GridLayout::SizeRowsAndColumns(bool layout, int width, int height,
(*i)->CalculateSize();
pref->set_width(std::max(pref->width(), (*i)->LayoutWidth()));
}
- pref->set_width(pref->width() + left_inset_ + right_inset_);
+ pref->set_width(pref->width() + insets_.width());
// Go over the columns again and set them all to the size we settled for.
width = width ? width : pref->width();
for (std::vector<ColumnSet*>::iterator i = column_sets_.begin();
i != column_sets_.end(); ++i) {
// We're doing a layout, divy up any extra space.
- (*i)->Resize(width - (*i)->LayoutWidth() - left_inset_ - right_inset_);
+ (*i)->Resize(width - (*i)->LayoutWidth() - insets_.left() -
+ insets_.right());
// And reset the x coordinates.
(*i)->ResetColumnXCoordinates();
}
@@ -949,7 +943,7 @@ void GridLayout::SizeRowsAndColumns(bool layout, int width, int height,
// We now know the preferred height, set it here.
pref->set_height(rows_[rows_.size() - 1]->Location() +
- rows_[rows_.size() - 1]->Size() + top_inset_ + bottom_inset_);
+ rows_[rows_.size() - 1]->Size() + insets_.height());
if (layout && height != pref->height()) {
// We're doing a layout, and the height differs from the preferred height,
diff --git a/ui/views/layout/grid_layout.h b/ui/views/layout/grid_layout.h
index 44ca26a..f026eb7 100644
--- a/ui/views/layout/grid_layout.h
+++ b/ui/views/layout/grid_layout.h
@@ -9,13 +9,10 @@
#include <vector>
#include "base/compiler_specific.h"
+#include "ui/gfx/insets.h"
#include "ui/views/layout/layout_manager.h"
#include "ui/views/view.h"
-namespace gfx {
-class Insets;
-}
-
// GridLayout is a LayoutManager that positions child Views in a grid. You
// define the structure of the Grid first, then add the Views.
// The following creates a trivial grid with two columns separated by
@@ -241,10 +238,7 @@ class VIEWS_EXPORT GridLayout : public LayoutManager {
ColumnSet* current_row_col_set_;
// Insets.
- int top_inset_;
- int bottom_inset_;
- int left_inset_;
- int right_inset_;
+ gfx::Insets insets_;
// Set to true when adding a View.
bool adding_view_;