Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/Wt/WBoxLayout.C
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ std::unique_ptr<WLayoutItem> WBoxLayout::removeItem(WLayoutItem *item)
int index = indexOf(item);

if (index != -1) {
switch (direction_) {
switch (direction()) {
case LayoutDirection::RightToLeft:
if ((impl() && implementation() != LayoutImplementation::Flex) || !implementationIsFlexLayout())
index = grid_.columns_.size() - 1 - index;
Expand Down Expand Up @@ -107,10 +107,10 @@ int WBoxLayout::count() const
return grid_.rows_.size() * grid_.columns_.size();
}

void WBoxLayout::setDirection(LayoutDirection direction)
void WBoxLayout::setDirection(LayoutDirection dir)
{
if (direction_ != direction) {
direction_ = direction;
if (direction() != dir) {
direction_ = dir;
}
}

Expand Down Expand Up @@ -207,7 +207,7 @@ bool WBoxLayout::setStretchFactor(WLayout *layout, int stretch)

void WBoxLayout::setStretchFactor(int i, int stretch)
{
switch (direction_) {
switch (direction()) {
case LayoutDirection::RightToLeft:
if ((impl() && implementation() != LayoutImplementation::Flex) || !implementationIsFlexLayout())
i = grid_.columns_.size() - 1 - i;
Expand All @@ -229,7 +229,7 @@ void WBoxLayout::insertItem(int index, std::unique_ptr<WLayoutItem> item,
{
WLayoutItem *it = item.get();

switch (direction_) {
switch (direction()) {
case LayoutDirection::RightToLeft:
if ((impl() && implementation() != LayoutImplementation::Flex) || !implementationIsFlexLayout())
index = grid_.columns_.size() - index;
Expand Down Expand Up @@ -270,8 +270,8 @@ std::unique_ptr<WWidget> WBoxLayout::createSpacer(const WLength& size)
std::unique_ptr<Spacer> spacer(new Spacer());

if (size.toPixels() > 0) {
if (direction_ == LayoutDirection::LeftToRight ||
direction_ == LayoutDirection::RightToLeft)
if (direction() == LayoutDirection::LeftToRight ||
direction() == LayoutDirection::RightToLeft)
spacer->setMinimumSize(size, WLength::Auto);
else
spacer->setMinimumSize(WLength::Auto, size);
Expand All @@ -289,7 +289,7 @@ void WBoxLayout::setResizable(int index, bool enabled,
setPreferredImplementation(LayoutImplementation::JavaScript);
}

switch (direction_) {
switch (direction()) {
case LayoutDirection::RightToLeft:
if ((impl() && implementation() != LayoutImplementation::Flex) || !implementationIsFlexLayout())
index = grid_.columns_.size() - 1 - index;
Expand Down
5 changes: 3 additions & 2 deletions src/Wt/WBoxLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ class WT_API WBoxLayout : public WLayout
*
* \sa direction()
*/
void setDirection(LayoutDirection direction);
virtual void setDirection(LayoutDirection dir);

/*! \brief Returns the layout direction.
*
* \sa setDirection()
*/
LayoutDirection direction() const { return direction_; }
virtual LayoutDirection direction() { return direction_; }

/*! \brief Sets spacing between each item.
*
Expand Down Expand Up @@ -386,6 +386,7 @@ class WT_API WBoxLayout : public WLayout
virtual bool implementationIsFlexLayout() const override;

protected:
WBoxLayout(){}
void insertItem(int index, std::unique_ptr<WLayoutItem> item, int stretch,
WFlags<AlignmentFlag> alignment);

Expand Down
21 changes: 20 additions & 1 deletion src/Wt/WHBoxLayout.C
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,30 @@
*/

#include "Wt/WHBoxLayout.h"
#include "Wt/WApplication.h"

namespace Wt {

WHBoxLayout::WHBoxLayout()
: WBoxLayout(LayoutDirection::LeftToRight)
: syncDirection_(false)
{ }

void WHBoxLayout::setDirection (LayoutDirection dir)
{
syncDirection_ = true;
WBoxLayout::setDirection (dir);
}

LayoutDirection WHBoxLayout::direction (void)
{

if (false == syncDirection_)
{

syncDirection_ = true;
WBoxLayout::setDirection (WApplication::instance()->layoutDirection());
}

return (WBoxLayout::direction());
}
}
5 changes: 5 additions & 0 deletions src/Wt/WHBoxLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ class WT_API WHBoxLayout : public WBoxLayout
/*! \brief Creates a new horizontal box layout.
*/
WHBoxLayout();
void setDirection (LayoutDirection dir) override;
LayoutDirection direction(void) override;

private:
bool syncDirection_;
};

}
Expand Down