Generally, clean up new archiving constant names & strings to be consistent in all classes. Modify archiving constants to be const char* const (thanks Ingo). Also modify archiving in many classes to use less fields by storing more data in arrays and structs. The common min, max, and preferred sizes, for example are always stored in an array now. In BTwoDimensionalLayout and BSplitLayout, the insets are archived in a BRect. Also fixed a typo in BGridLayout which caused column info to be incorrect during archival.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37777 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -12,10 +12,9 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const char* kMinSizeField = "BAbstractLayoutItem:minSize";
|
const char* const kSizesField = "BAbstractLayoutItem:sizes";
|
||||||
const char* kMaxSizeField = "BAbstractLayoutItem:maxSize";
|
// kSizesField == {min, max, preferred}
|
||||||
const char* kPreferredSizeField = "BAbstractLayoutItem:preferredSize";
|
const char* const kAlignmentField = "BAbstractLayoutItem:alignment";
|
||||||
const char* kAlignmentField = "BAbstractLayoutItem:alignment";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -37,9 +36,9 @@ BAbstractLayoutItem::BAbstractLayoutItem(BMessage* from)
|
|||||||
fPreferredSize(),
|
fPreferredSize(),
|
||||||
fAlignment()
|
fAlignment()
|
||||||
{
|
{
|
||||||
from->FindSize(kMinSizeField, &fMinSize);
|
from->FindSize(kSizesField, 0, &fMinSize);
|
||||||
from->FindSize(kMaxSizeField, &fMaxSize);
|
from->FindSize(kSizesField, 1, &fMaxSize);
|
||||||
from->FindSize(kPreferredSizeField, &fPreferredSize);
|
from->FindSize(kSizesField, 2, &fPreferredSize);
|
||||||
from->FindAlignment(kAlignmentField, &fAlignment);
|
from->FindAlignment(kAlignmentField, &fAlignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,13 +139,13 @@ BAbstractLayoutItem::Archive(BMessage* into, bool deep) const
|
|||||||
status_t err = BLayoutItem::Archive(into, deep);
|
status_t err = BLayoutItem::Archive(into, deep);
|
||||||
|
|
||||||
if (err == B_OK)
|
if (err == B_OK)
|
||||||
err = into->AddSize(kMinSizeField, fMinSize);
|
err = into->AddSize(kSizesField, fMinSize);
|
||||||
|
|
||||||
if (err == B_OK)
|
if (err == B_OK)
|
||||||
err = into->AddSize(kMaxSizeField, fMaxSize);
|
err = into->AddSize(kSizesField, fMaxSize);
|
||||||
|
|
||||||
if (err == B_OK)
|
if (err == B_OK)
|
||||||
err = into->AddSize(kPreferredSizeField, fPreferredSize);
|
err = into->AddSize(kSizesField, fPreferredSize);
|
||||||
|
|
||||||
if (err == B_OK)
|
if (err == B_OK)
|
||||||
err = into->AddAlignment(kAlignmentField, fAlignment);
|
err = into->AddAlignment(kAlignmentField, fAlignment);
|
||||||
|
|||||||
@@ -31,18 +31,14 @@ namespace {
|
|||||||
// a placeholder we put in our grid array to make a cell occupied
|
// a placeholder we put in our grid array to make a cell occupied
|
||||||
BLayoutItem* const OCCUPIED_GRID_CELL = (BLayoutItem*)0x1;
|
BLayoutItem* const OCCUPIED_GRID_CELL = (BLayoutItem*)0x1;
|
||||||
|
|
||||||
const char* kRowCountField = "gridlayout:rowcount";
|
const char* const kRowSizesField = "BGridLayout:rowsizes";
|
||||||
const char* kRowMinSizeField = "gridlayout:rowminsize";
|
// kRowSizesField = {min, max}
|
||||||
const char* kRowMaxSizeField = "gridlayout:rowmaxsize";
|
const char* const kRowWeightField = "BGridLayout:rowweight";
|
||||||
const char* kRowWeightField = "gridlayout:rowweight";
|
const char* const kColumnSizesField = "BGridLayout:columnsizes";
|
||||||
const char* kColumnCountField = "gridlayout:columncount";
|
// kColumnSizesField = {min, max}
|
||||||
const char* kColumnMinSizeField = "gridlayout:columnminsize";
|
const char* const kColumnWeightField = "BGridLayout:columnweight";
|
||||||
const char* kColumnMaxSizeField = "gridlayout:columnmaxsize";
|
const char* const kItemDimensionsField = "BGridLayout:item:dimensions";
|
||||||
const char* kColumnWeightField = "gridlayout:columnweight";
|
// kItemDimensionsField = {x, y, width, height}
|
||||||
const char* kItemHeight = "gridlayout:item:height";
|
|
||||||
const char* kItemWidth = "gridlayout:item:width";
|
|
||||||
const char* kItemX = "gridlayout:item:x";
|
|
||||||
const char* kItemY = "gridlayout:item:y";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -179,15 +175,12 @@ BGridLayout::BGridLayout(BMessage* from)
|
|||||||
fMultiColumnItems(0),
|
fMultiColumnItems(0),
|
||||||
fMultiRowItems(0)
|
fMultiRowItems(0)
|
||||||
{
|
{
|
||||||
int32 rows;
|
|
||||||
int32 columns;
|
|
||||||
BUnarchiver unarchiver(from);
|
BUnarchiver unarchiver(from);
|
||||||
|
int32 columns;
|
||||||
|
from->GetInfo(kColumnWeightField, NULL, &columns);
|
||||||
|
|
||||||
if (from->FindInt32(kRowCountField, &rows) != B_OK)
|
int32 rows;
|
||||||
fRowCount = 0;
|
from->GetInfo(kRowWeightField, NULL, &rows);
|
||||||
|
|
||||||
if (from->FindInt32(kColumnCountField, &columns) != B_OK)
|
|
||||||
fColumnCount = 0;
|
|
||||||
|
|
||||||
// sets fColumnCount && fRowCount on success
|
// sets fColumnCount && fRowCount on success
|
||||||
if (!_ResizeGrid(columns, rows)) {
|
if (!_ResizeGrid(columns, rows)) {
|
||||||
@@ -200,10 +193,10 @@ BGridLayout::BGridLayout(BMessage* from)
|
|||||||
if (from->FindFloat(kRowWeightField, i, &getter) == B_OK)
|
if (from->FindFloat(kRowWeightField, i, &getter) == B_OK)
|
||||||
fRowInfos->SetWeight(i, getter);
|
fRowInfos->SetWeight(i, getter);
|
||||||
|
|
||||||
if (from->FindFloat(kRowMinSizeField, i, &getter) == B_OK)
|
if (from->FindFloat(kRowSizesField, i * 2, &getter) == B_OK)
|
||||||
fRowInfos->SetMinSize(i, getter);
|
fRowInfos->SetMinSize(i, getter);
|
||||||
|
|
||||||
if (from->FindFloat(kRowMaxSizeField, i, &getter) == B_OK)
|
if (from->FindFloat(kRowSizesField, i * 2 + 1, &getter) == B_OK)
|
||||||
fRowInfos->SetMaxSize(i, getter);
|
fRowInfos->SetMaxSize(i, getter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,10 +205,10 @@ BGridLayout::BGridLayout(BMessage* from)
|
|||||||
if (from->FindFloat(kColumnWeightField, i, &getter) == B_OK)
|
if (from->FindFloat(kColumnWeightField, i, &getter) == B_OK)
|
||||||
fColumnInfos->SetWeight(i, getter);
|
fColumnInfos->SetWeight(i, getter);
|
||||||
|
|
||||||
if (from->FindFloat(kColumnMinSizeField, i, &getter) == B_OK)
|
if (from->FindFloat(kColumnSizesField, i * 2, &getter) == B_OK)
|
||||||
fColumnInfos->SetMinSize(i, getter);
|
fColumnInfos->SetMinSize(i, getter);
|
||||||
|
|
||||||
if (from->FindFloat(kColumnMaxSizeField, i, &getter) == B_OK)
|
if (from->FindFloat(kColumnSizesField, i * 2 + 1, &getter) == B_OK)
|
||||||
fColumnInfos->SetMaxSize(i, getter);
|
fColumnInfos->SetMaxSize(i, getter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -467,25 +460,20 @@ BGridLayout::Archive(BMessage* into, bool deep) const
|
|||||||
BArchiver archiver(into);
|
BArchiver archiver(into);
|
||||||
status_t err = BTwoDimensionalLayout::Archive(into, deep);
|
status_t err = BTwoDimensionalLayout::Archive(into, deep);
|
||||||
|
|
||||||
if (err == B_OK)
|
|
||||||
err = into->AddInt32(kRowCountField, fRowCount);
|
|
||||||
if (err == B_OK)
|
|
||||||
err = into->AddInt32(kColumnCountField, fColumnCount);
|
|
||||||
|
|
||||||
for (int32 i = 0; i < fRowCount && err == B_OK; i++) {
|
for (int32 i = 0; i < fRowCount && err == B_OK; i++) {
|
||||||
err = into->AddFloat(kRowWeightField, fRowInfos->Weight(i));
|
err = into->AddFloat(kRowWeightField, fRowInfos->Weight(i));
|
||||||
if (err == B_OK)
|
if (err == B_OK)
|
||||||
err = into->AddFloat(kRowMinSizeField, fRowInfos->MinSize(i));
|
err = into->AddFloat(kRowSizesField, fRowInfos->MinSize(i));
|
||||||
if (err == B_OK)
|
if (err == B_OK)
|
||||||
err = into->AddFloat(kRowMaxSizeField, fRowInfos->MaxSize(i));
|
err = into->AddFloat(kRowSizesField, fRowInfos->MaxSize(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32 i = 0; i < fColumnCount && err == B_OK; i++) {
|
for (int32 i = 0; i < fColumnCount && err == B_OK; i++) {
|
||||||
err = into->AddFloat(kColumnWeightField, fRowInfos->Weight(i));
|
err = into->AddFloat(kColumnWeightField, fColumnInfos->Weight(i));
|
||||||
if (err == B_OK)
|
if (err == B_OK)
|
||||||
err = into->AddFloat(kColumnMinSizeField, fRowInfos->MinSize(i));
|
err = into->AddFloat(kColumnSizesField, fColumnInfos->MinSize(i));
|
||||||
if (err == B_OK)
|
if (err == B_OK)
|
||||||
err = into->AddFloat(kColumnMaxSizeField, fRowInfos->MaxSize(i));
|
err = into->AddFloat(kColumnSizesField, fColumnInfos->MaxSize(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
return archiver.Finish(err);
|
return archiver.Finish(err);
|
||||||
@@ -508,13 +496,13 @@ BGridLayout::ItemArchived(BMessage* into, BLayoutItem* item, int32 index) const
|
|||||||
if (!data) // TODO: remove this check once AddItem() returns a bool
|
if (!data) // TODO: remove this check once AddItem() returns a bool
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
status_t err = into->AddInt32(kItemX, data->dimensions.x);
|
status_t err = into->AddInt32(kItemDimensionsField, data->dimensions.x);
|
||||||
if (err == B_OK)
|
if (err == B_OK)
|
||||||
err = into->AddInt32(kItemY, data->dimensions.y);
|
err = into->AddInt32(kItemDimensionsField, data->dimensions.y);
|
||||||
if (err == B_OK)
|
if (err == B_OK)
|
||||||
err = into->AddInt32(kItemWidth, data->dimensions.width);
|
err = into->AddInt32(kItemDimensionsField, data->dimensions.width);
|
||||||
if (err == B_OK)
|
if (err == B_OK)
|
||||||
err = into->AddInt32(kItemHeight, data->dimensions.height);
|
err = into->AddInt32(kItemDimensionsField, data->dimensions.height);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@@ -531,26 +519,33 @@ BGridLayout::ItemUnarchived(const BMessage* from,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Dimensions& dimensions = data->dimensions;
|
Dimensions& dimensions = data->dimensions;
|
||||||
status_t err = from->FindInt32(kItemX, index, &dimensions.x);
|
index *= 4;
|
||||||
|
// each item stores 4 int32s into kItemDimensionsField
|
||||||
|
status_t err = from->FindInt32(kItemDimensionsField, index, &dimensions.x);
|
||||||
if (err == B_OK)
|
if (err == B_OK)
|
||||||
err = from->FindInt32(kItemY, index, &dimensions.y);
|
err = from->FindInt32(kItemDimensionsField, ++index, &dimensions.y);
|
||||||
|
|
||||||
if (err == B_OK)
|
if (err == B_OK)
|
||||||
err = from->FindInt32(kItemWidth, index, &dimensions.width);
|
err = from->FindInt32(kItemDimensionsField, ++index, &dimensions.width);
|
||||||
|
|
||||||
if (err == B_OK)
|
if (err == B_OK) {
|
||||||
err = from->FindInt32(kItemHeight, index, &dimensions.height);
|
err = from->FindInt32(kItemDimensionsField,
|
||||||
|
++index, &dimensions.height);
|
||||||
|
}
|
||||||
|
|
||||||
if (err == B_OK && !_AreGridCellsEmpty(dimensions.x, dimensions.y,
|
if (err != B_OK)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
if (!_AreGridCellsEmpty(dimensions.x, dimensions.y,
|
||||||
dimensions.width, dimensions.height))
|
dimensions.width, dimensions.height))
|
||||||
err = B_BAD_DATA;
|
return B_BAD_DATA;
|
||||||
|
|
||||||
if (err == B_OK && !_InsertItemIntoGrid(item))
|
if (!_InsertItemIntoGrid(item))
|
||||||
err = B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
if (err == B_OK && dimensions.width > 1)
|
if (dimensions.width > 1)
|
||||||
fMultiColumnItems++;
|
fMultiColumnItems++;
|
||||||
if (err == B_OK && dimensions.height > 1)
|
if (dimensions.height > 1)
|
||||||
fMultiRowItems++;
|
fMultiRowItems++;
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const char* kWeightField = "BGroupLayoutData:weight";
|
const char* const kItemWeightField = "BGroupLayout:item:weight";
|
||||||
const char* kVerticalField = "BGroupLayout:vertical";
|
const char* const kVerticalField = "BGroupLayout:vertical";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -219,7 +219,7 @@ BGroupLayout::ItemArchived(BMessage* into,
|
|||||||
if (!data) // TODO: remove this once ItemAdded() returns a bool
|
if (!data) // TODO: remove this once ItemAdded() returns a bool
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
return into->AddFloat(kWeightField, data->weight);
|
return into->AddFloat(kItemWeightField, data->weight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -228,7 +228,7 @@ BGroupLayout::ItemUnarchived(const BMessage* from,
|
|||||||
BLayoutItem* item, int32 index)
|
BLayoutItem* item, int32 index)
|
||||||
{
|
{
|
||||||
float weight;
|
float weight;
|
||||||
status_t err = from->FindFloat(kWeightField, index, &weight);
|
status_t err = from->FindFloat(kItemWeightField, index, &weight);
|
||||||
|
|
||||||
if (err == B_OK)
|
if (err == B_OK)
|
||||||
_LayoutDataForItem(item)->weight = weight;
|
_LayoutDataForItem(item)->weight = weight;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
using std::nothrow;
|
using std::nothrow;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const char* kLayoutItemField = "BLayout:_items";
|
const char* const kLayoutItemField = "BLayout:items";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,12 +13,11 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const char* kMinSizeField = "BSpaceLayoutItem:minsize";
|
const char* const kSizesField = "BSpaceLayoutItem:sizes";
|
||||||
const char* kMaxSizeField = "BSpaceLayoutItem:maxsize";
|
// kSizesField = {min, max, preferred}
|
||||||
const char* kPreferredSizeField = "BSpaceLayoutItem:prefsize";
|
const char* const kAlignmentField = "BSpaceLayoutItem:alignment";
|
||||||
const char* kAlignmentField = "BSpaceLayoutItem:alignment";
|
const char* const kFrameField = "BSpaceLayoutItem:frame";
|
||||||
const char* kFrameField = "BSpaceLayoutItem:frame";
|
const char* const kVisibleField = "BSpaceLayoutItem:visible";
|
||||||
const char* kVisibleField = "BSpaceLayoutItem:visible";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -39,9 +38,9 @@ BSpaceLayoutItem::BSpaceLayoutItem(BMessage* archive)
|
|||||||
:
|
:
|
||||||
BLayoutItem(archive)
|
BLayoutItem(archive)
|
||||||
{
|
{
|
||||||
archive->FindSize(kMinSizeField, &fMinSize);
|
archive->FindSize(kSizesField, 0, &fMinSize);
|
||||||
archive->FindSize(kMaxSizeField, &fMaxSize);
|
archive->FindSize(kSizesField, 1, &fMaxSize);
|
||||||
archive->FindSize(kPreferredSizeField, &fPreferredSize);
|
archive->FindSize(kSizesField, 2, &fPreferredSize);
|
||||||
|
|
||||||
archive->FindAlignment(kAlignmentField, &fAlignment);
|
archive->FindAlignment(kAlignmentField, &fAlignment);
|
||||||
|
|
||||||
@@ -201,13 +200,13 @@ BSpaceLayoutItem::Archive(BMessage* into, bool deep) const
|
|||||||
err = into->AddRect(kFrameField, fFrame);
|
err = into->AddRect(kFrameField, fFrame);
|
||||||
|
|
||||||
if (err == B_OK)
|
if (err == B_OK)
|
||||||
err = into->AddSize(kMinSizeField, fMinSize);
|
err = into->AddSize(kSizesField, fMinSize);
|
||||||
|
|
||||||
if (err == B_OK)
|
if (err == B_OK)
|
||||||
err = into->AddSize(kMaxSizeField, fMaxSize);
|
err = into->AddSize(kSizesField, fMaxSize);
|
||||||
|
|
||||||
if (err == B_OK)
|
if (err == B_OK)
|
||||||
err = into->AddSize(kPreferredSizeField, fPreferredSize);
|
err = into->AddSize(kSizesField, fPreferredSize);
|
||||||
|
|
||||||
if (err == B_OK)
|
if (err == B_OK)
|
||||||
err = into->AddAlignment(kAlignmentField, fAlignment);
|
err = into->AddAlignment(kAlignmentField, fAlignment);
|
||||||
|
|||||||
@@ -20,15 +20,12 @@
|
|||||||
|
|
||||||
// archivng constants
|
// archivng constants
|
||||||
namespace {
|
namespace {
|
||||||
const char* kInfoCollapsibleField = "BSplitLayout::info::collapsible";
|
const char* const kItemCollapsibleField = "BSplitLayout:item:collapsible";
|
||||||
const char* kInfoWeightField = "BSplitLayout::info::weight";
|
const char* const kItemWeightField = "BSplitLayout:item:weight";
|
||||||
const char* kSpacingField = "BSplitLayout::spacing";
|
const char* const kSpacingField = "BSplitLayout:spacing";
|
||||||
const char* kSplitterSizeField = "BSplitLayout::splitterSize";
|
const char* const kSplitterSizeField = "BSplitLayout:splitterSize";
|
||||||
const char* kIsVerticalField = "BSplitLayout::vertical";
|
const char* const kIsVerticalField = "BSplitLayout:vertical";
|
||||||
const char* kTopInsetField = "BSplitLayout::TopInset";
|
const char* const kInsetsField = "BSplitLayout:insets";
|
||||||
const char* kBottomInsetField = "BSplitLayout::BottomInset";
|
|
||||||
const char* kLeftInsetField = "BSplitLayout::LeftInset";
|
|
||||||
const char* kRightInsetField = "BSplitLayout::RightInset";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -196,7 +193,7 @@ BSplitLayout::BSplitLayout(enum orientation orientation,
|
|||||||
|
|
||||||
BSplitLayout::BSplitLayout(BMessage* from)
|
BSplitLayout::BSplitLayout(BMessage* from)
|
||||||
:
|
:
|
||||||
BLayout(from),
|
BLayout(BUnarchiver::PrepareArchive(from)),
|
||||||
fSplitterItems(),
|
fSplitterItems(),
|
||||||
fVisibleItems(),
|
fVisibleItems(),
|
||||||
fMin(),
|
fMin(),
|
||||||
@@ -225,16 +222,29 @@ BSplitLayout::BSplitLayout(BMessage* from)
|
|||||||
fDraggingCurrentValue(0),
|
fDraggingCurrentValue(0),
|
||||||
fDraggingSplitterIndex(-1)
|
fDraggingSplitterIndex(-1)
|
||||||
{
|
{
|
||||||
|
BUnarchiver unarchiver(from);
|
||||||
|
|
||||||
bool isVertical;
|
bool isVertical;
|
||||||
from->FindBool(kIsVerticalField, &isVertical);
|
status_t err = from->FindBool(kIsVerticalField, &isVertical);
|
||||||
|
if (err != B_OK) {
|
||||||
|
unarchiver.Finish(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
fOrientation = (isVertical) ? B_VERTICAL : B_HORIZONTAL ;
|
fOrientation = (isVertical) ? B_VERTICAL : B_HORIZONTAL ;
|
||||||
|
|
||||||
from->FindFloat(kLeftInsetField, &fLeftInset);
|
BRect insets;
|
||||||
from->FindFloat(kRightInsetField, &fRightInset);
|
err = from->FindRect(kInsetsField, &insets);
|
||||||
from->FindFloat(kTopInsetField, &fTopInset);
|
if (err != B_OK) {
|
||||||
from->FindFloat(kBottomInsetField, &fBottomInset);
|
unarchiver.Finish(err);
|
||||||
from->FindFloat(kSplitterSizeField, &fSplitterSize);
|
return;
|
||||||
from->FindFloat(kSpacingField, &fSpacing);
|
}
|
||||||
|
SetInsets(insets.left, insets.top, insets.right, insets.bottom);
|
||||||
|
|
||||||
|
err = from->FindFloat(kSplitterSizeField, &fSplitterSize);
|
||||||
|
if (err == B_OK)
|
||||||
|
err = from->FindFloat(kSpacingField, &fSpacing);
|
||||||
|
|
||||||
|
unarchiver.Finish(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -702,19 +712,12 @@ BSplitLayout::Archive(BMessage* into, bool deep) const
|
|||||||
status_t err = BLayout::Archive(into, deep);
|
status_t err = BLayout::Archive(into, deep);
|
||||||
|
|
||||||
if (err == B_OK)
|
if (err == B_OK)
|
||||||
into->AddBool(kIsVerticalField, fOrientation == B_VERTICAL);
|
err = into->AddBool(kIsVerticalField, fOrientation == B_VERTICAL);
|
||||||
|
|
||||||
if (err == B_OK)
|
if (err == B_OK) {
|
||||||
err = into->AddFloat(kLeftInsetField, fLeftInset);
|
BRect insets(fLeftInset, fTopInset, fRightInset, fBottomInset);
|
||||||
|
err = into->AddRect(kInsetsField, insets);
|
||||||
if (err == B_OK)
|
}
|
||||||
err = into->AddFloat(kRightInsetField, fRightInset);
|
|
||||||
|
|
||||||
if (err == B_OK)
|
|
||||||
err = into->AddFloat(kTopInsetField, fTopInset);
|
|
||||||
|
|
||||||
if (err == B_OK)
|
|
||||||
err = into->AddFloat(kBottomInsetField, fBottomInset);
|
|
||||||
|
|
||||||
if (err == B_OK)
|
if (err == B_OK)
|
||||||
err = into->AddFloat(kSplitterSizeField, fSplitterSize);
|
err = into->AddFloat(kSplitterSizeField, fSplitterSize);
|
||||||
@@ -743,9 +746,9 @@ BSplitLayout::ItemArchived(BMessage* into, BLayoutItem* item, int32 index) const
|
|||||||
if (!info) // TODO: remove this check when AddItem() returns a bool
|
if (!info) // TODO: remove this check when AddItem() returns a bool
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
status_t err = into->AddFloat(kInfoWeightField, info->weight);
|
status_t err = into->AddFloat(kItemWeightField, info->weight);
|
||||||
if (err == B_OK)
|
if (err == B_OK)
|
||||||
err = into->AddBool(kInfoCollapsibleField, info->isCollapsible);
|
err = into->AddBool(kItemCollapsibleField, info->isCollapsible);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@@ -756,11 +759,11 @@ BSplitLayout::ItemUnarchived(const BMessage* from,
|
|||||||
BLayoutItem* item, int32 index)
|
BLayoutItem* item, int32 index)
|
||||||
{
|
{
|
||||||
ItemLayoutInfo* info = _ItemLayoutInfo(item);
|
ItemLayoutInfo* info = _ItemLayoutInfo(item);
|
||||||
status_t err = from->FindFloat(kInfoWeightField, index, &info->weight);
|
status_t err = from->FindFloat(kItemWeightField, index, &info->weight);
|
||||||
|
|
||||||
if (err == B_OK) {
|
if (err == B_OK) {
|
||||||
bool* collapsible = &info->isCollapsible;
|
bool* collapsible = &info->isCollapsible;
|
||||||
err = from->FindBool(kInfoCollapsibleField, index, collapsible);
|
err = from->FindBool(kItemCollapsibleField, index, collapsible);
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,11 +22,6 @@
|
|||||||
#include "SimpleLayouter.h"
|
#include "SimpleLayouter.h"
|
||||||
|
|
||||||
|
|
||||||
// Archiving constants
|
|
||||||
namespace {
|
|
||||||
const char* kHAlignedLayoutField = "B2DLayout:halignedlayout";
|
|
||||||
const char* kVAlignedLayoutField = "B2DLayout:valignedlayout";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Some words of explanation:
|
// Some words of explanation:
|
||||||
@@ -238,12 +233,13 @@ private:
|
|||||||
|
|
||||||
// archiving constants
|
// archiving constants
|
||||||
namespace {
|
namespace {
|
||||||
const char* kLeftInsetField = "B2Dlayout:leftInset";
|
const char* const kHAlignedLayoutField = "BTwoDimensionalLayout:"
|
||||||
const char* kRightInsetField = "B2Dlayout:rightInset";
|
"halignedlayout";
|
||||||
const char* kTopInsetField = "B2Dlayout:topInset";
|
const char* const kVAlignedLayoutField = "BTwoDimensionalLayout:"
|
||||||
const char* kBottomInsetField = "B2Dlayout:bottomInset";
|
"valignedlayout";
|
||||||
const char* kHSpacingField = "B2Dlayout:hspacing";
|
const char* const kInsetsField = "BTwoDimensionalLayout:insets";
|
||||||
const char* kVSpacingField = "B2Dlayout:vspacing";
|
const char* const kSpacingField = "BTwoDimensionalLayout:spacing";
|
||||||
|
// kSpacingField = {fHSpacing, fVSpacing}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -271,18 +267,12 @@ BTwoDimensionalLayout::BTwoDimensionalLayout(BMessage* from)
|
|||||||
fVSpacing(0),
|
fVSpacing(0),
|
||||||
fLocalLayouter(new LocalLayouter(this))
|
fLocalLayouter(new LocalLayouter(this))
|
||||||
{
|
{
|
||||||
float leftInset;
|
BRect insets;
|
||||||
float rightInset;
|
from->FindRect(kInsetsField, &insets);
|
||||||
float topInset;
|
SetInsets(insets.left, insets.top, insets.right, insets.bottom);
|
||||||
float bottomInset;
|
|
||||||
if (from->FindFloat(kLeftInsetField, &leftInset) == B_OK
|
|
||||||
&& from->FindFloat(kRightInsetField, &rightInset) == B_OK
|
|
||||||
&& from->FindFloat(kTopInsetField, &topInset) == B_OK
|
|
||||||
&& from->FindFloat(kBottomInsetField, &bottomInset) == B_OK)
|
|
||||||
SetInsets(leftInset, topInset, rightInset, bottomInset);
|
|
||||||
|
|
||||||
from->FindFloat(kHSpacingField, &fHSpacing);
|
from->FindFloat(kSpacingField, 0, &fHSpacing);
|
||||||
from->FindFloat(kVSpacingField, &fVSpacing);
|
from->FindFloat(kSpacingField, 1, &fVSpacing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -454,23 +444,16 @@ BTwoDimensionalLayout::Archive(BMessage* into, bool deep) const
|
|||||||
BArchiver archiver(into);
|
BArchiver archiver(into);
|
||||||
status_t err = BLayout::Archive(into, deep);
|
status_t err = BLayout::Archive(into, deep);
|
||||||
|
|
||||||
if (err == B_OK)
|
if (err == B_OK) {
|
||||||
err = into->AddFloat(kLeftInsetField, fLeftInset);
|
BRect insets(fLeftInset, fTopInset, fRightInset, fBottomInset);
|
||||||
|
err = into->AddRect(kInsetsField, insets);
|
||||||
|
}
|
||||||
|
|
||||||
if (err == B_OK)
|
if (err == B_OK)
|
||||||
err = into->AddFloat(kRightInsetField, fRightInset);
|
err = into->AddFloat(kSpacingField, fHSpacing);
|
||||||
|
|
||||||
if (err == B_OK)
|
if (err == B_OK)
|
||||||
err = into->AddFloat(kTopInsetField, fTopInset);
|
err = into->AddFloat(kSpacingField, fVSpacing);
|
||||||
|
|
||||||
if (err == B_OK)
|
|
||||||
err = into->AddFloat(kBottomInsetField, fBottomInset);
|
|
||||||
|
|
||||||
if (err == B_OK)
|
|
||||||
err = into->AddFloat(kHSpacingField, fHSpacing);
|
|
||||||
|
|
||||||
if (err == B_OK)
|
|
||||||
err = into->AddFloat(kVSpacingField, fVSpacing);
|
|
||||||
|
|
||||||
return archiver.Finish(err);
|
return archiver.Finish(err);
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-14
@@ -318,10 +318,10 @@ ViewState::UpdateFrom(BPrivate::PortLink &link)
|
|||||||
|
|
||||||
// archiving constants
|
// archiving constants
|
||||||
namespace {
|
namespace {
|
||||||
const char* kMinSizeField = "ViewLayoutData:minsize";
|
const char* const kSizesField = "BView:sizes";
|
||||||
const char* kMaxSizeField = "ViewLayoutData:maxsize";
|
// kSizesField = {min, max, pref}
|
||||||
const char* kPreferredSizeField = "ViewLayoutData:prefsize";
|
const char* const kAlignmentField = "BView:alignment";
|
||||||
const char* kAlignmentField = "ViewLayoutData:alignment";
|
const char* const kLayoutField = "BView:layout";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -345,13 +345,13 @@ struct BView::LayoutData {
|
|||||||
status_t
|
status_t
|
||||||
AddDataToArchive(BMessage* archive)
|
AddDataToArchive(BMessage* archive)
|
||||||
{
|
{
|
||||||
status_t err = archive->AddSize(kMinSizeField, fMinSize);
|
status_t err = archive->AddSize(kSizesField, fMinSize);
|
||||||
|
|
||||||
if (err == B_OK)
|
if (err == B_OK)
|
||||||
err = archive->AddSize(kMaxSizeField, fMaxSize);
|
err = archive->AddSize(kSizesField, fMaxSize);
|
||||||
|
|
||||||
if (err == B_OK)
|
if (err == B_OK)
|
||||||
err = archive->AddSize(kPreferredSizeField, fPreferredSize);
|
err = archive->AddSize(kSizesField, fPreferredSize);
|
||||||
|
|
||||||
if (err == B_OK)
|
if (err == B_OK)
|
||||||
err = archive->AddAlignment(kAlignmentField, fAlignment);
|
err = archive->AddAlignment(kAlignmentField, fAlignment);
|
||||||
@@ -362,9 +362,9 @@ struct BView::LayoutData {
|
|||||||
void
|
void
|
||||||
PopulateFromArchive(BMessage* archive)
|
PopulateFromArchive(BMessage* archive)
|
||||||
{
|
{
|
||||||
archive->FindSize(kMinSizeField, &fMinSize);
|
archive->FindSize(kSizesField, 0, &fMinSize);
|
||||||
archive->FindSize(kMaxSizeField, &fMaxSize);
|
archive->FindSize(kSizesField, 1, &fMaxSize);
|
||||||
archive->FindSize(kPreferredSizeField, &fPreferredSize);
|
archive->FindSize(kSizesField, 2, &fPreferredSize);
|
||||||
archive->FindAlignment(kAlignmentField, &fAlignment);
|
archive->FindAlignment(kAlignmentField, &fAlignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,7 +497,7 @@ BView::BView(BMessage* archive)
|
|||||||
int32 i = 0;
|
int32 i = 0;
|
||||||
while (unarchiver.EnsureUnarchived("_views", i++) == B_OK)
|
while (unarchiver.EnsureUnarchived("_views", i++) == B_OK)
|
||||||
;
|
;
|
||||||
unarchiver.EnsureUnarchived("_layout");
|
unarchiver.EnsureUnarchived(kLayoutField);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
BMessage msg;
|
BMessage msg;
|
||||||
@@ -618,7 +618,7 @@ BView::Archive(BMessage* data, bool deep) const
|
|||||||
ret = archiver.AddArchivable("_views", child, deep);
|
ret = archiver.AddArchivable("_views", child, deep);
|
||||||
|
|
||||||
if (ret == B_OK)
|
if (ret == B_OK)
|
||||||
ret = archiver.AddArchivable("_layout", GetLayout(), deep);
|
ret = archiver.AddArchivable(kLayoutField, GetLayout(), deep);
|
||||||
}
|
}
|
||||||
|
|
||||||
return archiver.Finish(ret);
|
return archiver.Finish(ret);
|
||||||
@@ -643,12 +643,11 @@ BView::AllUnarchived(const BMessage* from)
|
|||||||
|
|
||||||
if (err == B_OK) {
|
if (err == B_OK) {
|
||||||
BLayout*& layout = fLayoutData->fLayout;
|
BLayout*& layout = fLayoutData->fLayout;
|
||||||
err = unarchiver.FindObject("_layout", layout);
|
err = unarchiver.FindObject(kLayoutField, layout);
|
||||||
if (err == B_OK && layout) {
|
if (err == B_OK && layout) {
|
||||||
fFlags |= B_SUPPORTS_LAYOUT;
|
fFlags |= B_SUPPORTS_LAYOUT;
|
||||||
fLayoutData->fLayout->BLayout::SetView(this);
|
fLayoutData->fLayout->BLayout::SetView(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const char* kViewField = "ViewLayoutItem:view";
|
const char* const kViewField = "BViewLayoutItem:view";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user