void ButtonWidget::Render() { Color BackgroundColor(0.99, 0.99, 0.99); Color BorderColor(0.5, 0.5, 0.5); if (CheckHover() && CheckActive()) { BackgroundColor[0] = 0.5; BackgroundColor[1] = 0.5; BackgroundColor[2] = 0.5; BorderColor[0] = 0.0; BorderColor[1] = 0.0; BorderColor[2] = 0.0; } //else if ((CheckHover() && !CheckAnyActive()) || (!CheckHover() && CheckActive())) else if (CheckHover() && !CheckActive()) { BackgroundColor[0] = 1.0; BackgroundColor[1] = 1.0; BackgroundColor[2] = 1.0; BorderColor[0] = 0.898; BorderColor[1] = 0.765; BorderColor[2] = 0.396; } else { } DrawBox(GetPosition(), GetDimensions(), BackgroundColor, BorderColor); }
void FunctionWidget::Render() { Color BackgroundColor(1.0, 1.0, 1.0); Color BorderColor(0.3, 0.3, 0.3); /*if (CheckHover(WidgetManager) && CheckActive(WidgetManager)) { } else if ((CheckHover(WidgetManager) && !CheckAnyActive(WidgetManager)) || (!CheckHover(WidgetManager) && CheckActive(WidgetManager))) { BorderColor[0] = 0.898; BorderColor[1] = 0.765; BorderColor[2] = 0.396; } else { }*/ //if (CheckHover()) // HACK if (HasTypingFocus()) { BorderColor[0] = 0.898; BorderColor[1] = 0.765; BorderColor[2] = 0.396; } DrawAroundBox(GetPosition(), GetDimensions(), BackgroundColor, BorderColor); glColor3d(0, 0, 0); OglUtilsPrint(GetPosition().X(), GetPosition().Y() - lineHeight, 0, LEFT, "Global Function"); OpenGLStream OpenGLStream(GetPosition()); OpenGLStream << m_Function; }
void MultitouchTestBoxWidget::Render() { const Color Colors[] = { Color(static_cast<uint8>(0), 140, 0), Color(static_cast<uint8>(0), 98, 140), Color(static_cast<uint8>(194), 74, 0), Color(static_cast<uint8>(89), 0, 140), Color(static_cast<uint8>(191), 150, 0), Color(static_cast<uint8>(140), 0, 0) }; Color BackgroundColor(Colors[m_Color]); //Color BorderColor(0.0, 0.0, 0.0); Color BorderColor(BackgroundColor); if (CheckHover()) { BorderColor[0] = 0.898; BorderColor[1] = 0.765; BorderColor[2] = 0.396; } DrawBox(GetPosition(), GetDimensions(), BackgroundColor, BorderColor); }
void AHUD::ShowDebugInfo(float& YL, float& YPos) { if (DebugCanvas != nullptr ) { FLinearColor BackgroundColor(0.f, 0.f, 0.f, 0.2f); DebugCanvas->Canvas->DrawTile(0, 0, DebugCanvas->ClipX, DebugCanvas->ClipY, 0.f, 0.f, 0.f, 0.f, BackgroundColor); FDebugDisplayInfo DisplayInfo(DebugDisplay, ToggledDebugCategories); if (bShowDebugForReticleTarget) { FRotator CamRot; FVector CamLoc; PlayerOwner->GetPlayerViewPoint(CamLoc, CamRot); FCollisionQueryParams TraceParams(NAME_None, true, PlayerOwner->PlayerCameraManager->ViewTarget.Target); FHitResult Hit; bool bHit = GetWorld()->LineTraceSingleByChannel(Hit, CamLoc, CamRot.Vector() * 100000.f + CamLoc, ECC_WorldDynamic, TraceParams); if (bHit) { AActor* HitActor = Hit.Actor.Get(); if (HitActor && (ShowDebugTargetDesiredClass == NULL || HitActor->IsA(ShowDebugTargetDesiredClass))) { ShowDebugTargetActor = HitActor; } } } else { ShowDebugTargetActor = PlayerOwner->PlayerCameraManager->ViewTarget.Target; } if (ShowDebugTargetActor && !ShowDebugTargetActor->IsPendingKill()) { ShowDebugTargetActor->DisplayDebug(DebugCanvas, DisplayInfo, YL, YPos); } if (ShouldDisplayDebug(NAME_Game)) { AGameModeBase* AuthGameMode = GetWorld()->GetAuthGameMode(); if (AuthGameMode) { AuthGameMode->DisplayDebug(DebugCanvas, DisplayInfo, YL, YPos); } } if (bShowDebugInfo) { OnShowDebugInfo.Broadcast(this, DebugCanvas, DisplayInfo, YL, YPos); } } }
void ViewBuffer::_RenderGlyph(int32 x, int32 y, const char* string, uint8 attr, bool fill) { BPoint where(x * CHAR_WIDTH, (y + 1) * CHAR_HEIGHT - 3); SetHighColor(GetPaletteEntry(ForegroundColor(attr))); if (fill) { SetLowColor(GetPaletteEntry(BackgroundColor(attr))); FillRect(BRect(x * CHAR_WIDTH, y * CHAR_HEIGHT, (x + 1) * CHAR_WIDTH, (y + 1) * CHAR_HEIGHT), B_SOLID_LOW); } DrawString(string, where); }
GLScene::GLScene() { dist=100; center_x=center_y=0; center_z=1; beta=15; alfa=30; //by default, the view size is 800*600 ox=0; oy=0; h=600; w=800; showGrid=false; showFrame=true; BackgroundColor(0.2f,0.2f,0.2f); }
void ViewBuffer::Clear(uint8 attr) { if (LockLooper()) { SetLowColor(GetPaletteEntry(BackgroundColor(attr))); SetViewColor(LowColor()); FillRect(Frame(), B_SOLID_LOW); Sync(); UnlockLooper(); } fCursorX = -1; fCursorY = -1; if (fGlyphGrid) memset(fGlyphGrid, 0, fRows * fColumns * sizeof(uint16)); }
e_status_t EWin32GraphicsWindow::SetBackgroundColor(e_rgb_color bkColor) { if(bkColor == BackgroundColor()) return E_OK; if(fRequestWin == NULL) return E_ERROR; etk_win32_gdi_callback_t callback; callback.command = WM_ETK_MESSAGE_SET_WINDOW_BACKGROUND; callback.win = this; callback.bkColor = bkColor; bool successed = (SendMessageA(fRequestWin, WM_ETK_MESSAGE, WM_ETK_MESSAGE_WINDOW, (LPARAM)&callback) == (LRESULT)TRUE); if(!successed) return E_ERROR; EGraphicsDrawable::SetBackgroundColor(bkColor); return E_OK; }
void LabelWidget::Render() { // TODO: Refactor this out if (!m_Visible) return; Color BackgroundColor(1.0, 1.0, 1.0); Color BorderColor(0.6, 0.6, 0.6); auto Content = m_Content(); ModifyDimensions() = Concept::GetDimensions(Content); if (Background::Normal == m_Background) { DrawAroundBox(GetPosition(), GetDimensions(), BackgroundColor, BorderColor); } OpenGLStream OpenGLStream(GetPosition()); OpenGLStream << Content; }
void CheckBox::createTexture(void) { Kernel *kernel = Kernel::getInstance(); if ((_cTexture = kernel->getWidgetTexture(CHECKBOX)) != NULL) return; ColorRGBA pColor1(183,191,213,255); ColorRGBA pColor2( 71, 92,148,255); ColorRGBA pColor3(100,118,165,255); ColorRGBA pColor4(207,212,226,255); ColorRGBA colorClick(170,220,255,60); ColorRGBA colorOver(colorClick[0] - 100,colorClick[1] - 80,colorClick[2] - 40, colorClick[3]); ColorRGBA BackgroundColor(112,112,112,0); // create texture object _cTexture = new ComponentTexture(32, 16); kernel->setWidgetTexture(CHECKBOX, _cTexture); _cTexture->setTextureEnvMode(GL_MODULATE); // !selected _cTexture->addTexture(Point(0,0), 13, 13, data::CheckBox); // selected _cTexture->addTexture(Point(13,0), 13, 13, data::CheckBoxPressed); // over MatrixTemplate<ColorRGBA> over(1, 1, ColorRGBA(0,0,0,0)); Texture2D::drawPoint(over, Point(0,0), colorOver); _cTexture->addTexture(Point(0,13), over); // hold MatrixTemplate<ColorRGBA> hold(1, 1, ColorRGBA(0,0,0,0)); Texture2D::drawPoint(hold, Point(0,0), colorClick); _cTexture->addTexture(Point(1,13), hold); _cTexture->createTexture(); }
template <typename T> void MenuWidget<T>::Render() { Color BackgroundColor(1.0, 1.0, 1.0); Color BorderColor(0.3, 0.3, 0.3); /*if (CheckHover(WidgetManager) && CheckActive(WidgetManager)) { } else if ((CheckHover(WidgetManager) && !CheckAnyActive(WidgetManager)) || (!CheckHover(WidgetManager) && CheckActive(WidgetManager))) { BorderColor[0] = 0.898; BorderColor[1] = 0.765; BorderColor[2] = 0.396; } else { }*/ // HACK, TODO: Make this a single DRY const if (HasTypingFocus()) { BorderColor[0] = 0.898; BorderColor[1] = 0.765; BorderColor[2] = 0.396; } // TODO: Think if I should outsource the entire rendering code for more generality // Draw list { UpdateDimensions(); // LATER: Optimize by not repeating this calculation each time, only when something changes? if (m_Entries.empty()) { BackgroundColor[0] = 234 / 255.0; BackgroundColor[1] = 233 / 255.0; BackgroundColor[2] = 190 / 255.0; } DrawAroundBox(GetPosition(), GetDimensions(), BackgroundColor, BorderColor); // TEST auto Spot = m_Entries.end(); if ( nullptr != m_TypingModule && !m_TypingModule->GetString().empty()) { for (auto & Pointer : GetGestureRecognizer().GetConnected()) { if (Pointer::VirtualCategory::POINTING == Pointer->GetVirtualCategory()) { Vector2n GlobalPosition(Pointer->GetPointerState().GetAxisState(0).GetPosition(), Pointer->GetPointerState().GetAxisState(1).GetPosition()); Vector2n LocalPosition(GlobalToLocal(GlobalPosition)); Spot = m_Entries.begin() + (LocalPosition.Y() / lineHeight); } } } OpenGLStream OpenGLStream(GetPosition()); //for (auto & Entry : m_Entries) for (auto Entry = m_Entries.begin(); m_Entries.end() != Entry; ++Entry) { if (Entry == Spot) OpenGLStream << endl; if (Entry - m_Entries.begin() == m_SelectedEntryId) { if (HasTypingFocus()) DrawBox(GetPosition() + Vector2n(0, static_cast<sint32>((Entry - m_Entries.begin() + (Entry >= Spot)) * lineHeight)), Vector2n(GetDimensions().X(), lineHeight), m_SelectedColor, m_SelectedColor); else DrawBox(GetPosition() + Vector2n(0, static_cast<sint32>((Entry - m_Entries.begin() + (Entry >= Spot)) * lineHeight)), Vector2n(GetDimensions().X(), lineHeight), m_UnfocusedSelectedColor, m_UnfocusedSelectedColor); } OpenGLStream << *Entry << endl; } } }
template <typename T> void ListWidget<T>::Render() { Color BackgroundColor(1.0, 1.0, 1.0); Color BorderColor(0.3, 0.3, 0.3); /*if (CheckHover(WidgetManager) && CheckActive(WidgetManager)) { } else if ((CheckHover(WidgetManager) && !CheckAnyActive(WidgetManager)) || (!CheckHover(WidgetManager) && CheckActive(WidgetManager))) { BorderColor[0] = 0.898; BorderColor[1] = 0.765; BorderColor[2] = 0.396; } else { }*/ // TODO: Think if I should outsource the entire rendering code for more generality // Draw list { UpdateDimensions(); // LATER: Optimize by not repeating this calculation each time, only when something changes? if (m_List.empty()) { BackgroundColor[0] = 234 / 255.0; BackgroundColor[1] = 233 / 255.0; BackgroundColor[2] = 190 / 255.0; } DrawAroundBox(GetPosition(), GetDimensions(), BackgroundColor, BorderColor); // TODO: This part is not general std::string Description[2] = { "#include <", ">" }; glColor3d(0, 0, 0); OglUtilsPrint(GetPosition().X(), GetPosition().Y(), 0, RIGHT, Description[0].c_str()); glColor3d(0, 0, 0); OglUtilsPrint(GetPosition().X() + GetDimensions().X(), GetPosition().Y(), 0, LEFT, Description[1].c_str()); // TEST auto Spot = m_List.end(); if (!m_TypingModule.GetString().empty()) { for (auto & Pointer : GetGestureRecognizer().GetConnected()) { if (Pointer::VirtualCategory::POINTING == Pointer->GetVirtualCategory()) { Vector2n GlobalPosition(Pointer->GetPointerState().GetAxisState(0).GetPosition(), Pointer->GetPointerState().GetAxisState(1).GetPosition()); Vector2n LocalPosition(GlobalToLocal(GlobalPosition)); Spot = m_List.begin() + (LocalPosition.Y() / lineHeight); } } } OpenGLStream OpenGLStream(GetPosition()); for (auto ListEntry = m_List.begin(); m_List.end() != ListEntry; ++ListEntry) { if (ListEntry == Spot) OpenGLStream << endl; OpenGLStream << *ListEntry << endl; } } CompositeWidget::Render(); }
void ConceptStringBoxWidget::Render() { Color BackgroundColor(1.0, 1.0, 1.0); Color BorderColor(0.3, 0.3, 0.3); /*if (CheckHover(WidgetManager) && CheckActive(WidgetManager)) { } else if ((CheckHover(WidgetManager) && !CheckAnyActive(WidgetManager)) || (!CheckHover(WidgetManager) && CheckActive(WidgetManager))) { BorderColor[0] = 0.898; BorderColor[1] = 0.765; BorderColor[2] = 0.396; } else { }*/ //if (CheckHover()) // HACK if (HasTypingFocus()) { BorderColor[0] = 0.898; BorderColor[1] = 0.765; BorderColor[2] = 0.396; } /*glBegin(GL_QUADS); glVertex2d(m_Position.X(), m_Position.Y()); glVertex2d(m_Position.X(), m_Position.Y() + 30); glVertex2d(m_Position.X() + 30, m_Position.Y() + 30); glVertex2d(m_Position.X() + 30, m_Position.Y()); glEnd();*/ DrawAroundBox(GetPosition(), GetDimensions(), BackgroundColor, BorderColor); glColor3d(0, 0, 0); OpenGLStream OpenGLStream(GetPosition()); //OpenGLStream << m_Content.substr(0, m_CaretPosition); // TODO: Optimize this somehow? OpenGLStream << decltype(m_Content)(m_Content.begin(), m_Content.begin() + m_CaretPosition); // TEST if (!m_TypingModule.GetString().empty()) { for (auto & Pointer : GetGestureRecognizer().GetConnected()) { if (Pointer::VirtualCategory::POINTING == Pointer->GetVirtualCategory()) { //Vector2n GlobalPosition(Pointer->GetPointerState().GetAxisState(0).GetPosition(), Pointer->GetPointerState().GetAxisState(1).GetPosition()); //Vector2n LocalPosition(GlobalToLocal(GlobalPosition)); //auto ConceptId = FindOrCreateConcept(Entry); OpenGLStream << m_TypingModule.GetString(); } } } Vector2n CaretPosition = OpenGLStream.GetCaretPosition(); //OpenGLStream << m_Content.substr(m_CaretPosition); // TODO: Optimize this somehow? OpenGLStream << decltype(m_Content)(m_Content.begin() + m_CaretPosition, m_Content.end()); //if (CheckHover()) // HACK if (HasTypingFocus()) { // Draw caret //if (static_cast<int>(glfwGetTime() * 2) % 2) { glPushMatrix(); glTranslated(CaretPosition.X(), CaretPosition.Y(), 0); glColor3d(0, 0, 0); glBegin(GL_QUADS); glVertex2d(-1, 0); glVertex2d(-1, lineHeight); glVertex2d(+1, lineHeight); glVertex2d(+1, 0); glEnd(); glPopMatrix(); } } }
//: BeOS hook function // Draws a BeOS style title tab. This method class the two attached // decorations to draw the maximize and close buttons. void CMDITitleView::Draw(BRect updateRect) { Window()->BeginViewTransaction(); // --- Calc colors CColor background = BackgroundColor(); CColor highlight( MIN(background.red+80, 255), MIN(background.green+80, 255), MIN(background.blue+80, 255) ); CColor darkShadow( MAX(background.red-81, 0), MAX(background.green-81, 0), MAX(background.blue-81, 0) ); CColor textColor = Active() ? CColor::Black : CColor(80, 80, 80); // --- Fill background SetHighColor(background); FillRect(updateRect); // --- Draw borders BRect bounds = Bounds(); float width = bounds.Width(); float height = bounds.Height(); SetHighColor(CColor::BeShadow); MovePenTo(0, height); StrokeLine(BPoint(0, 0)); StrokeLine(BPoint(width, 0)); SetHighColor(CColor::BeDarkShadow); MovePenTo(width, 1); StrokeLine(BPoint(width, height)); SetHighColor(highlight); MovePenTo(1, height); StrokeLine(BPoint(1, 1)); StrokeLine(BPoint(width-1, 1)); SetHighColor(darkShadow); MovePenTo(width-1, 2); StrokeLine(BPoint(width-1, height)); // --- Draw close button if(DisplayCloseButton()) { closeButton->SetPosition(CloseButtonRect().LeftTop()); closeButton->SetBackgroundColor(background); closeButton->Draw(); } // --- Draw maximize button if(DisplayMaximizeButton()) { maximizeButton->SetPosition(MaximizeButtonRect().LeftTop()); maximizeButton->SetBackgroundColor(background); maximizeButton->Draw(); } // --- Draw title BFont titleFont; GetTitleFont(&titleFont); const char *title = target->Title(); char *truncatedTitle = new char [strlen(title)+3]; float titleWidth; BPoint titlePos; GetTitleWidthAndPos(titleWidth, titlePos); titleFont.GetTruncatedStrings(&title, 1, B_TRUNCATE_END, titleWidth, &truncatedTitle); SetHighColor(textColor); SetLowColor(background); SetFont(&titleFont); DrawString(truncatedTitle, strlen(truncatedTitle), titlePos); delete [] truncatedTitle; Window()->EndViewTransaction(); }
void FSpriteGeometryEditingHelper::DrawGeometry(const FSceneView& View, FPrimitiveDrawInterface& PDI, const FLinearColor& GeometryVertexColor, const FLinearColor& NegativeGeometryVertexColor) { if (GeometryBeingEdited == nullptr) { return; } FSpriteGeometryCollection& Geometry = GetGeometryChecked(); const bool bIsHitTesting = PDI.IsHitTesting(); const float UnitsPerPixel = EditorContext->SelectedItemGetUnitsPerPixel(); // Run thru the geometry shapes and draw hit proxies for them for (int32 ShapeIndex = 0; ShapeIndex < Geometry.Shapes.Num(); ++ShapeIndex) { const FSpriteGeometryShape& Shape = Geometry.Shapes[ShapeIndex]; const bool bIsShapeSelected = IsGeometrySelected(FShapeVertexPair(ShapeIndex, INDEX_NONE)); const FLinearColor LineColorRaw = Shape.bNegativeWinding ? NegativeGeometryVertexColor : GeometryVertexColor; const FLinearColor VertexColor = Shape.bNegativeWinding ? NegativeGeometryVertexColor : GeometryVertexColor; const FLinearColor LineColor = Shape.IsShapeValid() ? LineColorRaw : FMath::Lerp(LineColorRaw, FLinearColor::Red, 0.8f); // Draw the interior (allowing selection of the whole shape) if (bIsHitTesting) { TSharedPtr<FSpriteSelectedShape> Data = MakeShareable(new FSpriteSelectedShape(EditorContext, Geometry, ShapeIndex, /*bIsBackground=*/ true)); PDI.SetHitProxy(new HSpriteSelectableObjectHitProxy(Data)); } FColor BackgroundColor(bIsShapeSelected ? SpriteEditingConstantsEX::GeometrySelectedColor : LineColor); BackgroundColor.A = 4; FMaterialRenderProxy* ShapeMaterialProxy = WidgetVertexColorMaterial->GetRenderProxy(bIsShapeSelected); if (Shape.ShapeType == ESpriteShapeType::Circle) { //@TODO: This is going to have issues if we ever support ellipses const FVector2D PixelSpaceRadius = Shape.BoxSize * 0.5f; const float WorldSpaceRadius = PixelSpaceRadius.X * UnitsPerPixel; const FVector CircleCenterWorldPos = EditorContext->TextureSpaceToWorldSpace(Shape.BoxPosition); DrawDisc(&PDI, CircleCenterWorldPos, PaperAxisX, PaperAxisY, BackgroundColor, WorldSpaceRadius, SpriteEditingConstantsEX::CircleShapeNumSides, ShapeMaterialProxy, SDPG_Foreground); } else { TArray<FVector2D> SourceTextureSpaceVertices; Shape.GetTextureSpaceVertices(/*out*/ SourceTextureSpaceVertices); TArray<FVector2D> TriangulatedPolygonVertices; PaperGeomTools::TriangulatePoly(/*out*/ TriangulatedPolygonVertices, SourceTextureSpaceVertices, /*bKeepColinearVertices=*/ true); if (((TriangulatedPolygonVertices.Num() % 3) == 0) && (TriangulatedPolygonVertices.Num() > 0)) { FDynamicMeshBuilder MeshBuilder; FDynamicMeshVertex MeshVertex; MeshVertex.Color = BackgroundColor; MeshVertex.TextureCoordinate = FVector2D::ZeroVector; MeshVertex.SetTangents(PaperAxisX, PaperAxisY, PaperAxisZ); for (const FVector2D& SrcTriangleVertex : TriangulatedPolygonVertices) { MeshVertex.Position = EditorContext->TextureSpaceToWorldSpace(SrcTriangleVertex); MeshBuilder.AddVertex(MeshVertex); } for (int32 TriangleIndex = 0; TriangleIndex < TriangulatedPolygonVertices.Num(); TriangleIndex += 3) { MeshBuilder.AddTriangle(TriangleIndex, TriangleIndex + 1, TriangleIndex + 2); } MeshBuilder.Draw(&PDI, FMatrix::Identity, ShapeMaterialProxy, SDPG_Foreground); } } if (bIsHitTesting) { PDI.SetHitProxy(nullptr); } } }
/// <summary> ///Get background color Blue /// </summary> int GetBGColB() { int anRgb[3]; BackgroundColor (anRgb[0], anRgb[1], anRgb[2]); return anRgb[2]; }
template <typename T> void ListWidget<T>::Render() { Color BackgroundColor(1.0, 1.0, 1.0); Color BorderColor(0.3, 0.3, 0.3); /*if (CheckHover(WidgetManager) && CheckActive(WidgetManager)) { } else if ((CheckHover(WidgetManager) && !CheckAnyActive(WidgetManager)) || (!CheckHover(WidgetManager) && CheckActive(WidgetManager))) { BorderColor[0] = 0.898; BorderColor[1] = 0.765; BorderColor[2] = 0.396; } else { }*/ // TODO: Think if I should outsource the entire rendering code for more generality // Draw list { UpdateDimensions(); // LATER: Optimize by not repeating this calculation each time, only when something changes? if (m_Entries.empty()) { BackgroundColor[0] = 234 / 255.0; BackgroundColor[1] = 233 / 255.0; BackgroundColor[2] = 190 / 255.0; } DrawAroundBox(GetPosition(), GetDimensions(), BackgroundColor, BorderColor); // TEST auto Spot = m_Entries.end(); if (!m_TypingModule.GetString().empty()) { for (auto & Pointer : GetGestureRecognizer().GetConnected()) { if (Pointer::VirtualCategory::POINTING == Pointer->GetVirtualCategory()) { Vector2n GlobalPosition(Pointer->GetPointerState().GetAxisState(0).GetPosition(), Pointer->GetPointerState().GetAxisState(1).GetPosition()); Vector2n LocalPosition(GlobalToLocal(GlobalPosition)); Spot = m_Entries.begin() + (LocalPosition.Y() / lineHeight); } } } OpenGLStream OpenGLStream(GetPosition()); for (auto Entry = m_Entries.begin(); m_Entries.end() != Entry; ++Entry) { if (Entry == Spot) OpenGLStream << endl; OpenGLStream << *Entry << endl; } } #if DECISION_LIST_WIDGET_IS_COMPOSITE CompositeWidget::Render(); #endif }