| 1 | // SPDX-FileComment: generic support classes for a 2D panel. |
| 2 | // SPDX-FileCopyrightText: 2000 David Megginson |
| 3 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 4 | |
| 5 | #pragma once |
| 6 | |
| 7 | #ifndef __cplusplus |
| 8 | # error This library requires C++ |
| 9 | #endif |
| 10 | |
| 11 | |
| 12 | #include <simgear/props/propsfwd.hxx> |
| 13 | #include <simgear/structure/subsystem_mgr.hxx> |
| 14 | |
| 15 | #include "FGCroppedTexture.hxx" |
| 16 | #include "FGPanelInstrument.hxx" |
| 17 | |
| 18 | |
| 19 | //////////////////////////////////////////////////////////////////////// |
| 20 | // Top-level panel. |
| 21 | //////////////////////////////////////////////////////////////////////// |
| 22 | |
| 23 | /** |
| 24 | * Instrument panel class. |
| 25 | * |
| 26 | * The panel is a container that has a background texture and holds |
| 27 | * zero or more instruments. The panel will order the instruments to |
| 28 | * redraw themselves when necessary, and will pass mouse clicks on to |
| 29 | * the appropriate instruments for processing. |
| 30 | */ |
| 31 | class FGPanel : public SGSubsystem { |
| 32 | public: |
| 33 | FGPanel (const SGPropertyNode_ptr root); |
| 34 | virtual ~FGPanel (); |
| 35 | |
| 36 | // Subsystem API. |
| 37 | void init() override; |
| 38 | void bind() override; |
| 39 | void unbind() override; |
| 40 | void update(double dt) override; |
| 41 | |
| 42 | // Subsystem identification. |
| 43 | static const char* staticSubsystemClassId() { return "panel"; } |
| 44 | |
| 45 | // transfer pointer ownership!!! |
| 46 | virtual void addInstrument (FGPanelInstrument * const instrument); |
| 47 | |
| 48 | // Background texture. |
| 49 | virtual void setBackground (const FGCroppedTexture_ptr texture); |
| 50 | void setBackgroundWidth (const double d); |
| 51 | void setBackgroundHeight (const double d); |
| 52 | |
| 53 | // Background multiple textures. |
| 54 | virtual void setMultiBackground (const FGCroppedTexture_ptr texture , const int idx); |
| 55 | |
| 56 | // Full width of panel. |
| 57 | virtual void setWidth (const int width); |
| 58 | virtual int getWidth () const; |
| 59 | |
| 60 | // Full height of panel. |
| 61 | virtual void setHeight (const int height); |
| 62 | virtual int getHeight () const; |
| 63 | |
| 64 | private: |
| 65 | typedef std::vector <FGPanelInstrument *> instrument_list_type; |
| 66 | int m_width; |
| 67 | int m_height; |
| 68 | |
| 69 | SGPropertyNode_ptr m_flipx; |
| 70 | |
| 71 | FGCroppedTexture_ptr m_bg; |
| 72 | double m_bg_width; |
| 73 | double m_bg_height; |
| 74 | FGCroppedTexture_ptr m_mbg[8]; |
| 75 | // List of instruments in panel. |
| 76 | instrument_list_type m_instruments; |
| 77 | |
| 78 | void getInitDisplayList (); |
| 79 | |
| 80 | static GLuint Textured_Layer_Program_Object; |
| 81 | static GLint Textured_Layer_Position_Loc; |
| 82 | static GLint Textured_Layer_Tex_Coord_Loc; |
| 83 | static GLint Textured_Layer_MVP_Loc; |
| 84 | static GLint Textured_Layer_Sampler_Loc; |
| 85 | }; |