PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: Splitter.h * 00003 * 00004 * Copyright (C) 2002-2011 The PixelLight Team (http://www.pixellight.org/) 00005 * 00006 * This file is part of PixelLight. 00007 * 00008 * PixelLight is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License as published by 00010 * the Free Software Foundation, either version 3 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * PixelLight is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public License 00019 * along with PixelLight. If not, see <http://www.gnu.org/licenses/>. 00020 \*********************************************************/ 00021 00022 00023 #ifndef __PLGUI_SPLITTER_H__ 00024 #define __PLGUI_SPLITTER_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include "PLGui/Widgets/Widget.h" 00032 00033 00034 //[-------------------------------------------------------] 00035 //[ Namespace ] 00036 //[-------------------------------------------------------] 00037 namespace PLGui { 00038 00039 00040 //[-------------------------------------------------------] 00041 //[ Classes ] 00042 //[-------------------------------------------------------] 00043 /** 00044 * @brief 00045 * Container widget that splits an area into two sides 00046 */ 00047 class Splitter : public Widget { 00048 00049 00050 //[-------------------------------------------------------] 00051 //[ Class definition ] 00052 //[-------------------------------------------------------] 00053 pl_class(PLGUI_RTTI_EXPORT, Splitter, "PLGui", PLGui::Widget, "Container widget that splits an area into two sides") 00054 // Attributes 00055 pl_attribute(Orientation, pl_enum_type(EOrientation), Horizontal, ReadWrite, GetSet, "Orientation", "") 00056 pl_attribute(Sizable, bool, true, ReadWrite, GetSet, "Is the widget sizable?", "") 00057 pl_attribute(SizeLeft, SizeHint, SizeHint(), ReadWrite, GetSet, "Size of left (or top) container", "") 00058 pl_attribute(SizeRight, SizeHint, SizeHint(), ReadWrite, GetSet, "Size of right (or bottom) container", "") 00059 // Constructors 00060 pl_constructor_0(DefaultConstructor, "Default constructor", "") 00061 pl_class_end 00062 00063 00064 //[-------------------------------------------------------] 00065 //[ Public functions ] 00066 //[-------------------------------------------------------] 00067 public: 00068 /** 00069 * @brief 00070 * Constructor 00071 * 00072 * @param[in] pParent 00073 * Pointer to parent widget 00074 */ 00075 PLGUI_API Splitter(Widget *pParent = nullptr); 00076 00077 /** 00078 * @brief 00079 * Destructor 00080 */ 00081 PLGUI_API virtual ~Splitter(); 00082 00083 /** 00084 * @brief 00085 * Get orientation 00086 * 00087 * @return 00088 * Orientation 00089 */ 00090 PLGUI_API EOrientation GetOrientation() const; 00091 00092 /** 00093 * @brief 00094 * Set orientation 00095 * 00096 * @param[in] nOrientation 00097 * Orientation 00098 */ 00099 PLGUI_API void SetOrientation(EOrientation nOrientation); 00100 00101 /** 00102 * @brief 00103 * Check if size can be altered by the user 00104 * 00105 * @return 00106 * 'true' if sizable, else 'false' 00107 */ 00108 PLGUI_API bool GetSizable() const; 00109 00110 /** 00111 * @brief 00112 * Set if size can be altered by the user 00113 * 00114 * @param[in] bSizable 00115 * 'true' if sizable, else 'false' 00116 */ 00117 PLGUI_API void SetSizable(bool bSizable); 00118 00119 /** 00120 * @brief 00121 * Get size of left (or top) side 00122 * 00123 * @return 00124 * Size hint 00125 */ 00126 PLGUI_API const SizeHint &GetSizeLeft() const; 00127 00128 /** 00129 * @brief 00130 * Set size of left (or top) side 00131 * 00132 * @param[in] cSize 00133 * Size hint 00134 */ 00135 PLGUI_API void SetSizeLeft(const SizeHint &cSize); 00136 00137 /** 00138 * @brief 00139 * Get size of right (or bottom) side 00140 * 00141 * @return 00142 * Size hint 00143 */ 00144 PLGUI_API const SizeHint &GetSizeRight() const; 00145 00146 /** 00147 * @brief 00148 * Set size of right (or bottom) side 00149 * 00150 * @param[in] cSize 00151 * Size hint 00152 */ 00153 PLGUI_API void SetSizeRight(const SizeHint &cSize); 00154 00155 /** 00156 * @brief 00157 * Get content widget of a given side 00158 * 00159 * @param[in] nSide 00160 * Side 00161 * 00162 * @return 00163 * Content widget 00164 * 00165 * @remarks 00166 * A splitter has exactly two content widgets. 00167 * The first is retrieved with SideLeft or SideTop, the second with SideRight or SideBottom. 00168 */ 00169 PLGUI_API Widget *GetSide(ESide nSide) const; 00170 00171 /** 00172 * @brief 00173 * Get content widget 00174 * 00175 * @return 00176 * Content widget 00177 * 00178 * @remarks 00179 * A splitter has actually two content widgets, this function returns the first one. 00180 * See GetSide() for retrieving both content widgets. 00181 */ 00182 PLGUI_API virtual Widget *GetContentWidget() const; 00183 00184 00185 //[-------------------------------------------------------] 00186 //[ Public virtual Widget functions ] 00187 //[-------------------------------------------------------] 00188 public: 00189 PLGUI_API virtual void OnDraw(Graphics &cGraphics) override; 00190 PLGUI_API virtual PLMath::Vector2i OnPreferredSize(const PLMath::Vector2i &vRefSize) const override; 00191 PLGUI_API virtual void OnAdjustContent() override; 00192 PLGUI_API virtual void OnMouseLeave() override; 00193 PLGUI_API virtual void OnMouseMove(const PLMath::Vector2i &vPos) override; 00194 PLGUI_API virtual void OnMouseButtonDown(PLCore::uint32 nButton, const PLMath::Vector2i &vPos) override; 00195 PLGUI_API virtual void OnMouseButtonUp(PLCore::uint32 nButton, const PLMath::Vector2i &vPos) override; 00196 00197 00198 //[-------------------------------------------------------] 00199 //[ Protected functions ] 00200 //[-------------------------------------------------------] 00201 protected: 00202 /** 00203 * @brief 00204 * Change size of content widgets 00205 * 00206 * @param[in] nDelta 00207 * Movement delta (in pixels) 00208 */ 00209 PLGUI_API void ChangeSize(int nDelta); 00210 00211 00212 //[-------------------------------------------------------] 00213 //[ Protected data ] 00214 //[-------------------------------------------------------] 00215 protected: 00216 // Options 00217 EOrientation m_nOrientation; /**< Orientation */ 00218 bool m_bSizable; /**< Is the widget sizable? */ 00219 SizeHint m_cSizeLeft; /**< Size of left (or top) container */ 00220 SizeHint m_cSizeRight; /**< Size of right (or bottom) container */ 00221 00222 // Internal data 00223 Widget *m_pContentLeft; /**< Inner widget for the left/top side */ 00224 Widget *m_pContentRight; /**< Inner widget for the right/bottom side */ 00225 PLMath::Vector2i m_vMousePos; /**< Current mouse position */ 00226 bool m_bSizing; /**< Are we currently changing the size? */ 00227 00228 00229 }; 00230 00231 00232 //[-------------------------------------------------------] 00233 //[ Namespace ] 00234 //[-------------------------------------------------------] 00235 } // PLGui 00236 00237 00238 #endif // __PLGUI_SPLITTER_H__
|