2019-09-20 09:34:29 +03:00
|
|
|
/*
|
2020-04-18 09:27:42 +03:00
|
|
|
* Copyright 2020 Haiku, Inc. All rights reserved.
|
2019-09-20 09:34:29 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
2020-04-18 09:27:42 +03:00
|
|
|
* Niels Sascha Reedijk, niels.reedijk@gmail.com
|
2019-09-20 09:34:29 +03:00
|
|
|
*
|
|
|
|
* Corresponds to:
|
|
|
|
* headers/os/interface/SpaceLayoutItem.h hrev43514
|
|
|
|
* src/kits/interface/SpaceLayoutItem.cpp hrev44346
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\file SpaceLayoutItem.h
|
|
|
|
\ingroup layout
|
2020-04-18 09:27:42 +03:00
|
|
|
\brief Provides the BSpaceLayoutItem class.
|
2019-09-20 09:34:29 +03:00
|
|
|
|
|
|
|
\since Haiku R1
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\class BSpaceLayoutItem
|
|
|
|
\ingroup layout
|
|
|
|
\ingroup libbe
|
2020-04-18 09:27:42 +03:00
|
|
|
\brief An empty layout item that expands into empty space based on its size
|
|
|
|
configuration.
|
2019-09-20 09:34:29 +03:00
|
|
|
|
2020-04-18 09:27:42 +03:00
|
|
|
This class is a specialized layout item, that is used to distribute space
|
|
|
|
within one of the layouts. The layout item can be manually configured, but
|
|
|
|
there are also two default varieties.
|
2019-09-20 09:34:29 +03:00
|
|
|
|
2020-04-18 09:27:42 +03:00
|
|
|
The first variety is the \b glue variety. Glue is an element that expands
|
|
|
|
to the maximum space that is available. Let's say, you have a horizontal
|
|
|
|
BGroupLayout. You want a button on the left, and a button on the right,
|
|
|
|
with empty space in the middle. The middle element can be a glue element.
|
|
|
|
The glue will push the right button all the way to the end of the available
|
|
|
|
space. If the host view gets larger, the glue will expand. You can use the
|
|
|
|
static method BSpaceLayoutItem::CreateGlue() to easily create a glue
|
|
|
|
element.
|
2019-09-20 09:34:29 +03:00
|
|
|
|
2020-04-18 09:27:42 +03:00
|
|
|
Another variety is the \b strut. A is a layout item with no minimum size,
|
|
|
|
and a maximum size. This means that the item might be smaller than the
|
|
|
|
maximum size, but it will never be larger than the maximum size. You can
|
|
|
|
use the static methods BSpaceLayoutItem::CreateVerticalStrut() and
|
|
|
|
BSpaceLayoutItem::CreateHorizontalStrut() to create a strut item.
|
2019-09-20 09:34:29 +03:00
|
|
|
|
2020-04-18 09:27:42 +03:00
|
|
|
The default constructor allows you to create a layout item with custom
|
|
|
|
minimum sizes, maximum sizes, preferred sizes and alignments.
|
2019-09-20 09:34:29 +03:00
|
|
|
|
2020-04-18 09:27:42 +03:00
|
|
|
\see Where applicable, the layout builder classes have convenience methods
|
|
|
|
to add glue or struts. See
|
|
|
|
BLayoutBuilder::Group<ParentBuilder>::AddGlue() or
|
|
|
|
BLayoutBuilder::Group<ParentBuilder>::AddStrut().
|
2019-09-20 09:34:29 +03:00
|
|
|
|
|
|
|
\since Haiku R1
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2020-04-18 09:27:42 +03:00
|
|
|
\fn BSpaceLayoutItem::BSpaceLayoutItem(BSize minSize, BSize maxSize,
|
|
|
|
BSize preferredSize, BAlignment alignment)
|
|
|
|
\brief Create a space layout item with specific properties.
|
2019-09-20 09:34:29 +03:00
|
|
|
|
2020-04-18 09:27:42 +03:00
|
|
|
See the CreateGlue(), CreateVerticalStrut() and CreateHorizontalStruct
|
|
|
|
static methods to create common space items.
|
2019-09-20 09:34:29 +03:00
|
|
|
|
2020-04-18 09:27:42 +03:00
|
|
|
\param minSize The minimum size for this item.
|
|
|
|
\param maxSize The maximum size for this item.
|
|
|
|
\param preferredSize The preferred size for this item.
|
|
|
|
\param alignment The alignment of this item.
|
2019-09-20 09:34:29 +03:00
|
|
|
|
|
|
|
\since Haiku R1
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2020-04-18 09:27:42 +03:00
|
|
|
\fn BSpaceLayoutItem::BSpaceLayoutItem(BMessage *archive)
|
|
|
|
\brief Constructs a BSpaceLayoutItem from an \a archive message.
|
|
|
|
|
|
|
|
This method is usually not called directly, if you want to build a
|
|
|
|
space layout item from an archived message you should call Instantiate()
|
|
|
|
instead because it can handle errors properly.
|
2019-09-20 09:34:29 +03:00
|
|
|
|
2020-04-18 09:27:42 +03:00
|
|
|
\param archive The \ref BMessage that contains the space layout item.
|
2019-09-20 09:34:29 +03:00
|
|
|
|
|
|
|
\since Haiku R1
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2020-04-18 09:27:42 +03:00
|
|
|
\fn virtual BSpaceLayoutItem::~BSpaceLayoutItem()
|
|
|
|
\brief Destructor.
|
2019-09-20 09:34:29 +03:00
|
|
|
|
|
|
|
\since Haiku R1
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2020-04-18 09:27:42 +03:00
|
|
|
\fn virtual BSize BSpaceLayoutItem::MinSize()
|
|
|
|
\copydoc BLayoutItem::MinSize()
|
2019-09-20 09:34:29 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2020-04-18 09:27:42 +03:00
|
|
|
\fn virtual BSize BSpaceLayoutItem::MaxSize()
|
|
|
|
\copydoc BLayoutItem::MaxSize()
|
2019-09-20 09:34:29 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2020-04-18 09:27:42 +03:00
|
|
|
\fn virtual BSize BSpaceLayoutItem::PreferredSize()
|
|
|
|
\copydoc BLayoutItem::PreferredSize()
|
2019-09-20 09:34:29 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2020-04-18 09:27:42 +03:00
|
|
|
\fn virtual BAlignment BSpaceLayoutItem::Alignment()
|
|
|
|
\copydoc BLayoutItem::Alignment()
|
2019-09-20 09:34:29 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2020-04-18 09:27:42 +03:00
|
|
|
\fn virtual void BSpaceLayoutItem::SetExplicitMinSize(BSize size)
|
|
|
|
\copydoc BLayoutItem::SetExplicitMinSize()
|
2019-09-20 09:34:29 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2020-04-18 09:27:42 +03:00
|
|
|
\fn virtual void BSpaceLayoutItem::SetExplicitMaxSize(BSize size)
|
|
|
|
\copydoc BLayoutItem::SetExplicitMaxSize()
|
2019-09-20 09:34:29 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2020-04-18 09:27:42 +03:00
|
|
|
\fn virtual void BSpaceLayoutItem::SetExplicitPreferredSize(
|
|
|
|
BSize size)
|
|
|
|
\copydoc BLayoutItem::SetExplicitPreferredSize()
|
|
|
|
*/
|
2019-09-20 09:34:29 +03:00
|
|
|
|
|
|
|
|
2020-04-18 09:27:42 +03:00
|
|
|
/*!
|
|
|
|
\fn virtual void BSpaceLayoutItem::SetExplicitAlignment(
|
|
|
|
BAlignment alignment)
|
|
|
|
\copydoc BLayoutItem::SetExplicitAlignment()
|
2019-09-20 09:34:29 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn virtual virtual bool BSpaceLayoutItem::IsVisible()
|
2020-04-18 09:27:42 +03:00
|
|
|
\brief Return the current local visibility of this item.
|
2019-09-20 09:34:29 +03:00
|
|
|
|
2020-04-18 09:27:42 +03:00
|
|
|
The visibility is set explicitly through SetVisible(). By default, the
|
|
|
|
layout item is visible.
|
2019-09-20 09:34:29 +03:00
|
|
|
|
|
|
|
\since Haiku R1
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2020-04-18 09:27:42 +03:00
|
|
|
\fn virtual void BSpaceLayoutItem::SetVisible(bool visible)
|
|
|
|
\brief Set the visibility of this space layout item.
|
2019-09-20 09:34:29 +03:00
|
|
|
|
2020-04-18 09:27:42 +03:00
|
|
|
\param visible The desired visibility of the layout item.
|
2019-09-20 09:34:29 +03:00
|
|
|
|
|
|
|
\since Haiku R1
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2020-04-18 09:27:42 +03:00
|
|
|
\fn virtual BRect BSpaceLayoutItem::Frame()
|
|
|
|
\copydoc BLayoutItem::Frame()
|
2019-09-20 09:34:29 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2020-04-18 09:27:42 +03:00
|
|
|
\fn virtual void BSpaceLayoutItem::SetFrame(BRect frame)
|
|
|
|
\copydoc BLayoutItem::SetFrame()
|
2019-09-20 09:34:29 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2020-04-18 09:27:42 +03:00
|
|
|
\fn static BSpaceLayoutItem* BSpaceLayoutItem::CreateGlue()
|
|
|
|
\brief Create a layout item that acts like glue.
|
2019-09-20 09:34:29 +03:00
|
|
|
|
2020-04-18 09:27:42 +03:00
|
|
|
This type of space layout item has no minimum size, and expands to the
|
|
|
|
maximum available space in all directions.
|
2019-09-20 09:34:29 +03:00
|
|
|
|
2020-04-18 09:27:42 +03:00
|
|
|
\return Creates a new BSpaceLayoutItem and returns ownership to the caller.
|
2019-09-20 09:34:29 +03:00
|
|
|
|
|
|
|
\since Haiku R1
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2020-04-18 09:27:42 +03:00
|
|
|
\fn static BSpaceLayoutItem* BSpaceLayoutItem::CreateHorizontalStrut(
|
|
|
|
float width)
|
|
|
|
\brief Create a layout item that horizontally expands to a maximum
|
|
|
|
\a width.
|
2019-09-20 09:34:29 +03:00
|
|
|
|
2020-04-18 09:27:42 +03:00
|
|
|
The item has no minimum size, meaning that if the total available width is
|
|
|
|
smaller than the maximum \a width, the strut will use the available space.
|
2019-09-20 09:34:29 +03:00
|
|
|
|
2020-04-18 09:27:42 +03:00
|
|
|
\param width The maximum width.
|
2019-09-20 09:34:29 +03:00
|
|
|
|
2020-04-18 09:27:42 +03:00
|
|
|
\return Creates a new BSpaceLayoutItem and returns ownership to the caller.
|
2019-09-20 09:34:29 +03:00
|
|
|
|
|
|
|
\since Haiku R1
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn static static BSpaceLayoutItem* BSpaceLayoutItem::CreateVerticalStrut(float height)
|
2020-04-18 09:27:42 +03:00
|
|
|
\brief Create a layout item that vertically expands to a maximum
|
|
|
|
\a height.
|
|
|
|
|
|
|
|
The item has no minimum size, meaning that if the total available height is
|
|
|
|
smaller than the maximum \a width, the strut will use the available space.
|
2019-09-20 09:34:29 +03:00
|
|
|
|
2020-04-18 09:27:42 +03:00
|
|
|
\param height The maximum height.
|
2019-09-20 09:34:29 +03:00
|
|
|
|
2020-04-18 09:27:42 +03:00
|
|
|
\return Creates a new BSpaceLayoutItem and returns ownership to the caller.
|
2019-09-20 09:34:29 +03:00
|
|
|
|
|
|
|
\since Haiku R1
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2020-04-18 09:27:42 +03:00
|
|
|
\fn static BArchivable* BSpaceLayoutItem::Instantiate(BMessage *from)
|
|
|
|
\brief Instantiate the item from the message \a from.
|
2019-09-20 09:34:29 +03:00
|
|
|
|
|
|
|
\since Haiku R1
|
|
|
|
*/
|