MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / onRenderCell

Method onRenderCell

Engine/source/gui/controls/guiPopUpCtrl.cpp:166–228  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

164
165//------------------------------------------------------------------------------
166void GuiPopupTextListCtrl::onRenderCell(Point2I offset, Point2I cell, bool selected, bool mouseOver)
167{
168 Point2I size;
169 getCellSize( size );
170
171 // Render a background color for the cell
172 if ( mouseOver )
173 {
174 RectI cellR( offset.x, offset.y, size.x, size.y );
175 GFX->getDrawUtil()->drawRectFill( cellR, mProfile->mFillColorHL );
176
177 }
178 else if ( selected )
179 {
180 RectI cellR( offset.x, offset.y, size.x, size.y );
181 GFX->getDrawUtil()->drawRectFill( cellR, mProfile->mFillColorSEL );
182 }
183
184 // Define the default x offset for the text
185 U32 textXOffset = offset.x + mProfile->mTextOffset.x;
186
187 // Do we also draw a colored box beside the text?
188 ColorI boxColor;
189 bool drawbox = mPopUpCtrl->getColoredBox( boxColor, mList[cell.y].id);
190 if(drawbox)
191 {
192 Point2I coloredboxsize(15,10);
193 RectI r(offset.x + mProfile->mTextOffset.x, offset.y+2, coloredboxsize.x, coloredboxsize.y);
194 GFX->getDrawUtil()->drawRectFill( r, boxColor);
195 GFX->getDrawUtil()->drawRect( r, ColorI(0,0,0));
196
197 textXOffset += coloredboxsize.x + mProfile->mTextOffset.x;
198 }
199
200 ColorI fontColor;
201 mPopUpCtrl->getFontColor( fontColor, mList[cell.y].id, selected, mouseOver );
202
203 GFX->getDrawUtil()->setBitmapModulation( fontColor );
204 //GFX->drawText( mFont, Point2I( offset.x + 4, offset.y ), mList[cell.y].text );
205
206 // Get the number of columns in the cell
207 S32 colcount = getColumnCount(mList[cell.y].text, "\t");
208
209 // Are there two or more columns?
210 if(colcount >= 2)
211 {
212 char buff[256];
213
214 // Draw the first column
215 getColumn(mList[cell.y].text, buff, 0, "\t");
216 GFX->getDrawUtil()->drawText( mFont, Point2I( textXOffset, offset.y ), buff ); // Used mTextOffset as a margin for the text list rather than the hard coded value of '4'.
217
218 // Draw the second column to the right
219 getColumn(mList[cell.y].text, buff, 1, "\t");
220 S32 txt_w = mFont->getStrWidth(buff);
221
222 GFX->getDrawUtil()->drawText( mFont, Point2I( offset.x+size.x-mProfile->mTextOffset.x-txt_w, offset.y ), buff ); // Used mTextOffset as a margin for the text list rather than the hard coded value of '4'.
223

Callers

nothing calls this directly

Calls 13

getCellSizeFunction · 0.85
drawRectFillMethod · 0.80
getDrawUtilMethod · 0.80
drawRectMethod · 0.80
setBitmapModulationMethod · 0.80
getStrWidthMethod · 0.80
getColumnCountFunction · 0.70
getColumnFunction · 0.70
ColorIClass · 0.50
Point2IClass · 0.50
getColoredBoxMethod · 0.45
getFontColorMethod · 0.45

Tested by

no test coverage detected