Beispiel #1
0
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;
}
Beispiel #2
0
// Prints a segment that doesn't contain line breaks, tabs
void OpenGLStream::PrintSegment(const std::string & Segment)
{
	if (Color(1.0, 1.0, 1.0) != m_BackgroundColor)
	{
		glPushAttrib(GL_ALL_ATTRIB_BITS);
		DrawBox(m_CaretPosition, Vector2n(static_cast<sint32>(Segment.length()) * charWidth, lineHeight), m_BackgroundColor, m_BackgroundColor);
		glPopAttrib();
	}

	OglUtilsPrint(m_CaretPosition.X(), m_CaretPosition.Y(), 0, LEFT, Segment.c_str());
	m_CaretPosition.X() += Segment.length() * charWidth;
}
Beispiel #3
0
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();
}