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:
parent
c3bcd1ce7c
commit
4a254e4ddb
@ -12,10 +12,9 @@
|
||||
|
||||
|
||||
namespace {
|
||||
const char* kMinSizeField = "BAbstractLayoutItem:minSize";
|
||||
const char* kMaxSizeField = "BAbstractLayoutItem:maxSize";
|
||||
const char* kPreferredSizeField = "BAbstractLayoutItem:preferredSize";
|
||||
const char* kAlignmentField = "BAbstractLayoutItem:alignment";
|
||||
const char* const kSizesField = "BAbstractLayoutItem:sizes";
|
||||
// kSizesField == {min, max, preferred}
|
||||
const char* const kAlignmentField = "BAbstractLayoutItem:alignment";
|
||||
}
|
||||
|
||||
|
||||
@ -37,9 +36,9 @@ BAbstractLayoutItem::BAbstractLayoutItem(BMessage* from)
|
||||
fPreferredSize(),
|
||||
fAlignment()
|
||||
{
|
||||
from->FindSize(kMinSizeField, &fMinSize);
|
||||
from->FindSize(kMaxSizeField, &fMaxSize);
|
||||
from->FindSize(kPreferredSizeField, &fPreferredSize);
|
||||
from->FindSize(kSizesField, 0, &fMinSize);
|
||||
from->FindSize(kSizesField, 1, &fMaxSize);
|
||||
from->FindSize(kSizesField, 2, &fPreferredSize);
|
||||
from->FindAlignment(kAlignmentField, &fAlignment);
|
||||
}
|
||||
|
||||
@ -140,13 +139,13 @@ BAbstractLayoutItem::Archive(BMessage* into, bool deep) const
|
||||
status_t err = BLayoutItem::Archive(into, deep);
|
||||
|
||||
if (err == B_OK)
|
||||
err = into->AddSize(kMinSizeField, fMinSize);
|
||||
err = into->AddSize(kSizesField, fMinSize);
|
||||
|
||||
if (err == B_OK)
|
||||
err = into->AddSize(kMaxSizeField, fMaxSize);
|
||||
err = into->AddSize(kSizesField, fMaxSize);
|
||||
|
||||
if (err == B_OK)
|
||||
err = into->AddSize(kPreferredSizeField, fPreferredSize);
|
||||
err = into->AddSize(kSizesField, fPreferredSize);
|
||||
|
||||
if (err == B_OK)
|
||||
err = into->AddAlignment(kAlignmentField, fAlignment);
|
||||
|
@ -31,18 +31,14 @@ namespace {
|
||||
// a placeholder we put in our grid array to make a cell occupied
|
||||
BLayoutItem* const OCCUPIED_GRID_CELL = (BLayoutItem*)0x1;
|
||||
|
||||
const char* kRowCountField = "gridlayout:rowcount";
|
||||
const char* kRowMinSizeField = "gridlayout:rowminsize";
|
||||
const char* kRowMaxSizeField = "gridlayout:rowmaxsize";
|
||||
const char* kRowWeightField = "gridlayout:rowweight";
|
||||
const char* kColumnCountField = "gridlayout:columncount";
|
||||
const char* kColumnMinSizeField = "gridlayout:columnminsize";
|
||||
const char* kColumnMaxSizeField = "gridlayout:columnmaxsize";
|
||||
const char* kColumnWeightField = "gridlayout:columnweight";
|
||||
const char* kItemHeight = "gridlayout:item:height";
|
||||
const char* kItemWidth = "gridlayout:item:width";
|
||||
const char* kItemX = "gridlayout:item:x";
|
||||
const char* kItemY = "gridlayout:item:y";
|
||||
const char* const kRowSizesField = "BGridLayout:rowsizes";
|
||||
// kRowSizesField = {min, max}
|
||||
const char* const kRowWeightField = "BGridLayout:rowweight";
|
||||
const char* const kColumnSizesField = "BGridLayout:columnsizes";
|
||||
// kColumnSizesField = {min, max}
|
||||
const char* const kColumnWeightField = "BGridLayout:columnweight";
|
||||
const char* const kItemDimensionsField = "BGridLayout:item:dimensions";
|
||||
// kItemDimensionsField = {x, y, width, height}
|
||||
}
|
||||
|
||||
|
||||
@ -179,15 +175,12 @@ BGridLayout::BGridLayout(BMessage* from)
|
||||
fMultiColumnItems(0),
|
||||
fMultiRowItems(0)
|
||||
{
|
||||
int32 rows;
|
||||
int32 columns;
|
||||
BUnarchiver unarchiver(from);
|
||||
int32 columns;
|
||||
from->GetInfo(kColumnWeightField, NULL, &columns);
|
||||
|
||||
if (from->FindInt32(kRowCountField, &rows) != B_OK)
|
||||
fRowCount = 0;
|
||||
|
||||
if (from->FindInt32(kColumnCountField, &columns) != B_OK)
|
||||
fColumnCount = 0;
|
||||
int32 rows;
|
||||
from->GetInfo(kRowWeightField, NULL, &rows);
|
||||
|
||||
// sets fColumnCount && fRowCount on success
|
||||
if (!_ResizeGrid(columns, rows)) {
|
||||
@ -200,10 +193,10 @@ BGridLayout::BGridLayout(BMessage* from)
|
||||
if (from->FindFloat(kRowWeightField, i, &getter) == B_OK)
|
||||
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);
|
||||
|
||||
if (from->FindFloat(kRowMaxSizeField, i, &getter) == B_OK)
|
||||
if (from->FindFloat(kRowSizesField, i * 2 + 1, &getter) == B_OK)
|
||||
fRowInfos->SetMaxSize(i, getter);
|
||||
}
|
||||
|
||||
@ -212,10 +205,10 @@ BGridLayout::BGridLayout(BMessage* from)
|
||||
if (from->FindFloat(kColumnWeightField, i, &getter) == B_OK)
|
||||
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);
|
||||
|
||||
if (from->FindFloat(kColumnMaxSizeField, i, &getter) == B_OK)
|
||||
if (from->FindFloat(kColumnSizesField, i * 2 + 1, &getter) == B_OK)
|
||||
fColumnInfos->SetMaxSize(i, getter);
|
||||
}
|
||||
}
|
||||
@ -467,25 +460,20 @@ BGridLayout::Archive(BMessage* into, bool deep) const
|
||||
BArchiver archiver(into);
|
||||
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++) {
|
||||
err = into->AddFloat(kRowWeightField, fRowInfos->Weight(i));
|
||||
if (err == B_OK)
|
||||
err = into->AddFloat(kRowMinSizeField, fRowInfos->MinSize(i));
|
||||
err = into->AddFloat(kRowSizesField, fRowInfos->MinSize(i));
|
||||
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++) {
|
||||
err = into->AddFloat(kColumnWeightField, fRowInfos->Weight(i));
|
||||
err = into->AddFloat(kColumnWeightField, fColumnInfos->Weight(i));
|
||||
if (err == B_OK)
|
||||
err = into->AddFloat(kColumnMinSizeField, fRowInfos->MinSize(i));
|
||||
err = into->AddFloat(kColumnSizesField, fColumnInfos->MinSize(i));
|
||||
if (err == B_OK)
|
||||
err = into->AddFloat(kColumnMaxSizeField, fRowInfos->MaxSize(i));
|
||||
err = into->AddFloat(kColumnSizesField, fColumnInfos->MaxSize(i));
|
||||
}
|
||||
|
||||
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
|
||||
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)
|
||||
err = into->AddInt32(kItemY, data->dimensions.y);
|
||||
err = into->AddInt32(kItemDimensionsField, data->dimensions.y);
|
||||
if (err == B_OK)
|
||||
err = into->AddInt32(kItemWidth, data->dimensions.width);
|
||||
err = into->AddInt32(kItemDimensionsField, data->dimensions.width);
|
||||
if (err == B_OK)
|
||||
err = into->AddInt32(kItemHeight, data->dimensions.height);
|
||||
err = into->AddInt32(kItemDimensionsField, data->dimensions.height);
|
||||
|
||||
return err;
|
||||
}
|
||||
@ -531,26 +519,33 @@ BGridLayout::ItemUnarchived(const BMessage* from,
|
||||
}
|
||||
|
||||
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)
|
||||
err = from->FindInt32(kItemY, index, &dimensions.y);
|
||||
err = from->FindInt32(kItemDimensionsField, ++index, &dimensions.y);
|
||||
|
||||
if (err == B_OK)
|
||||
err = from->FindInt32(kItemWidth, index, &dimensions.width);
|
||||
err = from->FindInt32(kItemDimensionsField, ++index, &dimensions.width);
|
||||
|
||||
if (err == B_OK)
|
||||
err = from->FindInt32(kItemHeight, index, &dimensions.height);
|
||||
if (err == B_OK) {
|
||||
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))
|
||||
err = B_BAD_DATA;
|
||||
return B_BAD_DATA;
|
||||
|
||||
if (err == B_OK && !_InsertItemIntoGrid(item))
|
||||
err = B_NO_MEMORY;
|
||||
if (!_InsertItemIntoGrid(item))
|
||||
return B_NO_MEMORY;
|
||||
|
||||
if (err == B_OK && dimensions.width > 1)
|
||||
if (dimensions.width > 1)
|
||||
fMultiColumnItems++;
|
||||
if (err == B_OK && dimensions.height > 1)
|
||||
if (dimensions.height > 1)
|
||||
fMultiRowItems++;
|
||||
|
||||
return err;
|
||||
|
@ -14,8 +14,8 @@
|
||||
|
||||
|
||||
namespace {
|
||||
const char* kWeightField = "BGroupLayoutData:weight";
|
||||
const char* kVerticalField = "BGroupLayout:vertical";
|
||||
const char* const kItemWeightField = "BGroupLayout:item:weight";
|
||||
const char* const kVerticalField = "BGroupLayout:vertical";
|
||||
}
|
||||
|
||||
|
||||
@ -219,7 +219,7 @@ BGroupLayout::ItemArchived(BMessage* into,
|
||||
if (!data) // TODO: remove this once ItemAdded() returns a bool
|
||||
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)
|
||||
{
|
||||
float weight;
|
||||
status_t err = from->FindFloat(kWeightField, index, &weight);
|
||||
status_t err = from->FindFloat(kItemWeightField, index, &weight);
|
||||
|
||||
if (err == B_OK)
|
||||
_LayoutDataForItem(item)->weight = weight;
|
||||
|
@ -19,7 +19,7 @@
|
||||
using std::nothrow;
|
||||
|
||||
namespace {
|
||||
const char* kLayoutItemField = "BLayout:_items";
|
||||
const char* const kLayoutItemField = "BLayout:items";
|
||||
}
|
||||
|
||||
|
||||
|
@ -13,12 +13,11 @@
|
||||
|
||||
|
||||
namespace {
|
||||
const char* kMinSizeField = "BSpaceLayoutItem:minsize";
|
||||
const char* kMaxSizeField = "BSpaceLayoutItem:maxsize";
|
||||
const char* kPreferredSizeField = "BSpaceLayoutItem:prefsize";
|
||||
const char* kAlignmentField = "BSpaceLayoutItem:alignment";
|
||||
const char* kFrameField = "BSpaceLayoutItem:frame";
|
||||
const char* kVisibleField = "BSpaceLayoutItem:visible";
|
||||
const char* const kSizesField = "BSpaceLayoutItem:sizes";
|
||||
// kSizesField = {min, max, preferred}
|
||||
const char* const kAlignmentField = "BSpaceLayoutItem:alignment";
|
||||
const char* const kFrameField = "BSpaceLayoutItem:frame";
|
||||
const char* const kVisibleField = "BSpaceLayoutItem:visible";
|
||||
}
|
||||
|
||||
|
||||
@ -39,9 +38,9 @@ BSpaceLayoutItem::BSpaceLayoutItem(BMessage* archive)
|
||||
:
|
||||
BLayoutItem(archive)
|
||||
{
|
||||
archive->FindSize(kMinSizeField, &fMinSize);
|
||||
archive->FindSize(kMaxSizeField, &fMaxSize);
|
||||
archive->FindSize(kPreferredSizeField, &fPreferredSize);
|
||||
archive->FindSize(kSizesField, 0, &fMinSize);
|
||||
archive->FindSize(kSizesField, 1, &fMaxSize);
|
||||
archive->FindSize(kSizesField, 2, &fPreferredSize);
|
||||
|
||||
archive->FindAlignment(kAlignmentField, &fAlignment);
|
||||
|
||||
@ -201,13 +200,13 @@ BSpaceLayoutItem::Archive(BMessage* into, bool deep) const
|
||||
err = into->AddRect(kFrameField, fFrame);
|
||||
|
||||
if (err == B_OK)
|
||||
err = into->AddSize(kMinSizeField, fMinSize);
|
||||
err = into->AddSize(kSizesField, fMinSize);
|
||||
|
||||
if (err == B_OK)
|
||||
err = into->AddSize(kMaxSizeField, fMaxSize);
|
||||
err = into->AddSize(kSizesField, fMaxSize);
|
||||
|
||||
if (err == B_OK)
|
||||
err = into->AddSize(kPreferredSizeField, fPreferredSize);
|
||||
err = into->AddSize(kSizesField, fPreferredSize);
|
||||
|
||||
if (err == B_OK)
|
||||
err = into->AddAlignment(kAlignmentField, fAlignment);
|
||||
|
@ -20,15 +20,12 @@
|
||||
|
||||
// archivng constants
|
||||
namespace {
|
||||
const char* kInfoCollapsibleField = "BSplitLayout::info::collapsible";
|
||||
const char* kInfoWeightField = "BSplitLayout::info::weight";
|
||||
const char* kSpacingField = "BSplitLayout::spacing";
|
||||
const char* kSplitterSizeField = "BSplitLayout::splitterSize";
|
||||
const char* kIsVerticalField = "BSplitLayout::vertical";
|
||||
const char* kTopInsetField = "BSplitLayout::TopInset";
|
||||
const char* kBottomInsetField = "BSplitLayout::BottomInset";
|
||||
const char* kLeftInsetField = "BSplitLayout::LeftInset";
|
||||
const char* kRightInsetField = "BSplitLayout::RightInset";
|
||||
const char* const kItemCollapsibleField = "BSplitLayout:item:collapsible";
|
||||
const char* const kItemWeightField = "BSplitLayout:item:weight";
|
||||
const char* const kSpacingField = "BSplitLayout:spacing";
|
||||
const char* const kSplitterSizeField = "BSplitLayout:splitterSize";
|
||||
const char* const kIsVerticalField = "BSplitLayout:vertical";
|
||||
const char* const kInsetsField = "BSplitLayout:insets";
|
||||
}
|
||||
|
||||
|
||||
@ -196,7 +193,7 @@ BSplitLayout::BSplitLayout(enum orientation orientation,
|
||||
|
||||
BSplitLayout::BSplitLayout(BMessage* from)
|
||||
:
|
||||
BLayout(from),
|
||||
BLayout(BUnarchiver::PrepareArchive(from)),
|
||||
fSplitterItems(),
|
||||
fVisibleItems(),
|
||||
fMin(),
|
||||
@ -225,16 +222,29 @@ BSplitLayout::BSplitLayout(BMessage* from)
|
||||
fDraggingCurrentValue(0),
|
||||
fDraggingSplitterIndex(-1)
|
||||
{
|
||||
BUnarchiver unarchiver(from);
|
||||
|
||||
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 ;
|
||||
|
||||
from->FindFloat(kLeftInsetField, &fLeftInset);
|
||||
from->FindFloat(kRightInsetField, &fRightInset);
|
||||
from->FindFloat(kTopInsetField, &fTopInset);
|
||||
from->FindFloat(kBottomInsetField, &fBottomInset);
|
||||
from->FindFloat(kSplitterSizeField, &fSplitterSize);
|
||||
from->FindFloat(kSpacingField, &fSpacing);
|
||||
BRect insets;
|
||||
err = from->FindRect(kInsetsField, &insets);
|
||||
if (err != B_OK) {
|
||||
unarchiver.Finish(err);
|
||||
return;
|
||||
}
|
||||
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);
|
||||
|
||||
if (err == B_OK)
|
||||
into->AddBool(kIsVerticalField, fOrientation == B_VERTICAL);
|
||||
err = into->AddBool(kIsVerticalField, fOrientation == B_VERTICAL);
|
||||
|
||||
if (err == B_OK)
|
||||
err = into->AddFloat(kLeftInsetField, fLeftInset);
|
||||
|
||||
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) {
|
||||
BRect insets(fLeftInset, fTopInset, fRightInset, fBottomInset);
|
||||
err = into->AddRect(kInsetsField, insets);
|
||||
}
|
||||
|
||||
if (err == B_OK)
|
||||
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
|
||||
return B_ERROR;
|
||||
|
||||
status_t err = into->AddFloat(kInfoWeightField, info->weight);
|
||||
status_t err = into->AddFloat(kItemWeightField, info->weight);
|
||||
if (err == B_OK)
|
||||
err = into->AddBool(kInfoCollapsibleField, info->isCollapsible);
|
||||
err = into->AddBool(kItemCollapsibleField, info->isCollapsible);
|
||||
|
||||
return err;
|
||||
}
|
||||
@ -756,11 +759,11 @@ BSplitLayout::ItemUnarchived(const BMessage* from,
|
||||
BLayoutItem* item, int32 index)
|
||||
{
|
||||
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) {
|
||||
bool* collapsible = &info->isCollapsible;
|
||||
err = from->FindBool(kInfoCollapsibleField, index, collapsible);
|
||||
err = from->FindBool(kItemCollapsibleField, index, collapsible);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
@ -22,11 +22,6 @@
|
||||
#include "SimpleLayouter.h"
|
||||
|
||||
|
||||
// Archiving constants
|
||||
namespace {
|
||||
const char* kHAlignedLayoutField = "B2DLayout:halignedlayout";
|
||||
const char* kVAlignedLayoutField = "B2DLayout:valignedlayout";
|
||||
}
|
||||
|
||||
|
||||
// Some words of explanation:
|
||||
@ -238,12 +233,13 @@ private:
|
||||
|
||||
// archiving constants
|
||||
namespace {
|
||||
const char* kLeftInsetField = "B2Dlayout:leftInset";
|
||||
const char* kRightInsetField = "B2Dlayout:rightInset";
|
||||
const char* kTopInsetField = "B2Dlayout:topInset";
|
||||
const char* kBottomInsetField = "B2Dlayout:bottomInset";
|
||||
const char* kHSpacingField = "B2Dlayout:hspacing";
|
||||
const char* kVSpacingField = "B2Dlayout:vspacing";
|
||||
const char* const kHAlignedLayoutField = "BTwoDimensionalLayout:"
|
||||
"halignedlayout";
|
||||
const char* const kVAlignedLayoutField = "BTwoDimensionalLayout:"
|
||||
"valignedlayout";
|
||||
const char* const kInsetsField = "BTwoDimensionalLayout:insets";
|
||||
const char* const kSpacingField = "BTwoDimensionalLayout:spacing";
|
||||
// kSpacingField = {fHSpacing, fVSpacing}
|
||||
}
|
||||
|
||||
|
||||
@ -271,18 +267,12 @@ BTwoDimensionalLayout::BTwoDimensionalLayout(BMessage* from)
|
||||
fVSpacing(0),
|
||||
fLocalLayouter(new LocalLayouter(this))
|
||||
{
|
||||
float leftInset;
|
||||
float rightInset;
|
||||
float topInset;
|
||||
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);
|
||||
BRect insets;
|
||||
from->FindRect(kInsetsField, &insets);
|
||||
SetInsets(insets.left, insets.top, insets.right, insets.bottom);
|
||||
|
||||
from->FindFloat(kHSpacingField, &fHSpacing);
|
||||
from->FindFloat(kVSpacingField, &fVSpacing);
|
||||
from->FindFloat(kSpacingField, 0, &fHSpacing);
|
||||
from->FindFloat(kSpacingField, 1, &fVSpacing);
|
||||
}
|
||||
|
||||
|
||||
@ -454,23 +444,16 @@ BTwoDimensionalLayout::Archive(BMessage* into, bool deep) const
|
||||
BArchiver archiver(into);
|
||||
status_t err = BLayout::Archive(into, deep);
|
||||
|
||||
if (err == B_OK)
|
||||
err = into->AddFloat(kLeftInsetField, fLeftInset);
|
||||
if (err == B_OK) {
|
||||
BRect insets(fLeftInset, fTopInset, fRightInset, fBottomInset);
|
||||
err = into->AddRect(kInsetsField, insets);
|
||||
}
|
||||
|
||||
if (err == B_OK)
|
||||
err = into->AddFloat(kRightInsetField, fRightInset);
|
||||
err = into->AddFloat(kSpacingField, fHSpacing);
|
||||
|
||||
if (err == B_OK)
|
||||
err = into->AddFloat(kTopInsetField, fTopInset);
|
||||
|
||||
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);
|
||||
err = into->AddFloat(kSpacingField, fVSpacing);
|
||||
|
||||
return archiver.Finish(err);
|
||||
}
|
||||
|
@ -318,10 +318,10 @@ ViewState::UpdateFrom(BPrivate::PortLink &link)
|
||||
|
||||
// archiving constants
|
||||
namespace {
|
||||
const char* kMinSizeField = "ViewLayoutData:minsize";
|
||||
const char* kMaxSizeField = "ViewLayoutData:maxsize";
|
||||
const char* kPreferredSizeField = "ViewLayoutData:prefsize";
|
||||
const char* kAlignmentField = "ViewLayoutData:alignment";
|
||||
const char* const kSizesField = "BView:sizes";
|
||||
// kSizesField = {min, max, pref}
|
||||
const char* const kAlignmentField = "BView:alignment";
|
||||
const char* const kLayoutField = "BView:layout";
|
||||
}
|
||||
|
||||
|
||||
@ -345,15 +345,15 @@ struct BView::LayoutData {
|
||||
status_t
|
||||
AddDataToArchive(BMessage* archive)
|
||||
{
|
||||
status_t err = archive->AddSize(kMinSizeField, fMinSize);
|
||||
status_t err = archive->AddSize(kSizesField, fMinSize);
|
||||
|
||||
if (err == B_OK)
|
||||
err = archive->AddSize(kMaxSizeField, fMaxSize);
|
||||
err = archive->AddSize(kSizesField, fMaxSize);
|
||||
|
||||
if (err == B_OK)
|
||||
err = archive->AddSize(kSizesField, fPreferredSize);
|
||||
|
||||
if (err == B_OK)
|
||||
err = archive->AddSize(kPreferredSizeField, fPreferredSize);
|
||||
|
||||
if (err == B_OK)
|
||||
err = archive->AddAlignment(kAlignmentField, fAlignment);
|
||||
|
||||
return err;
|
||||
@ -362,9 +362,9 @@ struct BView::LayoutData {
|
||||
void
|
||||
PopulateFromArchive(BMessage* archive)
|
||||
{
|
||||
archive->FindSize(kMinSizeField, &fMinSize);
|
||||
archive->FindSize(kMaxSizeField, &fMaxSize);
|
||||
archive->FindSize(kPreferredSizeField, &fPreferredSize);
|
||||
archive->FindSize(kSizesField, 0, &fMinSize);
|
||||
archive->FindSize(kSizesField, 1, &fMaxSize);
|
||||
archive->FindSize(kSizesField, 2, &fPreferredSize);
|
||||
archive->FindAlignment(kAlignmentField, &fAlignment);
|
||||
}
|
||||
|
||||
@ -497,7 +497,7 @@ BView::BView(BMessage* archive)
|
||||
int32 i = 0;
|
||||
while (unarchiver.EnsureUnarchived("_views", i++) == B_OK)
|
||||
;
|
||||
unarchiver.EnsureUnarchived("_layout");
|
||||
unarchiver.EnsureUnarchived(kLayoutField);
|
||||
|
||||
} else {
|
||||
BMessage msg;
|
||||
@ -618,7 +618,7 @@ BView::Archive(BMessage* data, bool deep) const
|
||||
ret = archiver.AddArchivable("_views", child, deep);
|
||||
|
||||
if (ret == B_OK)
|
||||
ret = archiver.AddArchivable("_layout", GetLayout(), deep);
|
||||
ret = archiver.AddArchivable(kLayoutField, GetLayout(), deep);
|
||||
}
|
||||
|
||||
return archiver.Finish(ret);
|
||||
@ -643,12 +643,11 @@ BView::AllUnarchived(const BMessage* from)
|
||||
|
||||
if (err == B_OK) {
|
||||
BLayout*& layout = fLayoutData->fLayout;
|
||||
err = unarchiver.FindObject("_layout", layout);
|
||||
err = unarchiver.FindObject(kLayoutField, layout);
|
||||
if (err == B_OK && layout) {
|
||||
fFlags |= B_SUPPORTS_LAYOUT;
|
||||
fLayoutData->fLayout->BLayout::SetView(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return err;
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
|
||||
namespace {
|
||||
const char* kViewField = "ViewLayoutItem:view";
|
||||
const char* const kViewField = "BViewLayoutItem:view";
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user