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 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; }
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(); } } }
void DrawAroundBox(Vector2n Position, Vector2n Size, Color BackgroundColor) { DrawAroundBox(Position, Size, BackgroundColor, Color(0.3, 0.3, 0.3)); }
void DrawAroundBox(Vector2n Position, Vector2n Size) { DrawAroundBox(Position, Size, Color(1.0, 1.0, 1.0)); }
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_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 }
void TextFieldWidget::Render() { //Color BackgroundColor(1.0, 1.0, 1.0); Color BackgroundColor = m_BackgroundColor; 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); // TEST auto ContentWithInsertion = m_Content; 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)); LocalPosition = m_TypingModule.GetInsertionPosition(LocalPosition); auto InsertionPosition = GetNearestCaretPosition(LocalPosition); ContentWithInsertion.insert(InsertionPosition, m_TypingModule.GetString()); } } } glColor3d(0, 0, 0); OpenGLStream OpenGLStream(GetPosition()); OpenGLStream << ContentWithInsertion.substr(0, std::min(m_CaretPosition, m_SelectionPosition)); Vector2n CaretPosition; // Remember caret position at selection front if (std::min(m_CaretPosition, m_SelectionPosition) == m_CaretPosition) { CaretPosition = OpenGLStream.GetCaretPosition(); } // Draw selected text as highlighted if (HasTypingFocus()) { OpenGLStream.SetBackgroundColor(Color(static_cast<uint8>(195), 212, 242)); } else { OpenGLStream.SetBackgroundColor(Color(static_cast<uint8>(212), 212, 212)); } auto SelectionLength = std::max(m_CaretPosition, m_SelectionPosition) - std::min(m_CaretPosition, m_SelectionPosition); OpenGLStream << ContentWithInsertion.substr(std::min(m_CaretPosition, m_SelectionPosition), SelectionLength); OpenGLStream.SetBackgroundColor(Color(1.0, 1.0, 1.0)); // Remember caret position at selection back if (std::max(m_CaretPosition, m_SelectionPosition) == m_CaretPosition) { CaretPosition = OpenGLStream.GetCaretPosition(); } OpenGLStream << ContentWithInsertion.substr(std::max(m_CaretPosition, m_SelectionPosition)); //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(); } } }