hrev44760 adds 7 changesets to branch 'master' old head: d2c8db267dd912f719bb582acc14c8c521eac15c new head: 17ad59afd3b25f230efd7231a3315e344ef73ae0 ---------------------------------------------------------------------------- 4656e55: Added method SetExplicitSize() for convenience. 2267b7e: Added Grid::AddGlue(), and SetExplicit*Size() methods. 6643ead: Made the BRect::*Copy() methods const as they should have been. 09d87d9: The text control is now more flexible with its layout items. * Before, you had to have both, the text view layout item, and the label layout item or else nothing would ever be visible. * Now you can only create the text view item, and it will still work. * Also, no matter the order you added the layout items, they would always put the label on the left, and the control to the right. * You can place the label and text view layout items anywhere now, although you should keep in mind that the view spans over their frame unions; IOW they should always adjacent to each other, but not necessarily horizontally and left to right. * No longer uses a fixed label spacing, but utilizes BControlLook::DefaultLabelSpacing() instead. * However, the spacing is always added to the right of the label, no matter how you place it in the layout. Maybe one wants to add a SetLabelTextViewGap() like method. 9e42a44: Added BPath::IsAbsolute() method. 762e4ec: BMessage::Append() is now actually working. 17ad59a: Added BLayoutBuilder::{Group|Grid}::SetExplicitAlignment(). [ Axel DÃrfler <axeld@xxxxxxxxxxxxxxxx> ] ---------------------------------------------------------------------------- 12 files changed, 320 insertions(+), 79 deletions(-) headers/os/interface/LayoutBuilder.h | 98 +++++++++++++++++++++++++- headers/os/interface/LayoutItem.h | 1 + headers/os/interface/Rect.h | 20 +++--- headers/os/interface/TextControl.h | 9 +-- headers/os/interface/View.h | 4 +- headers/os/storage/Path.h | 7 +- src/kits/app/Message.cpp | 9 +-- src/kits/interface/LayoutItem.cpp | 16 ++++- src/kits/interface/Rect.cpp | 95 ++++++++++++++++++++----- src/kits/interface/TextControl.cpp | 116 +++++++++++++++++++++---------- src/kits/interface/View.cpp | 10 +++ src/kits/storage/Path.cpp | 14 +++- ############################################################################ Commit: 4656e550b0998dae6450e63a6a37b2f664b03e4d URL: http://cgit.haiku-os.org/haiku/commit/?id=4656e55 Author: Axel DÃrfler <axeld@xxxxxxxxxxxxxxxx> Date: Sun Nov 4 09:45:51 2012 UTC Added method SetExplicitSize() for convenience. ---------------------------------------------------------------------------- diff --git a/headers/os/interface/LayoutItem.h b/headers/os/interface/LayoutItem.h index b0d5302..851fdd0 100644 --- a/headers/os/interface/LayoutItem.h +++ b/headers/os/interface/LayoutItem.h @@ -32,6 +32,7 @@ public: virtual void SetExplicitMinSize(BSize size) = 0; virtual void SetExplicitMaxSize(BSize size) = 0; virtual void SetExplicitPreferredSize(BSize size) = 0; + void SetExplicitSize(BSize size); virtual void SetExplicitAlignment(BAlignment alignment) = 0; virtual bool IsVisible() = 0; diff --git a/headers/os/interface/View.h b/headers/os/interface/View.h index 4471ddd..bac388e 100644 --- a/headers/os/interface/View.h +++ b/headers/os/interface/View.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2009, Haiku, Inc. All rights reserved. + * Copyright 2001-2012, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _VIEW_H @@ -537,6 +537,7 @@ public: void SetExplicitMinSize(BSize size); void SetExplicitMaxSize(BSize size); void SetExplicitPreferredSize(BSize size); + void SetExplicitSize(BSize size); void SetExplicitAlignment(BAlignment alignment); BSize ExplicitMinSize() const; @@ -753,4 +754,5 @@ BView::SetLowColor(uchar r, uchar g, uchar b, uchar a) SetLowColor(color); } + #endif // _VIEW_H diff --git a/src/kits/interface/LayoutItem.cpp b/src/kits/interface/LayoutItem.cpp index 0382c61..5ef6cab 100644 --- a/src/kits/interface/LayoutItem.cpp +++ b/src/kits/interface/LayoutItem.cpp @@ -1,9 +1,10 @@ /* - * Copyright 2010, Haiku, Inc. + * Copyright 2010-2012, Haiku, Inc. * Copyright 2006, Ingo Weinhold <bonefish@xxxxxxxxxxxxxxx>. * All rights reserved. Distributed under the terms of the MIT License. */ + #include <LayoutItem.h> #include <Layout.h> @@ -46,6 +47,15 @@ BLayoutItem::Layout() const } +void +BLayoutItem::SetExplicitSize(BSize size) +{ + SetExplicitMinSize(size); + SetExplicitMaxSize(size); + SetExplicitPreferredSize(size); +} + + bool BLayoutItem::HasHeightForWidth() { @@ -122,7 +132,7 @@ BLayoutItem::AlignInFrame(BRect frame) float minHeight; GetHeightForWidth(frame.Width(), &minHeight, NULL, NULL); - + frame.bottom = frame.top + max_c(frame.Height(), minHeight); maxSize.height = minHeight; } @@ -178,7 +188,7 @@ BLayoutItem::SetLayout(BLayout* layout) BView::Private(view).RegisterLayoutItem(this); } } - + if (fLayout) AttachedToLayout(); } diff --git a/src/kits/interface/View.cpp b/src/kits/interface/View.cpp index 47eb59f..7adf00e 100644 --- a/src/kits/interface/View.cpp +++ b/src/kits/interface/View.cpp @@ -4587,6 +4587,16 @@ BView::SetExplicitPreferredSize(BSize size) void +BView::SetExplicitSize(BSize size) +{ + fLayoutData->fMinSize = size; + fLayoutData->fMaxSize = size; + fLayoutData->fPreferredSize = size; + InvalidateLayout(); +} + + +void BView::SetExplicitAlignment(BAlignment alignment) { fLayoutData->fAlignment = alignment; ############################################################################ Commit: 2267b7e7fbfd5c977d50ec35613eb1a0b9ecf521 URL: http://cgit.haiku-os.org/haiku/commit/?id=2267b7e Author: Axel DÃrfler <axeld@xxxxxxxxxxxxxxxx> Date: Sun Nov 4 09:53:34 2012 UTC Added Grid::AddGlue(), and SetExplicit*Size() methods. ---------------------------------------------------------------------------- diff --git a/headers/os/interface/LayoutBuilder.h b/headers/os/interface/LayoutBuilder.h index 83e8824..7e9bda0 100644 --- a/headers/os/interface/LayoutBuilder.h +++ b/headers/os/interface/LayoutBuilder.h @@ -1,5 +1,5 @@ /* - * Copyright 2009-2010, Haiku, Inc. All rights reserved. + * Copyright 2009-2012, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _LAYOUT_BUILDER_H @@ -108,6 +108,10 @@ public: inline ThisBuilder& SetInsets(float horizontal, float vertical); inline ThisBuilder& SetInsets(float insets); + inline ThisBuilder& SetExplicitMinSize(BSize size); + inline ThisBuilder& SetExplicitMaxSize(BSize size); + inline ThisBuilder& SetExplicitPreferredSize(BSize size); + inline operator BGroupLayout*(); private: @@ -188,6 +192,9 @@ public: int32 row, int32 columnCount = 1, int32 rowCount = 1); + inline ThisBuilder& AddGlue(int32 column, int32 row, + int32 columnCount = 1, int32 rowCount = 1); + inline ThisBuilder& SetColumnWeight(int32 column, float weight); inline ThisBuilder& SetRowWeight(int32 row, float weight); @@ -196,6 +203,10 @@ public: inline ThisBuilder& SetInsets(float horizontal, float vertical); inline ThisBuilder& SetInsets(float insets); + inline ThisBuilder& SetExplicitMinSize(BSize size); + inline ThisBuilder& SetExplicitMaxSize(BSize size); + inline ThisBuilder& SetExplicitPreferredSize(BSize size); + inline operator BGridLayout*(); private: @@ -605,6 +616,33 @@ Group<ParentBuilder>::SetInsets(float insets) template<typename ParentBuilder> +typename Group<ParentBuilder>::ThisBuilder& +Group<ParentBuilder>::SetExplicitMinSize(BSize size) +{ + fLayout->SetExplicitMinSize(size); + return *this; +} + + +template<typename ParentBuilder> +typename Group<ParentBuilder>::ThisBuilder& +Group<ParentBuilder>::SetExplicitMaxSize(BSize size) +{ + fLayout->SetExplicitMaxSize(size); + return *this; +} + + +template<typename ParentBuilder> +typename Group<ParentBuilder>::ThisBuilder& +Group<ParentBuilder>::SetExplicitPreferredSize(BSize size) +{ + fLayout->SetExplicitPreferredSize(size); + return *this; +} + + +template<typename ParentBuilder> Group<ParentBuilder>::operator BGroupLayout*() { return fLayout; @@ -835,6 +873,17 @@ Grid<ParentBuilder>::AddSplit(BSplitView* splitView, int32 column, int32 row, template<typename ParentBuilder> typename Grid<ParentBuilder>::ThisBuilder& +Grid<ParentBuilder>::AddGlue(int32 column, int32 row, int32 columnCount, + int32 rowCount) +{ + fLayout->AddItem(BSpaceLayoutItem::CreateGlue(), column, row, columnCount, + rowCount); + return *this; +} + + +template<typename ParentBuilder> +typename Grid<ParentBuilder>::ThisBuilder& Grid<ParentBuilder>::SetColumnWeight(int32 column, float weight) { fLayout->SetColumnWeight(column, weight); @@ -880,6 +929,33 @@ Grid<ParentBuilder>::SetInsets(float insets) template<typename ParentBuilder> +typename Grid<ParentBuilder>::ThisBuilder& +Grid<ParentBuilder>::SetExplicitMinSize(BSize size) +{ + fLayout->SetExplicitMinSize(size); + return *this; +} + + +template<typename ParentBuilder> +typename Grid<ParentBuilder>::ThisBuilder& +Grid<ParentBuilder>::SetExplicitMaxSize(BSize size) +{ + fLayout->SetExplicitMaxSize(size); + return *this; +} + + +template<typename ParentBuilder> +typename Grid<ParentBuilder>::ThisBuilder& +Grid<ParentBuilder>::SetExplicitPreferredSize(BSize size) +{ + fLayout->SetExplicitPreferredSize(size); + return *this; +} + + +template<typename ParentBuilder> Grid<ParentBuilder>::operator BGridLayout*() { return fLayout; ############################################################################ Commit: 6643ead593c3c936c676df6f535337e57002c843 URL: http://cgit.haiku-os.org/haiku/commit/?id=6643ead Author: Axel DÃrfler <axeld@xxxxxxxxxxxxxxxx> Date: Sun Nov 4 13:07:46 2012 UTC Made the BRect::*Copy() methods const as they should have been. ---------------------------------------------------------------------------- diff --git a/headers/os/interface/Rect.h b/headers/os/interface/Rect.h index f55f24f..b48499f 100644 --- a/headers/os/interface/Rect.h +++ b/headers/os/interface/Rect.h @@ -1,16 +1,16 @@ /* - * Copyright 2001-2009, Haiku, Inc. All rights reserved. + * Copyright 2001-2012, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _RECT_H #define _RECT_H +#include <math.h> + #include <Point.h> #include <Size.h> -#include <math.h> - class BRect { public: @@ -54,16 +54,16 @@ public: // Expression transformations BRect& InsetBySelf(BPoint inset); BRect& InsetBySelf(float dx, float dy); - BRect InsetByCopy(BPoint inset); - BRect InsetByCopy(float dx, float dy); + BRect InsetByCopy(BPoint inset) const; + BRect InsetByCopy(float dx, float dy) const; BRect& OffsetBySelf(BPoint offset); BRect& OffsetBySelf(float dx, float dy); - BRect OffsetByCopy(BPoint offset); - BRect OffsetByCopy(float dx, float dy); + BRect OffsetByCopy(BPoint offset) const; + BRect OffsetByCopy(float dx, float dy) const; BRect& OffsetToSelf(BPoint offset); BRect& OffsetToSelf(float dx, float dy); - BRect OffsetToCopy(BPoint offset); - BRect OffsetToCopy(float dx, float dy); + BRect OffsetToCopy(BPoint offset) const; + BRect OffsetToCopy(float dx, float dy) const; // Comparison bool operator==(BRect r) const; @@ -120,7 +120,7 @@ inline BRect::BRect() : left(0), - top(0), + top(0), right(-1), bottom(-1) { diff --git a/src/kits/interface/Rect.cpp b/src/kits/interface/Rect.cpp index c56d51d..20b5130 100644 --- a/src/kits/interface/Rect.cpp +++ b/src/kits/interface/Rect.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007, Haiku, Inc. All Rights Reserved. + * Copyright 2001-2012, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -80,7 +80,7 @@ BRect::InsetBySelf(float dx, float dy) BRect -BRect::InsetByCopy(BPoint point) +BRect::InsetByCopy(BPoint point) const { BRect copy(*this); copy.InsetBy(point); @@ -89,7 +89,7 @@ BRect::InsetByCopy(BPoint point) BRect -BRect::InsetByCopy(float dx, float dy) +BRect::InsetByCopy(float dx, float dy) const { BRect copy(*this); copy.InsetBy(dx, dy); @@ -134,7 +134,7 @@ BRect::OffsetBySelf(float dx, float dy) BRect -BRect::OffsetByCopy(BPoint point) +BRect::OffsetByCopy(BPoint point) const { BRect copy(*this); copy.OffsetBy(point); @@ -143,7 +143,7 @@ BRect::OffsetByCopy(BPoint point) BRect -BRect::OffsetByCopy(float dx, float dy) +BRect::OffsetByCopy(float dx, float dy) const { BRect copy(*this); copy.OffsetBy(dx, dy); @@ -188,7 +188,7 @@ BRect::OffsetToSelf(float dx, float dy) BRect -BRect::OffsetToCopy(BPoint point) +BRect::OffsetToCopy(BPoint point) const { BRect copy(*this); copy.OffsetTo(point); @@ -197,7 +197,7 @@ BRect::OffsetToCopy(BPoint point) BRect -BRect::OffsetToCopy(float dx, float dy) +BRect::OffsetToCopy(float dx, float dy) const { BRect copy(*this); copy.OffsetTo(dx, dy); @@ -215,31 +215,31 @@ BRect::PrintToStream() const bool BRect::operator==(BRect rect) const { - return left == rect.left && right == rect.right && - top == rect.top && bottom == rect.bottom; + return left == rect.left && right == rect.right && + top == rect.top && bottom == rect.bottom; } bool BRect::operator!=(BRect rect) const { - return !(*this == rect); + return !(*this == rect); } BRect BRect::operator&(BRect rect) const { - return BRect(max_c(left, rect.left), max_c(top, rect.top), - min_c(right, rect.right), min_c(bottom, rect.bottom)); + return BRect(max_c(left, rect.left), max_c(top, rect.top), + min_c(right, rect.right), min_c(bottom, rect.bottom)); } BRect BRect::operator|(BRect rect) const { - return BRect(min_c(left, rect.left), min_c(top, rect.top), - max_c(right, rect.right), max_c(bottom, rect.bottom)); + return BRect(min_c(left, rect.left), min_c(top, rect.top), + max_c(right, rect.right), max_c(bottom, rect.bottom)); } @@ -250,7 +250,7 @@ BRect::Intersects(BRect rect) const return false; return !(rect.left > right || rect.right < left - || rect.top > bottom || rect.bottom < top); + || rect.top > bottom || rect.bottom < top); } @@ -258,7 +258,7 @@ bool BRect::Contains(BPoint point) const { return point.x >= left && point.x <= right - && point.y >= top && point.y <= bottom; + && point.y >= top && point.y <= bottom; } @@ -266,5 +266,66 @@ bool BRect::Contains(BRect rect) const { return rect.left >= left && rect.right <= right - && rect.top >= top && rect.bottom <= bottom; + && rect.top >= top && rect.bottom <= bottom; } + + +// #pragma mark - BeOS compatibility only +#if __GNUC__ == 2 + + +extern "C" BRect +InsetByCopy__5BRectG6BPoint(BRect* self, BPoint point) +{ + BRect copy(*self); + copy.InsetBy(point); + return copy; +} + + +extern "C" BRect +InsetByCopy__5BRectff(BRect* self, float dx, float dy) +{ + BRect copy(*self); + copy.InsetBy(dx, dy); + return copy; +} + + +extern "C" BRect +OffsetByCopy__5BRectG6BPoint(BRect* self, BPoint point) +{ + BRect copy(*self); + copy.OffsetBy(point); + return copy; +} + + +extern "C" BRect +OffsetByCopy__5BRectff(BRect* self, float dx, float dy) +{ + BRect copy(*self); + copy.OffsetBy(dx, dy); + return copy; +} + + +extern "C" BRect +OffsetToCopy__5BRectG6BPoint(BRect* self, BPoint point) +{ + BRect copy(*self); + copy.OffsetTo(point); + return copy; +} + + +extern "C" BRect +OffsetToCopy__5BRectff(BRect* self, float dx, float dy) +{ + BRect copy(*self); + copy.OffsetTo(dx, dy); + return copy; +} + + +#endif // __GNUC__ == 2 ############################################################################ Commit: 09d87d9151728f731c1d27e8914c5bbd6e72ec5b URL: http://cgit.haiku-os.org/haiku/commit/?id=09d87d9 Author: Axel DÃrfler <axeld@xxxxxxxxxxxxxxxx> Date: Sun Nov 4 14:23:09 2012 UTC The text control is now more flexible with its layout items. * Before, you had to have both, the text view layout item, and the label layout item or else nothing would ever be visible. * Now you can only create the text view item, and it will still work. * Also, no matter the order you added the layout items, they would always put the label on the left, and the control to the right. * You can place the label and text view layout items anywhere now, although you should keep in mind that the view spans over their frame unions; IOW they should always adjacent to each other, but not necessarily horizontally and left to right. * No longer uses a fixed label spacing, but utilizes BControlLook::DefaultLabelSpacing() instead. * However, the spacing is always added to the right of the label, no matter how you place it in the layout. Maybe one wants to add a SetLabelTextViewGap() like method. ---------------------------------------------------------------------------- diff --git a/headers/os/interface/TextControl.h b/headers/os/interface/TextControl.h index 456c6f1..aca56a1 100644 --- a/headers/os/interface/TextControl.h +++ b/headers/os/interface/TextControl.h @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010, Haiku, Inc. All rights reserved. + * Copyright 2006-2012, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _TEXT_CONTROL_H @@ -9,6 +9,7 @@ #include <Control.h> #include <TextView.h> + class BLayoutItem; namespace BPrivate { class _BTextInput_; @@ -22,14 +23,14 @@ public: BMessage* message, uint32 resizeMode = B_FOLLOW_LEFT | B_FOLLOW_TOP, - uint32 flags = B_WILL_DRAW | B_NAVIGABLE); + uint32 flags = B_WILL_DRAW | B_NAVIGABLE); BTextControl(const char* name, const char* label, const char* initialText, BMessage* message, - uint32 flags = B_WILL_DRAW | B_NAVIGABLE); + uint32 flags = B_WILL_DRAW | B_NAVIGABLE); BTextControl(const char* label, const char* initialText, - BMessage* message); + BMessage* message); virtual ~BTextControl(); BTextControl(BMessage* archive); diff --git a/src/kits/interface/TextControl.cpp b/src/kits/interface/TextControl.cpp index f0f64f4..90ee19d 100644 --- a/src/kits/interface/TextControl.cpp +++ b/src/kits/interface/TextControl.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2008, Haiku Inc. + * Copyright 2001-2012, Haiku Inc. * Distributed under the terms of the MIT License. * * Authors: @@ -8,12 +8,14 @@ * Ingo Weinhold <bonefish@xxxxxxxxxxxxxxx> */ + /*! BTextControl displays text that can act like a control. */ -#include <string.h> #include <TextControl.h> +#include <string.h> + #include <AbstractLayoutItem.h> #include <ControlLook.h> #include <LayoutUtils.h> @@ -82,8 +84,11 @@ public: virtual BSize BasePreferredSize(); virtual BAlignment BaseAlignment(); + BRect FrameInParent() const; + virtual status_t Archive(BMessage* into, bool deep = true) const; static BArchivable* Instantiate(BMessage* from); + private: BTextControl* fParent; BRect fFrame; @@ -109,6 +114,8 @@ public: virtual BSize BasePreferredSize(); virtual BAlignment BaseAlignment(); + BRect FrameInParent() const; + virtual status_t Archive(BMessage* into, bool deep = true) const; static BArchivable* Instantiate(BMessage* from); private: @@ -425,13 +432,17 @@ BTextControl::Draw(BRect updateRect) be_control_look->DrawTextControlBorder(this, rect, updateRect, base, flags); - rect = Bounds(); - rect.right = fDivider - kLabelInputSpacing; -// rect.right = fText->Frame().left - 2; -// rect.right -= 3;//be_control_look->DefaultLabelSpacing(); - be_control_look->DrawLabel(this, Label(), rect, updateRect, - base, flags, BAlignment(fLabelAlign, B_ALIGN_MIDDLE)); + if (Label() != NULL) { + if (fLayoutData->label_layout_item != NULL) { + rect = fLayoutData->label_layout_item->FrameInParent(); + } else { + rect = Bounds(); + rect.right = fDivider - kLabelInputSpacing; + } + be_control_look->DrawLabel(this, Label(), rect, updateRect, + base, flags, BAlignment(fLabelAlign, B_ALIGN_MIDDLE)); + } return; } @@ -524,9 +535,8 @@ BTextControl::Draw(BRect updateRect) void BTextControl::MouseDown(BPoint where) { - if (!fText->IsFocus()) { + if (!fText->IsFocus()) fText->MakeFocus(true); - } } @@ -892,23 +902,28 @@ BTextControl::DoLayout() if (size.height < fLayoutData->min.height) size.height = fLayoutData->min.height; + BRect dirty(fText->Frame()); + BRect textFrame; + // divider float divider = 0; - if (fLayoutData->label_layout_item && fLayoutData->text_view_layout_item) { - // We have layout items. They define the divider location. - divider = fLayoutData->text_view_layout_item->Frame().left - - fLayoutData->label_layout_item->Frame().left; + if (fLayoutData->text_view_layout_item != NULL) { + if (fLayoutData->label_layout_item != NULL) { + // We have layout items. They define the divider location. + divider = fabs(fLayoutData->text_view_layout_item->Frame().left + - fLayoutData->label_layout_item->Frame().left); + } + textFrame = fLayoutData->text_view_layout_item->FrameInParent(); } else { - if (fLayoutData->label_width > 0) - divider = fLayoutData->label_width + 5; + if (fLayoutData->label_width > 0) { + divider = fLayoutData->label_width + + be_control_look->DefaultLabelSpacing(); + } + textFrame.Set(divider, 0, size.width, size.height); } - // text view - BRect dirty(fText->Frame()); - BRect textFrame(divider + kFrameMargin, kFrameMargin, - size.width - kFrameMargin, size.height - kFrameMargin); - // place the text view and set the divider + textFrame.InsetBy(kFrameMargin, kFrameMargin); BLayoutUtils::AlignInFrame(fText, textFrame); fDivider = divider; @@ -1071,7 +1086,6 @@ BTextControl::_InitData(const char* label, const BMessage* archive) if (label) fDivider = floorf(bounds.Width() / 2.0f); - } @@ -1139,8 +1153,14 @@ BTextControl::_LayoutTextView() { CALLED(); - BRect frame = Bounds(); - frame.left = fDivider; + BRect frame; + if (fLayoutData->text_view_layout_item != NULL) { + frame = fLayoutData->text_view_layout_item->FrameInParent(); + } else { + frame = Bounds(); + frame.left = fDivider; + } + // we are stroking the frame around the text view, which // is 2 pixels wide frame.InsetBy(kFrameMargin, kFrameMargin); @@ -1160,17 +1180,26 @@ BTextControl::_UpdateFrame() { CALLED(); - if (fLayoutData->label_layout_item && fLayoutData->text_view_layout_item) { - BRect labelFrame = fLayoutData->label_layout_item->Frame(); + if (fLayoutData->text_view_layout_item != NULL) { BRect textFrame = fLayoutData->text_view_layout_item->Frame(); + BRect labelFrame; + if (fLayoutData->label_layout_item != NULL) + labelFrame = fLayoutData->label_layout_item->Frame(); + + BRect frame; + if (labelFrame.IsValid()) { + frame = textFrame | labelFrame; + + // update divider + fDivider = fabs(textFrame.left - labelFrame.left); + } else { + frame = textFrame; + fDivider = 0; + } - // update divider - fDivider = textFrame.left - labelFrame.left; - - MoveTo(labelFrame.left, labelFrame.top); + MoveTo(frame.left, frame.top); BSize oldSize = Bounds().Size(); - ResizeTo(textFrame.left + textFrame.Width() - labelFrame.left, - textFrame.top + textFrame.Height() - labelFrame.top); + ResizeTo(frame.Width(), frame.Height()); BSize newSize = Bounds().Size(); // If the size changes, ResizeTo() will trigger a relayout, otherwise @@ -1203,8 +1232,10 @@ BTextControl::_ValidateLayoutData() // compute the minimal divider float divider = 0; - if (fLayoutData->label_width > 0) - divider = fLayoutData->label_width + 5; + if (fLayoutData->label_width > 0) { + divider = fLayoutData->label_width + + be_control_look->DefaultLabelSpacing(); + } // If we shan't do real layout, we let the current divider take influence. if (!(Flags() & B_SUPPORTS_LAYOUT)) @@ -1306,7 +1337,8 @@ BTextControl::LabelLayoutItem::BaseMinSize() if (!fParent->Label()) return BSize(-1, -1); - return BSize(fParent->fLayoutData->label_width + 5, + return BSize(fParent->fLayoutData->label_width + + be_control_look->DefaultLabelSpacing(), fParent->fLayoutData->label_height); } @@ -1332,6 +1364,13 @@ BTextControl::LabelLayoutItem::BaseAlignment() } +BRect +BTextControl::LabelLayoutItem::FrameInParent() const +{ + return fFrame.OffsetByCopy(-fParent->Frame().left, -fParent->Frame().top); +} + + status_t BTextControl::LabelLayoutItem::Archive(BMessage* into, bool deep) const { @@ -1459,6 +1498,13 @@ BTextControl::TextViewLayoutItem::BaseAlignment() } +BRect +BTextControl::TextViewLayoutItem::FrameInParent() const +{ + return fFrame.OffsetByCopy(-fParent->Frame().left, -fParent->Frame().top); +} + + status_t BTextControl::TextViewLayoutItem::Archive(BMessage* into, bool deep) const { ############################################################################ Commit: 9e42a44cad6e56c2a04b9ee1b76446fdd2916a62 URL: http://cgit.haiku-os.org/haiku/commit/?id=9e42a44 Author: Axel DÃrfler <axeld@xxxxxxxxxxxxxxxx> Date: Sun Nov 4 16:21:12 2012 UTC Added BPath::IsAbsolute() method. ---------------------------------------------------------------------------- diff --git a/headers/os/storage/Path.h b/headers/os/storage/Path.h index 13438a4..d12723a 100644 --- a/headers/os/storage/Path.h +++ b/headers/os/storage/Path.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009, Haiku, Inc. All Rights Reserved. + * Copyright 2002-2012, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _PATH_H @@ -25,7 +25,7 @@ public: BPath(const BEntry* entry); BPath(const char* dir, const char* leaf = NULL, bool normalize = false); - BPath(const BDirectory* dir, + BPath(const BDirectory* dir, const char* leaf = NULL, bool normalize = false); @@ -37,7 +37,7 @@ public: status_t SetTo(const BEntry* entry); status_t SetTo(const char* path, const char* leaf = NULL, bool normalize = false); - status_t SetTo(const BDirectory* dir, + status_t SetTo(const BDirectory* dir, const char* leaf = NULL, bool normalize = false); void Unset(); @@ -47,6 +47,7 @@ public: const char* Path() const; const char* Leaf() const; status_t GetParent(BPath* path) const; + bool IsAbsolute() const; bool operator==(const BPath& item) const; bool operator==(const char* path) const; diff --git a/src/kits/storage/Path.cpp b/src/kits/storage/Path.cpp index 7ba3171..7c61299 100644 --- a/src/kits/storage/Path.cpp +++ b/src/kits/storage/Path.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009, Haiku Inc. + * Copyright 2002-2012, Haiku Inc. * Distributed under the terms of the MIT License. * * Authors: @@ -7,11 +7,13 @@ * Ingo Weinhold, bonefish@xxxxxxxxxxxx */ + /*! \file Path.cpp BPath implementation. */ + #include <Path.h> #include <new> @@ -402,6 +404,16 @@ BPath::GetParent(BPath* path) const } +bool +BPath::IsAbsolute() const +{ + if (InitCheck() != B_OK) + return false; + + return fName[0] == '/'; +} + + /*! \brief Performs a simple (string-wise) comparison of paths. No normalization takes place! Uninitialized BPath objects are considered to be equal. ############################################################################ Commit: 762e4ecaffb1bbaa3fef83ea8fc2b14554aa1c1b URL: http://cgit.haiku-os.org/haiku/commit/?id=762e4ec Author: Axel DÃrfler <axeld@xxxxxxxxxxxxxxxx> Date: Sun Nov 4 16:21:47 2012 UTC BMessage::Append() is now actually working. ---------------------------------------------------------------------------- diff --git a/src/kits/app/Message.cpp b/src/kits/app/Message.cpp index ecfa625..09bf7e4 100644 --- a/src/kits/app/Message.cpp +++ b/src/kits/app/Message.cpp @@ -2729,16 +2729,17 @@ BMessage::Append(const BMessage &other) size_t size = field->data_size / field->count; for (uint32 j = 0; j < field->count; j++) { - if (!isFixed) + if (!isFixed) { size = *(uint32 *)data; + data = (const void *)((const char *)data + sizeof(uint32)); + } status_t status = AddData(name, field->type, data, size, - isFixed != 0, 1); + isFixed, 1); if (status != B_OK) return status; - data = (const void *)((const char *)data + size - + (isFixed ? 0 : sizeof(uint32))); + data = (const void *)((const char *)data + size); } } return B_OK; ############################################################################ Revision: hrev44760 Commit: 17ad59afd3b25f230efd7231a3315e344ef73ae0 URL: http://cgit.haiku-os.org/haiku/commit/?id=17ad59a Author: Axel DÃrfler <axeld@xxxxxxxxxxxxxxxx> Date: Sun Nov 4 16:22:32 2012 UTC Added BLayoutBuilder::{Group|Grid}::SetExplicitAlignment(). ---------------------------------------------------------------------------- diff --git a/headers/os/interface/LayoutBuilder.h b/headers/os/interface/LayoutBuilder.h index 7e9bda0..3b50c7d 100644 --- a/headers/os/interface/LayoutBuilder.h +++ b/headers/os/interface/LayoutBuilder.h @@ -111,6 +111,7 @@ public: inline ThisBuilder& SetExplicitMinSize(BSize size); inline ThisBuilder& SetExplicitMaxSize(BSize size); inline ThisBuilder& SetExplicitPreferredSize(BSize size); + inline ThisBuilder& SetExplicitAlignment(BAlignment alignment); inline operator BGroupLayout*(); @@ -206,6 +207,7 @@ public: inline ThisBuilder& SetExplicitMinSize(BSize size); inline ThisBuilder& SetExplicitMaxSize(BSize size); inline ThisBuilder& SetExplicitPreferredSize(BSize size); + inline ThisBuilder& SetExplicitAlignment(BAlignment alignment); inline operator BGridLayout*(); @@ -643,6 +645,15 @@ Group<ParentBuilder>::SetExplicitPreferredSize(BSize size) template<typename ParentBuilder> +typename Group<ParentBuilder>::ThisBuilder& +Group<ParentBuilder>::SetExplicitAlignment(BAlignment alignment) +{ + fLayout->SetExplicitAlignment(alignment); + return *this; +} + + +template<typename ParentBuilder> Group<ParentBuilder>::operator BGroupLayout*() { return fLayout; @@ -956,6 +967,15 @@ Grid<ParentBuilder>::SetExplicitPreferredSize(BSize size) template<typename ParentBuilder> +typename Grid<ParentBuilder>::ThisBuilder& +Grid<ParentBuilder>::SetExplicitAlignment(BAlignment alignment) +{ + fLayout->SetExplicitAlignment(alignment); + return *this; +} + + +template<typename ParentBuilder> Grid<ParentBuilder>::operator BGridLayout*() { return fLayout;