2016-12-04 18:36:53 +00:00
|
|
|
// FGPanel.hxx - generic support classes for a 2D panel.
|
|
|
|
//
|
|
|
|
// Written by David Megginson, started January 2000.
|
|
|
|
// Adopted for standalone fgpanel application by Torsten Dreyer, August 2009
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
//
|
|
|
|
// $Id: FGPanel.hxx,v 1.1 2016/07/20 22:01:30 allaert Exp $
|
|
|
|
|
2022-01-15 07:48:01 +00:00
|
|
|
#pragma once
|
2016-12-04 18:36:53 +00:00
|
|
|
|
|
|
|
#ifndef __cplusplus
|
|
|
|
# error This library requires C++
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#include <simgear/props/propsfwd.hxx>
|
|
|
|
#include <simgear/structure/subsystem_mgr.hxx>
|
|
|
|
|
|
|
|
#include "FGCroppedTexture.hxx"
|
|
|
|
#include "FGPanelInstrument.hxx"
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
// Top-level panel.
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Instrument panel class.
|
|
|
|
*
|
|
|
|
* The panel is a container that has a background texture and holds
|
|
|
|
* zero or more instruments. The panel will order the instruments to
|
|
|
|
* redraw themselves when necessary, and will pass mouse clicks on to
|
|
|
|
* the appropriate instruments for processing.
|
|
|
|
*/
|
2016-12-04 18:36:53 +00:00
|
|
|
class FGPanel : public SGSubsystem {
|
2016-12-04 18:36:53 +00:00
|
|
|
public:
|
2018-04-03 10:21:33 +00:00
|
|
|
FGPanel (const SGPropertyNode_ptr root);
|
|
|
|
virtual ~FGPanel ();
|
2016-12-04 18:36:53 +00:00
|
|
|
|
2018-04-03 08:41:27 +00:00
|
|
|
// Subsystem API.
|
|
|
|
void init() override;
|
|
|
|
void bind() override;
|
|
|
|
void unbind() override;
|
|
|
|
void update(double dt) override;
|
2016-12-04 18:36:53 +00:00
|
|
|
|
2018-05-05 09:38:11 +00:00
|
|
|
// Subsystem identification.
|
|
|
|
static const char* staticSubsystemClassId() { return "panel"; }
|
|
|
|
|
2018-04-03 10:21:33 +00:00
|
|
|
// transfer pointer ownership!!!
|
|
|
|
virtual void addInstrument (FGPanelInstrument * const instrument);
|
2016-12-04 18:36:53 +00:00
|
|
|
|
2018-04-03 10:21:33 +00:00
|
|
|
// Background texture.
|
|
|
|
virtual void setBackground (const FGCroppedTexture_ptr texture);
|
|
|
|
void setBackgroundWidth (const double d);
|
|
|
|
void setBackgroundHeight (const double d);
|
2016-12-04 18:36:53 +00:00
|
|
|
|
2018-04-03 10:21:33 +00:00
|
|
|
// Background multiple textures.
|
|
|
|
virtual void setMultiBackground (const FGCroppedTexture_ptr texture , const int idx);
|
2016-12-04 18:36:53 +00:00
|
|
|
|
2018-04-03 10:21:33 +00:00
|
|
|
// Full width of panel.
|
|
|
|
virtual void setWidth (const int width);
|
|
|
|
virtual int getWidth () const;
|
2016-12-04 18:36:53 +00:00
|
|
|
|
2018-04-03 10:21:33 +00:00
|
|
|
// Full height of panel.
|
|
|
|
virtual void setHeight (const int height);
|
|
|
|
virtual int getHeight () const;
|
2016-12-04 18:36:53 +00:00
|
|
|
|
|
|
|
private:
|
2022-01-15 07:48:01 +00:00
|
|
|
typedef std::vector <FGPanelInstrument *> instrument_list_type;
|
2018-04-03 10:21:33 +00:00
|
|
|
int m_width;
|
|
|
|
int m_height;
|
|
|
|
|
|
|
|
SGPropertyNode_ptr m_flipx;
|
|
|
|
|
|
|
|
FGCroppedTexture_ptr m_bg;
|
|
|
|
double m_bg_width;
|
|
|
|
double m_bg_height;
|
|
|
|
FGCroppedTexture_ptr m_mbg[8];
|
|
|
|
// List of instruments in panel.
|
|
|
|
instrument_list_type m_instruments;
|
|
|
|
|
|
|
|
void getInitDisplayList ();
|
|
|
|
|
|
|
|
static GLuint Textured_Layer_Program_Object;
|
|
|
|
static GLint Textured_Layer_Position_Loc;
|
|
|
|
static GLint Textured_Layer_Tex_Coord_Loc;
|
|
|
|
static GLint Textured_Layer_MVP_Loc;
|
|
|
|
static GLint Textured_Layer_Sampler_Loc;
|
2016-12-04 18:36:53 +00:00
|
|
|
};
|