28 ClassImp(TGLOverlayButton);
33 TGLOverlayButton::TGLOverlayButton(TGLViewerBase *parent,
const char *text,
34 Float_t posx, Float_t posy, Float_t width, Float_t height) :
48 parent->AddOverlayElement(
this);
54 void TGLOverlayButton::Render(TGLRnrCtx& rnrCtx)
57 glMatrixMode(GL_PROJECTION);
60 if (rnrCtx.Selection())
62 TGLRect rect(*rnrCtx.GetPickRectangle());
63 rnrCtx.GetCamera()->WindowToViewport(rect);
64 gluPickMatrix(rect.X(), rect.Y(), rect.Width(), rect.Height(),
65 (Int_t*) rnrCtx.GetCamera()->RefViewport().CArr());
67 const TGLRect& vp = rnrCtx.RefCamera().RefViewport();
68 glOrtho(vp.X(), vp.Width(), vp.Y(), vp.Height(), 0, 1);
69 glMatrixMode(GL_MODELVIEW);
73 Float_t offset = (fPosY >= 0.0)? 0.0 : vp.Height()-fHeight;
75 TGLCapabilitySwitch lights_off(GL_LIGHTING, kFALSE);
76 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
77 glDisable(GL_CULL_FACE);
79 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
80 glShadeModel(GL_FLAT);
81 glClearColor(0.0, 0.0, 0.0, 0.0);
86 TGLCapabilitySwitch move_to_back(GL_POLYGON_OFFSET_FILL, kTRUE);
87 glPolygonOffset(0.5f, 0.5f);
89 glTranslatef(fPosX, offset+fPosY, 0);
91 TColor::Pixel2RGB(fTextColor, r, g, b);
92 (fActiveID == 1) ? TGLUtil::Color4f(r, g, b, fHighAlpha):TGLUtil::Color4f(r, g, b, fNormAlpha);
93 TGLUtil::LineWidth(1);
94 glBegin(GL_LINE_LOOP);
96 glVertex2f(0.0, fHeight);
97 glVertex2f(fWidth, fHeight);
98 glVertex2f(fWidth, 0.0);
102 TColor::Pixel2RGB(fBackColor, r, g, b);
103 (fActiveID == 1) ? TGLUtil::Color4f(r, g, b, fHighAlpha * 0.8):TGLUtil::Color4f(r, g, b, fNormAlpha);
105 glVertex2f(0.0, 0.0);
106 glVertex2f(0.0, fHeight);
107 glVertex2f(fWidth, fHeight);
108 glVertex2f(fWidth, 0.0);
115 rnrCtx.RegisterFontNoScale(TMath::Nint(fHeight*0.8),
"arial", TGLFont::kPixmap, fFont);
116 fFont.PreRender(kFALSE);
118 TColor::Pixel2RGB(fTextColor, r, g, b);
119 (fActiveID == 1) ? TGLUtil::Color4f(r, g, b, fHighAlpha):TGLUtil::Color4f(r, g, b, fNormAlpha);
121 glTranslatef(fPosX+(fWidth/2.0), offset+fPosY+(fHeight/2.0), 0);
122 Float_t llx, lly, llz, urx, ury, urz;
123 fFont.BBox(fText.Data(), llx, lly, llz, urx, ury, urz);
125 glBitmap(0, 0, 0, 0, -urx*0.5f, -ury*0.5f, 0);
126 fFont.Render(fText.Data());
132 glMatrixMode(GL_PROJECTION);
134 glMatrixMode(GL_MODELVIEW);
142 void TGLOverlayButton::Clicked(TGLViewerBase *viewer)
144 Emit(
"Clicked(TGLViewerBase*)", (Long_t)viewer);
155 Bool_t TGLOverlayButton::Handle(TGLRnrCtx & rnrCtx,
156 TGLOvlSelectRecord & rec,
159 if (event->fCode != kButton1) {
162 switch (event->fType) {
164 if (rec.GetItem(1) == 1) {
169 if (rec.GetItem(1) == 1) {
170 Clicked(rnrCtx.GetViewer());
183 Bool_t TGLOverlayButton::MouseEnter(TGLOvlSelectRecord& )
192 void TGLOverlayButton::MouseLeave()