This repository has been archived on 2023-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
MyGameFramework/lib/gwen/controls/gwen_slider.h
Gered c5cdddbeaa initial commit
current versions of all of my basic framework sources, build configurations/scripts, and supporting assets
2013-01-31 12:53:05 -05:00

87 lines
2.2 KiB
C++

/*
GWEN
Copyright (c) 2010 Facepunch Studios
See license in Gwen.h
*/
#pragma once
#ifndef GWEN_CONTROLS_SLIDER_H
#define GWEN_CONTROLS_SLIDER_H
#include "gwen_base.h"
#include "gwen_button.h"
#include "gwen_dragger.h"
#include "../gwen.h"
#include "../gwen_skin.h"
namespace Gwen
{
namespace ControlsInternal
{
class GWEN_EXPORT SliderBar : public ControlsInternal::Dragger
{
GWEN_CONTROL( SliderBar, ControlsInternal::Dragger );
virtual void Render( Skin::Base* skin );
virtual void SetHorizontal( bool b ){ m_bHorizontal = b; }
virtual bool IsHorizontal(){ return m_bHorizontal; }
protected:
bool m_bHorizontal;
};
}
namespace Controls
{
class GWEN_EXPORT Slider : public Base
{
GWEN_CONTROL( Slider, Base );
virtual void Render( Skin::Base* skin ) = 0;
virtual void Layout( Skin::Base* skin );
virtual void SetClampToNotches( bool bClamp ) { m_bClampToNotches = bClamp; }
virtual void SetNotchCount( int num ) { m_iNumNotches = num; }
virtual int GetNotchCount() { return m_iNumNotches; }
virtual void SetRange( float fMin, float fMax );
virtual float GetFloatValue();
virtual void SetFloatValue( float val, bool forceUpdate = true );
virtual float CalculateValue();
virtual void OnMoved( Controls::Base * control );
virtual void OnMouseClickLeft( int /*x*/, int /*y*/, bool /*bDown*/ ){};
virtual bool OnKeyRight( bool bDown ) { if ( bDown ) SetFloatValue( GetFloatValue() + 1, true ); return true; }
virtual bool OnKeyLeft( bool bDown ) { if ( bDown ) SetFloatValue( GetFloatValue() - 1, true ); return true; }
virtual bool OnKeyUp( bool bDown ) { if ( bDown ) SetFloatValue( GetFloatValue() + 1, true ); return true; }
virtual bool OnKeyDown( bool bDown ) { if ( bDown ) SetFloatValue( GetFloatValue() - 1, true ); return true; }
virtual void RenderFocus( Gwen::Skin::Base* skin);
Gwen::Event::Caller onValueChanged;
protected:
virtual void SetValueInternal( float fVal );
virtual void UpdateBarFromValue() = 0;
ControlsInternal::SliderBar * m_SliderBar;
bool m_bClampToNotches;
int m_iNumNotches;
float m_fValue;
float m_fMin;
float m_fMax;
};
}
}
#endif