//----------------------------------------------------------------------- // d r a w //----------------------------------------------------------------------- void TGUIImage::draw() { if (!IsVisible) return; IGUISkin* skin = Environment->getSkin(); video::IVideoDriver* driver = Environment->getVideoDriver(); core::rect<s32> rect = AbsoluteRect; if (Texture) { if (ScaleImage) { const video::SColor Colors[] = {Color,Color,Color,Color}; driver->draw2DImage(Texture, AbsoluteRect, core::rect<s32>(core::position2d<s32>(0,0), core::dimension2di(Texture->getOriginalSize())), &AbsoluteClippingRect, Colors, UseAlphaChannel); } else { driver->draw2DImage(Texture, AbsoluteRect.UpperLeftCorner, core::rect<s32>(core::position2d<s32>(0,0), core::dimension2di(Texture->getOriginalSize())), &AbsoluteClippingRect, Color, UseAlphaChannel); } } else { skin->draw2DRectangle(this, skin->getColor(EGDC_3D_DARK_SHADOW), AbsoluteRect, &AbsoluteClippingRect); } IGUIElement::draw(); }
//! draws the element and its children void CGUIModalScreen::draw() { IGUISkin *skin = Environment->getSkin(); if (!skin) return; u32 now = os::Timer::getTime(); if (now - MouseDownTime < 300 && (now / 70)%2) { core::list<IGUIElement*>::Iterator it = Children.begin(); core::rect<s32> r; video::SColor c = Environment->getSkin()->getColor(gui::EGDC_3D_HIGH_LIGHT); for (; it != Children.end(); ++it) { r = (*it)->getAbsolutePosition(); r.LowerRightCorner.X += 1; r.LowerRightCorner.Y += 1; r.UpperLeftCorner.X -= 1; r.UpperLeftCorner.Y -= 1; skin->draw2DRectangle(this, c, r, &AbsoluteClippingRect); } } IGUIElement::draw(); }
//! draws the element and its children void CGUIScrollBar::draw() { if (!IsVisible) return; IGUISkin* skin = Environment->getSkin(); if (!skin) return; SliderRect = AbsoluteRect; // draws the background skin->draw2DRectangle(this, skin->getColor(EGDC_SCROLLBAR), SliderRect, &AbsoluteClippingRect); if ( core::isnotzero ( range() ) ) { // recalculate slider rectangle if (Horizontal) { SliderRect.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X + DrawPos + RelativeRect.getHeight() - DrawHeight/2; SliderRect.LowerRightCorner.X = SliderRect.UpperLeftCorner.X + DrawHeight; } else { SliderRect.UpperLeftCorner.Y = AbsoluteRect.UpperLeftCorner.Y + DrawPos + RelativeRect.getWidth() - DrawHeight/2; SliderRect.LowerRightCorner.Y = SliderRect.UpperLeftCorner.Y + DrawHeight; } skin->draw3DButtonPaneStandard(this, SliderRect, &AbsoluteClippingRect); } // draw buttons IGUIElement::draw(); }
//! draws the element and its children void CGUIImage::draw() { if (!IsVisible) return; IGUISkin* skin = Environment->getSkin(); IVideoDriver* driver = Environment->getVideoDriver(); if (Texture) { if (ScaleImage) { const ColourValue Colors[] = { Color, Color, Color, Color }; driver->draw2DImage(Texture, AbsoluteRect, rect<SINT32>(Position2d(0, 0), dimension2di(Texture->getOriginalSize())), &AbsoluteClippingRect, Colors, UseAlphaChannel); } else { driver->draw2DImage(Texture, AbsoluteRect.UpperLeftCorner, rect<SINT32>(Position2d(0, 0), dimension2di(Texture->getOriginalSize())), &AbsoluteClippingRect, Color, UseAlphaChannel); } } else { skin->draw2DRectangle(this, skin->getColor(EGDC_3D_DARK_SHADOW), AbsoluteRect, &AbsoluteClippingRect); } IGUIElement::draw(); }
//! draws the element and its children void CGUITab::draw() { if (!IsVisible) return; IGUISkin *skin = Environment->getSkin(); if (skin && DrawBackground) skin->draw2DRectangle(this, BackColor, AbsoluteRect, &AbsoluteClippingRect); IGUIElement::draw(); }
//! draws the element and its children void CGUIImage::draw() { if (!IsVisible) return; IGUISkin* skin = Environment->getSkin(); video::IVideoDriver* driver = Environment->getVideoDriver(); if (Texture) { core::rect<s32> sourceRect(SourceRect); if (sourceRect.getWidth() == 0 || sourceRect.getHeight() == 0) { sourceRect = core::rect<s32>(core::position2d<s32>(0,0), core::dimension2di(Texture->getOriginalSize())); } if (ScaleImage) { const video::SColor Colors[] = {Color,Color,Color,Color}; core::rect<s32> clippingRect(AbsoluteClippingRect); checkBounds(clippingRect); driver->draw2DImage(Texture, AbsoluteRect, sourceRect, &clippingRect, Colors, UseAlphaChannel); } else { core::rect<s32> clippingRect(AbsoluteRect.UpperLeftCorner, sourceRect.getSize()); checkBounds(clippingRect); clippingRect.clipAgainst(AbsoluteClippingRect); driver->draw2DImage(Texture, AbsoluteRect.UpperLeftCorner, sourceRect, &clippingRect, Color, UseAlphaChannel); } } else { core::rect<s32> clippingRect(AbsoluteClippingRect); checkBounds(clippingRect); skin->draw2DRectangle(this, skin->getColor(EGDC_3D_DARK_SHADOW), AbsoluteRect, &clippingRect); } IGUIElement::draw(); }
//! draws the element and its children void CGUIScrollBar::draw() { if (!IsVisible) return; IGUISkin* skin = Environment->getSkin(); if (!skin) return; ColourValue iconColor = skin->getColor(isEnabled() ? EGDC_WINDOW_SYMBOL : EGDC_GRAY_WINDOW_SYMBOL); if (iconColor != CurrentIconColor) { refreshControls(); } SliderRect = AbsoluteRect; // draws the background skin->draw2DRectangle(this, skin->getColor(EGDC_SCROLLBAR), SliderRect, &AbsoluteClippingRect); if (!Math::iszero(range())) { // recalculate slider rectangle if (Horizontal) { SliderRect.UpperLeftCorner.x = AbsoluteRect.UpperLeftCorner.x + DrawPos + RelativeRect.getHeight() - DrawHeight / 2; SliderRect.LowerRightCorner.x = SliderRect.UpperLeftCorner.x + DrawHeight; } else { SliderRect.UpperLeftCorner.y = AbsoluteRect.UpperLeftCorner.y + DrawPos + RelativeRect.getWidth() - DrawHeight / 2; SliderRect.LowerRightCorner.y = SliderRect.UpperLeftCorner.y + DrawHeight; } skin->draw3DButtonPaneStandard(this, SliderRect, &AbsoluteClippingRect); } // draw buttons IGUIElement::draw(); }
//! draws the element and its children void CGUIComboBox::draw() { if (!IsVisible) return; IGUISkin* skin = Environment->getSkin(); IGUIElement *currentFocus = Environment->getFocus(); if (currentFocus != LastFocus) { HasFocus = currentFocus == this || isMyChild(currentFocus); LastFocus = currentFocus; } core::rect<s32> frameRect(AbsoluteRect); // draw the border skin->draw3DSunkenPane(this, skin->getColor(EGDC_3D_HIGH_LIGHT), true, true, frameRect, &AbsoluteClippingRect); // Draw text if (Selected != -1) { frameRect = AbsoluteRect; frameRect.UpperLeftCorner.X += 2; frameRect.UpperLeftCorner.Y += 2; frameRect.LowerRightCorner.X -= ListButton->getAbsolutePosition().getWidth() + 2; frameRect.LowerRightCorner.Y -= 2; if (HasFocus) skin->draw2DRectangle(this, skin->getColor(EGDC_HIGH_LIGHT), frameRect, &AbsoluteClippingRect); IGUIFont* font = skin->getFont(); if (font) font->draw(Items[Selected].c_str(), frameRect, skin->getColor(HasFocus ? EGDC_HIGH_LIGHT_TEXT : EGDC_BUTTON_TEXT), false, true, &AbsoluteClippingRect); } // draw buttons IGUIElement::draw(); }
//! draws the element and its children void CGUIContextMenu::draw() { if (!IsVisible) return; IGUISkin* skin = Environment->getSkin(); if (!skin) return; IGUIFont* font = skin->getFont(EGDF_MENU); if (font != LastFont) { if (LastFont) LastFont->drop(); LastFont = font; if (LastFont) LastFont->grab(); recalculateSize(); } IGUISpriteBank* sprites = skin->getSpriteBank(); core::rect<s32> rect = AbsoluteRect; core::rect<s32>* clip = 0; // draw frame skin->draw3DMenuPane(this, AbsoluteRect, clip); // loop through all menu items rect = AbsoluteRect; s32 y = AbsoluteRect.UpperLeftCorner.Y; for (s32 i=0; i<(s32)Items.size(); ++i) { if (Items[i].IsSeparator) { // draw separator rect = AbsoluteRect; rect.UpperLeftCorner.Y += Items[i].PosY + 3; rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1; rect.UpperLeftCorner.X += 5; rect.LowerRightCorner.X -= 5; skin->draw2DRectangle(this, skin->getColor(EGDC_3D_SHADOW), rect, clip); rect.LowerRightCorner.Y += 1; rect.UpperLeftCorner.Y += 1; skin->draw2DRectangle(this, skin->getColor(EGDC_3D_HIGH_LIGHT), rect, clip); y += 10; } else { rect = getRect(Items[i], AbsoluteRect); // draw highlighted if (i == HighLighted && Items[i].Enabled) { core::rect<s32> r = AbsoluteRect; r.LowerRightCorner.Y = rect.LowerRightCorner.Y; r.UpperLeftCorner.Y = rect.UpperLeftCorner.Y; r.LowerRightCorner.X -= 5; r.UpperLeftCorner.X += 5; skin->draw2DRectangle(this, skin->getColor(EGDC_HIGH_LIGHT), r, clip); } // draw text EGUI_DEFAULT_COLOR c = EGDC_BUTTON_TEXT; if (i == HighLighted) c = EGDC_HIGH_LIGHT_TEXT; if (!Items[i].Enabled) c = EGDC_GRAY_TEXT; if (font) font->draw(Items[i].Text.c_str(), rect, skin->getColor(c), false, true, clip); // draw submenu symbol if (Items[i].SubMenu && sprites) { core::rect<s32> r = rect; r.UpperLeftCorner.X = r.LowerRightCorner.X - 15; sprites->draw2DSprite(skin->getIcon(EGDI_CURSOR_RIGHT), r.getCenter(), clip, skin->getColor(c), (i == HighLighted) ? ChangeTime : 0, (i == HighLighted) ? os::Timer::getTime() : 0, (i == HighLighted), true); } // draw checked symbol if (Items[i].Checked && sprites) { core::rect<s32> r = rect; r.LowerRightCorner.X = r.UpperLeftCorner.X - 15; r.UpperLeftCorner.X = r.LowerRightCorner.X + 15; sprites->draw2DSprite(skin->getIcon(EGDI_CHECK_BOX_CHECKED), r.getCenter(), clip, skin->getColor(c), (i == HighLighted) ? ChangeTime : 0, (i == HighLighted) ? os::Timer::getTime() : 0, (i == HighLighted), true); } } } IGUIElement::draw(); }
//! draws the element and its children void CGUITabControl::draw() { if (!IsVisible) return; IGUISkin* skin = Environment->getSkin(); if (!skin) return; IGUIFont* font = skin->getFont(); core::rect<s32> frameRect(AbsoluteRect); if (Tabs.empty()) skin->draw2DRectangle(this, skin->getColor(EGDC_3D_HIGH_LIGHT), frameRect, &AbsoluteClippingRect); if (!font) return; s32 tabheight = skin->getSize(gui::EGDS_BUTTON_HEIGHT); frameRect.UpperLeftCorner.Y += 2; frameRect.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y + tabheight; core::rect<s32> tr; s32 pos = frameRect.UpperLeftCorner.X + 2; // left and right pos of the active tab s32 left = 0; s32 right = 0; const wchar_t* activetext = 0; for (u32 i=0; i<Tabs.size(); ++i) { // get Text const wchar_t* text = 0; if (Tabs[i]) text = Tabs[i]->getText(); // get text length s32 len = font->getDimension(text).Width + 20; frameRect.UpperLeftCorner.X = pos; frameRect.LowerRightCorner.X = frameRect.UpperLeftCorner.X + len; pos += len; if ((s32)i == ActiveTab) { left = frameRect.UpperLeftCorner.X; right = frameRect.LowerRightCorner.X; activetext = text; } else { skin->draw3DTabButton(this, false, frameRect, &AbsoluteClippingRect); // draw text font->draw(text, frameRect, skin->getColor(EGDC_BUTTON_TEXT), true, true, &AbsoluteClippingRect); } } // draw active tab if (left != 0 && right != 0) { frameRect.UpperLeftCorner.X = left-2; frameRect.LowerRightCorner.X = right+2; frameRect.UpperLeftCorner.Y -= 2; skin->draw3DTabButton(this, true, frameRect, &AbsoluteClippingRect); // draw text font->draw(activetext, frameRect, skin->getColor(EGDC_BUTTON_TEXT), true, true, &AbsoluteClippingRect); // draw upper highlight frame tr.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X; tr.LowerRightCorner.X = left - 1; tr.UpperLeftCorner.Y = frameRect.LowerRightCorner.Y - 1; tr.LowerRightCorner.Y = frameRect.LowerRightCorner.Y; skin->draw2DRectangle(this, skin->getColor(EGDC_3D_HIGH_LIGHT), tr, &AbsoluteClippingRect); tr.UpperLeftCorner.X = right; tr.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X; skin->draw2DRectangle(this, skin->getColor(EGDC_3D_HIGH_LIGHT), tr, &AbsoluteClippingRect); } skin->draw3DTabBody(this, Border, FillBackground, AbsoluteRect, &AbsoluteClippingRect); IGUIElement::draw(); }
//! draws the element and its children void CGUIScrollBar::draw() { if (!IsVisible) return; IGUISkin* skin = Environment->getSkin(); if (!skin) return; u32 now = os::Timer::getRealTime(); if (Dragging && !DraggedBySlider && TrayClick && now > LastChange + 200) { LastChange = now; const s32 oldPos = Pos; if (DesiredPos >= Pos + LargeStep) setPos(Pos + LargeStep); else if (DesiredPos <= Pos - LargeStep) setPos(Pos - LargeStep); else if (DesiredPos >= Pos - LargeStep && DesiredPos <= Pos + LargeStep) setPos(DesiredPos); if (Pos != oldPos && Parent) { SEvent newEvent; newEvent.EventType = EET_GUI_EVENT; newEvent.GUIEvent.Caller = this; newEvent.GUIEvent.Element = 0; newEvent.GUIEvent.EventType = EGET_SCROLL_BAR_CHANGED; Parent->OnEvent(newEvent); } } SliderRect = AbsoluteRect; // draws the background skin->draw2DRectangle(this, skin->getColor(EGDC_SCROLLBAR), SliderRect, &AbsoluteClippingRect); if (Max!=0) { // recalculate slider rectangle if (Horizontal) { SliderRect.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X + DrawPos + RelativeRect.getHeight() - DrawHeight/2; SliderRect.LowerRightCorner.X = SliderRect.UpperLeftCorner.X + DrawHeight; } else { SliderRect.UpperLeftCorner.Y = AbsoluteRect.UpperLeftCorner.Y + DrawPos + RelativeRect.getWidth() - DrawHeight/2; SliderRect.LowerRightCorner.Y = SliderRect.UpperLeftCorner.Y + DrawHeight; } skin->draw3DButtonPaneStandard(this, SliderRect, &AbsoluteClippingRect); } // draw buttons IGUIElement::draw(); }
//! draws the element and its children void CGUIMeshViewer::draw() { if (!IsVisible) return; IGUISkin* skin = Environment->getSkin(); video::IVideoDriver* driver = Environment->getVideoDriver(); core::rect<s32> viewPort = AbsoluteRect; viewPort.LowerRightCorner.X -= 1; viewPort.LowerRightCorner.Y -= 1; viewPort.UpperLeftCorner.X += 1; viewPort.UpperLeftCorner.Y += 1; viewPort.clipAgainst(AbsoluteClippingRect); // draw the frame core::rect<s32> frameRect(AbsoluteRect); frameRect.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y + 1; skin->draw2DRectangle(this, skin->getColor(EGDC_3D_SHADOW), frameRect, &AbsoluteClippingRect); frameRect.LowerRightCorner.Y = AbsoluteRect.LowerRightCorner.Y; frameRect.LowerRightCorner.X = frameRect.UpperLeftCorner.X + 1; skin->draw2DRectangle(this, skin->getColor(EGDC_3D_SHADOW), frameRect, &AbsoluteClippingRect); frameRect = AbsoluteRect; frameRect.UpperLeftCorner.X = frameRect.LowerRightCorner.X - 1; skin->draw2DRectangle(this, skin->getColor(EGDC_3D_HIGH_LIGHT), frameRect, &AbsoluteClippingRect); frameRect = AbsoluteRect; frameRect.UpperLeftCorner.Y = AbsoluteRect.LowerRightCorner.Y - 1; frameRect.LowerRightCorner.Y = AbsoluteRect.LowerRightCorner.Y; skin->draw2DRectangle(this, skin->getColor(EGDC_3D_HIGH_LIGHT), frameRect, &AbsoluteClippingRect); // draw the mesh if (Mesh) { //TODO: if outside of screen, dont draw. // - why is the absolute clipping rect not already the screen? core::rect<s32> oldViewPort = driver->getViewPort(); driver->setViewPort(viewPort); core::matrix4 mat; //CameraControl->calculateProjectionMatrix(mat); //driver->setTransform(video::TS_PROJECTION, mat); mat.makeIdentity(); mat.setTranslation(core::vector3df(0,0,0)); driver->setTransform(video::ETS_WORLD, mat); //CameraControl->calculateViewMatrix(mat); //driver->setTransform(video::TS_VIEW, mat); driver->setMaterial(Material); u32 frame = 0; if(Mesh->getFrameCount()) frame = (os::Timer::getTime()/20)%Mesh->getFrameCount(); const scene::IMesh* const m = Mesh->getMesh(frame); for (u32 i=0; i<m->getMeshBufferCount(); ++i) { scene::IMeshBuffer* mb = m->getMeshBuffer(i); driver->drawVertexPrimitiveList(mb->getVertices(), mb->getVertexCount(), mb->getIndices(), mb->getIndexCount()/ 3, mb->getVertexType(), scene::EPT_TRIANGLES, mb->getIndexType()); } driver->setViewPort(oldViewPort); } IGUIElement::draw(); }
//! draws the element and its children void CGUIEditBox::draw() { #ifndef SERVER_ONLY if (!IsVisible) return; const bool focus = Environment->hasFocus(this); IGUISkin* skin = Environment->getSkin(); if (!skin) return; FrameRect = AbsoluteRect; // draw the border if (Border) { EGUI_DEFAULT_COLOR col = EGDC_GRAY_EDITABLE; if ( isEnabled() ) col = focus ? EGDC_FOCUSED_EDITABLE : EGDC_EDITABLE; skin->draw3DSunkenPane(this, skin->getColor(col), false, true, FrameRect, &AbsoluteClippingRect); FrameRect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X)+1; FrameRect.UpperLeftCorner.Y += skin->getSize(EGDS_TEXT_DISTANCE_Y)+1; FrameRect.LowerRightCorner.X -= skin->getSize(EGDS_TEXT_DISTANCE_X)+1; FrameRect.LowerRightCorner.Y -= skin->getSize(EGDS_TEXT_DISTANCE_Y)+1; } core::rect<s32> localClipRect = FrameRect; localClipRect.clipAgainst(AbsoluteClippingRect); // draw the text IGUIFont* font = OverrideFont; if (!OverrideFont) font = skin->getFont(); s32 cursorLine = 0; s32 charcursorpos = 0; if (font) { if (LastBreakFont != font) { breakText(); } // calculate cursor pos core::stringw *txtLine = &Text; s32 startPos = 0; core::stringw s, s2; // get mark position const bool ml = (!PasswordBox && (WordWrap || MultiLine)); const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; const s32 hlineStart = ml ? getLineFromPos(realmbgn) : 0; const s32 hlineCount = ml ? getLineFromPos(realmend) - hlineStart + 1 : 1; const s32 lineCount = ml ? BrokenText.size() : 1; // Save the override color information. // Then, alter it if the edit box is disabled. const bool prevOver = OverrideColorEnabled; const video::SColor prevColor = OverrideColor; if (Text.size()) { if (!isEnabled() && !OverrideColorEnabled) { OverrideColorEnabled = true; OverrideColor = skin->getColor(EGDC_GRAY_TEXT); } for (s32 i=0; i < lineCount; ++i) { setTextRect(i); // clipping test - don't draw anything outside the visible area core::rect<s32> c = localClipRect; c.clipAgainst(CurrentTextRect); if (!c.isValid()) continue; // get current line if (PasswordBox) { if (BrokenText.size() != 1) { BrokenText.clear(); BrokenText.push_back(core::stringw()); } if (BrokenText[0].size() != Text.size()) { BrokenText[0] = Text; for (u32 q = 0; q < Text.size(); ++q) { BrokenText[0] [q] = PasswordChar; } } txtLine = &BrokenText[0]; startPos = 0; } else { txtLine = ml ? &BrokenText[i] : &Text; startPos = ml ? BrokenTextPositions[i] : 0; } font->draw(translations->fribidize(txtLine->c_str()), CurrentTextRect, OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_BUTTON_TEXT), false, true, &localClipRect); // draw with fribidize no matter what language, because in fribidize function, // it will return the input pointer if (this->isRTLLanguage()) from Translations::isRTLText // is false // draw mark and marked text if (focus && MarkBegin != MarkEnd && i >= hlineStart && i < hlineStart + hlineCount) { s32 mbegin = 0, mend = 0; s32 lineStartPos = 0, lineEndPos = txtLine->size(); if (i == hlineStart) { // highlight start is on this line s = txtLine->subString(0, realmbgn - startPos); mbegin = font->getDimension(s.c_str()).Width; // deal with kerning mbegin += font->getKerningWidth( &((*txtLine)[realmbgn - startPos]), realmbgn - startPos > 0 ? &((*txtLine)[realmbgn - startPos - 1]) : 0); lineStartPos = realmbgn - startPos; } if (i == hlineStart + hlineCount - 1) { // highlight end is on this line s2 = txtLine->subString(0, realmend - startPos); mend = font->getDimension(s2.c_str()).Width; lineEndPos = (s32)s2.size(); } else mend = font->getDimension(txtLine->c_str()).Width; CurrentTextRect.UpperLeftCorner.X += mbegin; CurrentTextRect.LowerRightCorner.X = CurrentTextRect.UpperLeftCorner.X + mend - mbegin; // draw mark skin->draw2DRectangle(this, skin->getColor(EGDC_HIGH_LIGHT), CurrentTextRect, &localClipRect); // draw marked text s = txtLine->subString(lineStartPos, lineEndPos - lineStartPos); if (s.size()) font->draw(s.c_str(), CurrentTextRect, OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_HIGH_LIGHT_TEXT), false, true, &localClipRect); } } // Return the override color information to its previous settings. OverrideColorEnabled = prevOver; OverrideColor = prevColor; } // draw cursor if (WordWrap || MultiLine) { cursorLine = getLineFromPos(CursorPos); txtLine = &BrokenText[cursorLine]; startPos = BrokenTextPositions[cursorLine]; } s = txtLine->subString(0,CursorPos-startPos); charcursorpos = font->getDimension(s.c_str()).Width ; // + font->getKerningWidth(L"_", CursorPos-startPos > 0 ? &((*txtLine)[CursorPos-startPos-1]) : 0); if (focus && (getTime() - BlinkStartTime) % 2 == 0 && !m_rtl) { //setTextRect(cursorLine); //CurrentTextRect.UpperLeftCorner.X += charcursorpos; setTextRect(0); core::rect< s32 > caret_rect = CurrentTextRect; caret_rect.UpperLeftCorner.X += charcursorpos - 1; caret_rect.LowerRightCorner.X = caret_rect.UpperLeftCorner.X + 2; GL32_draw2DRectangle( video::SColor(255,0,0,0), caret_rect ); /* font->draw(L"_", CurrentTextRect, OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_BUTTON_TEXT), false, true, &localClipRect); */ } } // draw children IGUIElement::draw(); #endif }
//! draws the element and its children void CGUIMeshViewer::draw() { if (!IsVisible) return; IGUISkin* skin = Environment->getSkin(); IVideoDriver* driver = Environment->getVideoDriver(); rect<SINT32> viewPort = AbsoluteRect; viewPort.LowerRightCorner.x -= 1; viewPort.LowerRightCorner.y -= 1; viewPort.UpperLeftCorner.x += 1; viewPort.UpperLeftCorner.y += 1; viewPort.clipAgainst(AbsoluteClippingRect); // draw the frame rect<SINT32> frameRect(AbsoluteRect); frameRect.LowerRightCorner.y = frameRect.UpperLeftCorner.y + 1; skin->draw2DRectangle(this, skin->getColor(EGDC_3D_SHADOW), frameRect, &AbsoluteClippingRect); frameRect.LowerRightCorner.y = AbsoluteRect.LowerRightCorner.y; frameRect.LowerRightCorner.x = frameRect.UpperLeftCorner.x + 1; skin->draw2DRectangle(this, skin->getColor(EGDC_3D_SHADOW), frameRect, &AbsoluteClippingRect); frameRect = AbsoluteRect; frameRect.UpperLeftCorner.x = frameRect.LowerRightCorner.x - 1; skin->draw2DRectangle(this, skin->getColor(EGDC_3D_HIGH_LIGHT), frameRect, &AbsoluteClippingRect); frameRect = AbsoluteRect; frameRect.UpperLeftCorner.y = AbsoluteRect.LowerRightCorner.y - 1; skin->draw2DRectangle(this, skin->getColor(EGDC_3D_HIGH_LIGHT), frameRect, &AbsoluteClippingRect); // draw the mesh if (Mesh) { //TODO: if outside of screen, dont draw. // - why is the absolute clipping rect not already the screen? rect<SINT32> oldViewPort = driver->getViewPort(); driver->setViewPort(viewPort); Matrix4 mat; //CameraControl->calculateProjectionMatrix(mat); //driver->setTransform(TS_PROJECTION, mat); mat = Matrix4::IDENTITY; mat.setTrans(Vector3(0, 0, 0)); //mat.setTranslation(Vector3(0, 0, 0)); driver->setTransform(ETS_WORLD, mat); //CameraControl->calculateViewMatrix(mat); //driver->setTransform(TS_VIEW, mat); driver->setMaterial(Material); UINT32 frame = 0; if (Mesh->getFrameCount()) frame = (Timer::getTime() / 20) % Mesh->getFrameCount(); const IMesh* const m = Mesh->getMesh(frame); for (UINT32 i = 0; i<m->getMeshBufferCount(); ++i) { IMeshBuffer* mb = m->getMeshBuffer(i); driver->drawVertexPrimitiveList(mb->getVertices(), mb->getVertexCount(), mb->getIndices(), mb->getIndexCount() / 3, mb->getVertexType(), EPT_TRIANGLES, mb->getIndexType()); } driver->setViewPort(oldViewPort); } IGUIElement::draw(); }
/** * \brief Draw function draws the container component. * If texture for empty slot is not set, simple rectangles will be drawn. * This function also goes through the list of items and draws them textures in place. * \author Petar Bajic * \date July, 21 2008. */ void CGUIContainer::draw() { if(!IsVisible) return; //Draw Container IGUISkin* skin = Environment->getSkin(); core::rect<s32>* clipRect = 0; core::rect<s32> iconAbsoluteSquare; clipRect = &AbsoluteClippingRect; core::rect<s32> frameRect(AbsoluteRect); skin->draw3DSunkenPane(this, skin->getColor(EGDC_3D_HIGH_LIGHT), false, true, frameRect, clipRect); skin->draw2DRectangle(this, skin->getColor(EGDC_BUTTON_TEXT), frameRect, clipRect); //Draw Slots for(u32 x = 0; x < m_Width; x++) { for(u32 y = 0; y < m_Height; y++) { iconAbsoluteSquare.UpperLeftCorner = AbsoluteRect.UpperLeftCorner + position2d<s32>( m_Spacing.Width + x*(slotRect.getWidth() + m_Spacing.Width), m_Spacing.Height + y*(slotRect.getHeight() + m_Spacing.Height)); iconAbsoluteSquare.LowerRightCorner = position2d<s32>(iconAbsoluteSquare.UpperLeftCorner.X + slotRect.getWidth(), iconAbsoluteSquare.UpperLeftCorner.Y + slotRect.getHeight()); if (!m_SlotTexture) { //draw simlpe graphic squares Environment->getVideoDriver()->draw2DRectangle(SColor(255,50,155,0),iconAbsoluteSquare); } else { //draw fancy slot icons with textures Environment->getVideoDriver()->draw2DImage( m_SlotTexture, iconAbsoluteSquare.UpperLeftCorner, core::rect<s32>(core::position2d<s32>(0,0), m_SlotTexture->getOriginalSize()), &iconAbsoluteSquare); } } } //Draw Items in Container u32 index = 0; if (m_ListOfItems.size() == m_Width*m_Height) { for(u32 x = 0; x < m_Width; x++) { for(u32 y = 0; y < m_Height; y++) { index = x + y*m_Width; if ((m_ListOfItems[index].pick != NULL) && (m_ListOfItems[index].pick->m_IconTexture != NULL)) { iconAbsoluteSquare.UpperLeftCorner = AbsoluteRect.UpperLeftCorner + position2d<s32>( m_Spacing.Width + x*(slotRect.getWidth() + m_Spacing.Width), m_Spacing.Height + y*(slotRect.getHeight() + m_Spacing.Height)); iconAbsoluteSquare.LowerRightCorner = iconAbsoluteSquare.UpperLeftCorner + position2d<s32>(slotRect.getWidth(), slotRect.getHeight()); //Draw item in container Environment->getVideoDriver()->draw2DImage( m_ListOfItems[index].pick->m_IconTexture, iconAbsoluteSquare.UpperLeftCorner, core::rect<s32>(core::position2d<s32>(0,0), m_ListOfItems[index].pick->m_IconTexture->getOriginalSize()), &iconAbsoluteSquare); } else { //TODO: Draw invalid icon image!! } } } } }