Files
bullet3/examples/ThirdPartyLibs/Gwen/Controls/Layout/Splitter.h
erwincoumans ab8f16961e Code-style consistency improvement:
Apply clang-format-all.sh using the _clang-format file through all the cpp/.h files.
make sure not to apply it to certain serialization structures, since some parser expects the * as part of the name, instead of type.
This commit contains no other changes aside from adding and applying clang-format-all.sh
2018-09-23 14:17:31 -07:00

83 lines
1.3 KiB
C++

/*
GWEN
Copyright (c) 2010 Facepunch Studios
See license in Gwen.h
*/
#pragma once
#ifndef GWEN_CONTROLS_LAYOUT_SPLITTER_H
#define GWEN_CONTROLS_LAYOUT_SPLITTER_H
#include "Gwen/Controls/Base.h"
namespace Gwen
{
namespace Controls
{
namespace Layout
{
class GWEN_EXPORT Splitter : public Base
{
public:
typedef Base BaseClass;
Splitter(Base* pParent) : BaseClass(pParent)
{
for (int i = 0; i < 2; i++)
m_pPanel[i] = NULL;
}
void SetPanel(int i, Base* pPanel)
{
if (i < 0 || i > 1) return;
m_pPanel[i] = pPanel;
if (m_pPanel[i])
{
m_pPanel[i]->SetParent(this);
}
}
Base* GetPanel(int i) const
{
if (i < 0 || i > 1) return NULL;
return m_pPanel[i];
}
void Layout(Skin::Base* skin)
{
LayoutVertical(skin);
}
private:
void LayoutVertical(Skin::Base* /*skin*/)
{
int w = Width();
int h = Height();
if (m_pPanel[0])
{
const Margin& m = m_pPanel[0]->GetMargin();
m_pPanel[0]->SetBounds(m.left, m.top, w - m.left - m.right, (h * 0.5) - m.top - m.bottom);
}
if (m_pPanel[1])
{
const Margin& m = m_pPanel[1]->GetMargin();
m_pPanel[1]->SetBounds(m.left, m.top + (h * 0.5f), w - m.left - m.right, (h * 0.5f) - m.top - m.bottom);
}
}
void LayoutHorizontal(Skin::Base* /*skin*/)
{
// Todo.
}
Base* m_pPanel[2];
};
} // namespace Layout
} // namespace Controls
} // namespace Gwen
#endif