mirror of
https://github.com/tribes2/engine.git
synced 2026-03-06 14:00:28 +00:00
t2 engine svn checkout
This commit is contained in:
commit
ff569bd2ae
988 changed files with 394180 additions and 0 deletions
182
gui/guiFrameCtrl.h
Normal file
182
gui/guiFrameCtrl.h
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// V12 Engine
|
||||
//
|
||||
// Copyright (c) 2001 GarageGames.Com
|
||||
// Portions Copyright (c) 2001 by Sierra Online, Inc.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/******************************************************************************
|
||||
* FILENAME: D:\Tribes\darkstar\GUI\guiFrameCtrl.h
|
||||
*
|
||||
* DESCRIPTION: A gui control allowing a window to be subdivided into panes,
|
||||
* each of which displays a gui control child of the
|
||||
* GuiFrameSetCtrl. Each gui control child will have an associated
|
||||
* FrameDetail through which frame-specific details can be
|
||||
* assigned. Frame-specific values override the values specified
|
||||
* for the entire frameset.
|
||||
*
|
||||
* Note that it is possible to have more children than frames,
|
||||
* or more frames than children. In the former case, the extra
|
||||
* children will not be visible (they are moved beyond the
|
||||
* visible extent of the frameset). In the latter case, frames
|
||||
* will be empty.
|
||||
*
|
||||
* If a frameset had two columns and two rows but only three
|
||||
* gui control children they would be assigned to frames as
|
||||
* follows:
|
||||
* 1 | 2
|
||||
* -----
|
||||
* 3 |
|
||||
*
|
||||
* The last frame would be blank.
|
||||
*
|
||||
* CREATED: 10/08/99 14:40:24
|
||||
*
|
||||
* BY: PeteW
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef _GUIFRAMECTRL_H_
|
||||
#define _GUIFRAMECTRL_H_
|
||||
|
||||
#define DISABLE_COPY_CTOR(className) \
|
||||
className(const className &)
|
||||
|
||||
#define DISABLE_ASSIGNMENT(className) \
|
||||
className& operator=(const className &)
|
||||
|
||||
#ifndef _GUICONTROL_H_
|
||||
#include "GUI/guiControl.h"
|
||||
#endif
|
||||
|
||||
// for debugging porpoises...
|
||||
#define GUI_FRAME_DEBUG
|
||||
// ...save the porpoises
|
||||
|
||||
class GuiFrameSetCtrl : public GuiControl
|
||||
{
|
||||
private:
|
||||
typedef GuiControl Parent;
|
||||
public:
|
||||
enum
|
||||
{
|
||||
FRAME_STATE_ON, // ON overrides OFF
|
||||
FRAME_STATE_OFF, // OFF overrides AUTO
|
||||
FRAME_STATE_AUTO, // AUTO == ON, unless overridden
|
||||
|
||||
NO_HIT = -1,
|
||||
|
||||
DEFAULT_BORDER_WIDTH = 4,
|
||||
DEFAULT_COLUMNS = 1,
|
||||
DEFAULT_ROWS = 1,
|
||||
DEFAULT_MIN_FRAME_EXTENT = 20
|
||||
};
|
||||
enum Region
|
||||
{
|
||||
VERTICAL_DIVIDER,
|
||||
HORIZONTAL_DIVIDER,
|
||||
DIVIDER_INTERSECTION,
|
||||
NONE
|
||||
};
|
||||
struct FrameDetail
|
||||
{
|
||||
U32 mBorderWidth;
|
||||
ColorI mBorderColor;
|
||||
S32 mBorderEnable;
|
||||
S32 mBorderMovable;
|
||||
Point2I mMinExtent;
|
||||
FrameDetail() { mBorderWidth = DEFAULT_BORDER_WIDTH; mBorderEnable = FRAME_STATE_AUTO; mBorderMovable = FRAME_STATE_AUTO; mMinExtent.set(DEFAULT_MIN_FRAME_EXTENT, DEFAULT_MIN_FRAME_EXTENT); }
|
||||
};
|
||||
DECLARE_CONOBJECT(GuiFrameSetCtrl);
|
||||
static void consoleInit();
|
||||
static void initPersistFields();
|
||||
|
||||
GuiFrameSetCtrl();
|
||||
GuiFrameSetCtrl(U32 columns, U32 rows, const U32 columnOffsets[] = NULL, const U32 rowOffsets[] = NULL);
|
||||
virtual ~GuiFrameSetCtrl();
|
||||
|
||||
void addObject(SimObject *object);
|
||||
void removeObject(SimObject *object);
|
||||
|
||||
virtual void resize(const Point2I &newPos, const Point2I &newExtent);
|
||||
|
||||
virtual void onMouseMove(const GuiEvent &event);
|
||||
virtual void onMouseDown(const GuiEvent &event);
|
||||
virtual void onMouseUp(const GuiEvent &event);
|
||||
virtual void onMouseDragged(const GuiEvent &event);
|
||||
virtual void onMouseEnter(const GuiEvent &event);
|
||||
virtual void onMouseLeave(const GuiEvent &event);
|
||||
|
||||
bool onAdd();
|
||||
void onRender(Point2I offset, const RectI &updateRect, GuiControl *firstResponder);
|
||||
protected:
|
||||
/* member variables */
|
||||
Vector<S32> mColumnOffsets;
|
||||
Vector<S32> mRowOffsets;
|
||||
GuiCursor *mMoveCursor;
|
||||
GuiCursor *mUpDownCursor;
|
||||
GuiCursor *mLeftRightCursor;
|
||||
GuiCursor *mDefaultCursor;
|
||||
FrameDetail mFramesetDetails;
|
||||
VectorPtr<FrameDetail *> mFrameDetails;
|
||||
bool mAutoBalance;
|
||||
S32 mFudgeFactor;
|
||||
|
||||
/* divider activation member variables */
|
||||
Region mCurHitRegion;
|
||||
Point2I mLocOnDivider;
|
||||
S32 mCurVerticalHit;
|
||||
S32 mCurHorizontalHit;
|
||||
|
||||
bool init(U32 columns, U32 rows, const U32 columnOffsets[], const U32 rowOffsets[]);
|
||||
bool initCursors();
|
||||
|
||||
Region findHitRegion(const Point2I &point);
|
||||
Region pointInAnyRegion(const Point2I &point);
|
||||
S32 findResizableFrames(S32 indexes[]);
|
||||
bool hitVerticalDivider(S32 x, const Point2I &point);
|
||||
bool hitHorizontalDivider(S32 y, const Point2I &point);
|
||||
|
||||
void rebalance(const Point2I &newExtent);
|
||||
|
||||
void computeSizes(bool balanceFrames = false);
|
||||
void computeMovableRange(Region hitRegion, S32 vertHit, S32 horzHit, S32 numIndexes, const S32 indexes[], S32 ranges[]);
|
||||
|
||||
void drawDividers(const Point2I &offset);
|
||||
public:
|
||||
U32 columns() const { return(mColumnOffsets.size()); }
|
||||
U32 rows() const { return(mRowOffsets.size()); }
|
||||
U32 borderWidth() const { return(mFramesetDetails.mBorderWidth); }
|
||||
Vector<S32>* columnOffsets() { return(&mColumnOffsets); }
|
||||
Vector<S32>* rowOffsets() { return(&mRowOffsets); }
|
||||
FrameDetail* framesetDetails() { return(&mFramesetDetails); }
|
||||
|
||||
bool findFrameContents(S32 index, GuiControl **gc, FrameDetail **fd);
|
||||
|
||||
void frameBorderEnable(S32 index, const char *state = NULL);
|
||||
void frameBorderMovable(S32 index, const char *state = NULL);
|
||||
void frameMinExtent(S32 index, const Point2I &extent);
|
||||
|
||||
void balanceFrames() { computeSizes(true); }
|
||||
void updateSizes() { computeSizes(); }
|
||||
|
||||
private:
|
||||
DISABLE_COPY_CTOR(GuiFrameSetCtrl);
|
||||
DISABLE_ASSIGNMENT(GuiFrameSetCtrl);
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// x is the first value inside the next column, so the divider x-coords
|
||||
// precede x.
|
||||
inline bool GuiFrameSetCtrl::hitVerticalDivider(S32 x, const Point2I &point)
|
||||
{
|
||||
return((point.x >= S32(x - mFramesetDetails.mBorderWidth)) && (point.x < x) && (point.y >= 0) && (point.y < S32(mBounds.extent.y)));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// y is the first value inside the next row, so the divider y-coords precede y.
|
||||
inline bool GuiFrameSetCtrl::hitHorizontalDivider(S32 y, const Point2I &point)
|
||||
{
|
||||
return((point.x >= 0) && (point.x < S32(mBounds.extent.x)) && (point.y >= S32(y - mFramesetDetails.mBorderWidth)) && (point.y < y));
|
||||
}
|
||||
|
||||
#endif // _GUI_FRAME_CTRL_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue