Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef FREE_LAYOUT_H
Toshihiro Shimizu 890ddd
#define FREE_LAYOUT_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzCore includes
Toshihiro Shimizu 890ddd
#include "tcommon.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// Qt includes
Toshihiro Shimizu 890ddd
#include <qlist></qlist>
Toshihiro Shimizu 890ddd
#include <qlayout></qlayout>
Toshihiro Shimizu 890ddd
#include <qwidget></qwidget>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
#ifdef TOONZQT_EXPORTS
Toshihiro Shimizu 890ddd
#define DVAPI DV_EXPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_EXPORT_VAR
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define DVAPI DV_IMPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_IMPORT_VAR
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//************************************************************************************
Toshihiro Shimizu 890ddd
//    DummyLayout   declaration
Toshihiro Shimizu 890ddd
//************************************************************************************
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Shinya Kitaoka 120a6e
  \brief    The DummyLayout class implements a layout whose items' geometry is
Shinya Kitaoka 120a6e
  not
Toshihiro Shimizu 890ddd
            enforced at all, ignoring parent size bounds or geometry.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
  \details  A DummyLayout serves as a simple, inert container of layout items.
Toshihiro Shimizu 890ddd
            It does not enforce geometry to items added to it, allowing objects
Toshihiro Shimizu 890ddd
            using this layout to appear as a 'viewport' for free-geometry items.
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  \note     As this layout does not effectively manage its objects' geometry,
Shinya Kitaoka 120a6e
  these
Toshihiro Shimizu 890ddd
            must be managed outside.
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI DummyLayout : public QLayout {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  DummyLayout();
Shinya Kitaoka 120a6e
  virtual ~DummyLayout();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  QSize sizeHint() const override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  QSize minimumSize() const override { return QSize(0, 0); }
Shinya Kitaoka 38fd86
  QSize maximumSize() const override {
Shinya Kitaoka 38fd86
    return QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
Shinya Kitaoka 38fd86
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  int count() const override { return m_items.count(); }
Shinya Kitaoka 473e70
  void addItem(QLayoutItem *item) override { m_items.push_back(item); }
Shinya Kitaoka 473e70
  QLayoutItem *itemAt(int index) const override {
Shinya Kitaoka 120a6e
    return (index < count()) ? m_items.at(index) : 0;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 473e70
  QLayoutItem *takeAt(int index) override {
Shinya Kitaoka 120a6e
    return (index < count()) ? m_items.takeAt(index) : 0;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void setGeometry(const QRect &r) override {}
Shinya Kitaoka 120a6e
  // Qt::Orientations	expandingDirections () const { return
Shinya Kitaoka 120a6e
  // Qt::Orientations(); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  QList<qlayoutitem *=""> m_items;</qlayoutitem>
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//************************************************************************************
Toshihiro Shimizu 890ddd
//    FreeLayout   declaration
Toshihiro Shimizu 890ddd
//************************************************************************************
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Toshihiro Shimizu 890ddd
  \brief    The FreeLayout class implements a layout whose items can be freely
Toshihiro Shimizu 890ddd
            positioned, ignoring parent size bounds or geometry.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
  \details  A FreeLayout instance can be used to achieve results similar to that
Shinya Kitaoka 120a6e
            of a QScrollArea, with a more straightforward API and without
Shinya Kitaoka 120a6e
  restriction
Shinya Kitaoka 120a6e
            to just one item at a time. Please observe that layouts can be
Shinya Kitaoka 120a6e
  inserted too.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
            Specifically, FreeLayout is a convenience subclass of DummyLayout
Shinya Kitaoka 120a6e
  whose items'
Shinya Kitaoka 120a6e
            sizes are enforced to their sizeHint() - in order to spare users
Shinya Kitaoka 120a6e
  from having to deal
Shinya Kitaoka 120a6e
            with it externally. This complies with the idea that its items are
Shinya Kitaoka 120a6e
  comfortly
Shinya Kitaoka 120a6e
            free to adapt to their preferred size, as it would be in a
Shinya Kitaoka 120a6e
  scrollable environment.
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class FreeLayout final : public DummyLayout {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  FreeLayout() : DummyLayout() {}
Shinya Kitaoka 120a6e
  ~FreeLayout() {}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void setGeometry(const QRect &r) override;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
#endif  // FREE_LAYOUT_H