示例#1
0
void EditField::Render(Rect& rectArea) throw()
{
   if (!m_text.IsInit())
      UpdateTexture();

   m_text.Render(rectArea);

   // render border
   {
      glLineWidth(2.0f);

      //if (m_bShowBorder) // TODO
      {
         glBegin(GL_LINE_LOOP);
            Color m_cForeground = Color::Black(); // TODO
            glColor4ubv(m_cForeground.m_color);
            glVertex2i(rectArea.Left(),  rectArea.Top());
            glVertex2i(rectArea.Left(),  rectArea.Bottom());
            glVertex2i(rectArea.Right(), rectArea.Bottom());
            glVertex2i(rectArea.Right(), rectArea.Top());
         glEnd();
      }
   }

   // draw caret
   if (m_bFocused)
   {
      glBegin(GL_LINES);
         glColor4ubv(Color::Blue().m_color);
         glVertex2i(rectArea.Left() + m_uiCaretX, rectArea.Top() + 2);
         glVertex2i(rectArea.Left() + m_uiCaretX, rectArea.Top() + m_uiCaretHeight + 2);
      glEnd();
   }
}
示例#2
0
static void SetRect(RECT* r, const Rect& rect)
{
    r->left = rect.Left();
    r->top = rect.Top();
    r->right = rect.Right();
    r->bottom = rect.Bottom();
}
示例#3
0
	bool Rect::IsIntersects(const Rect& rect) const
	{
		return !(
			Right() < rect.Left() ||
			rect.Right() < Left() ||
			Bottom() < rect.Top() ||
			rect.Bottom() < Top());
	}
示例#4
0
//=================================================================================================
void FlowContainer::Draw(ControlDrawData*)
{
	GUI.DrawItem(GUI.tBox, global_pos, size - Int2(16, 0), WHITE, 8, 32);

	scroll.Draw();

	int sizex = size.x - 16;

	Rect rect;
	Rect clip = Rect::Create(global_pos + Int2(2, 2), Int2(sizex - 2, size.y - 2));
	int offset = (int)scroll.offset;
	DWORD flags = (word_warp ? 0 : DT_SINGLELINE) | DT_PARSE_SPECIAL;

	for(FlowItem* fi : items)
	{
		if(fi->type != FlowItem::Button)
		{
			rect = Rect::Create(global_pos + fi->pos - Int2(0, offset), fi->size);

			// text above box
			if(rect.Bottom() < global_pos.y)
				continue;

			if(fi->state == Button::DOWN)
			{
				Rect rs = { global_pos.x + 2, rect.Top(), global_pos.x + sizex, rect.Bottom() };
				Rect out;
				if(Rect::Intersect(rs, clip, out))
					GUI.DrawSpriteRect(GUI.tPix, out, COLOR_RGBA(0, 255, 0, 128));
			}

			if(!GUI.DrawText(fi->type == FlowItem::Section ? GUI.fBig : GUI.default_font, fi->text, flags,
				(fi->state != Button::DISABLED ? BLACK : COLOR_RGB(64, 64, 64)), rect, &clip))
				break;
		}
		else
		{
			// button above or below box
			if(global_pos.y + fi->pos.y - offset + fi->size.y < global_pos.y ||
				global_pos.y + fi->pos.y - offset > global_pos.y + size.y)
				continue;

			GUI.DrawSprite(button_tex[fi->tex_id].tex[fi->state], global_pos + fi->pos - Int2(0, offset), WHITE, &clip);
		}
	}
}
示例#5
0
	void Rect::Merge(const Rect& rect)
	{
		float left = min(Left(), rect.Left());
		float right = max(Right(), rect.Right());
		float top = min(Top(), rect.Top());
		float bottom = max(Bottom(), rect.Bottom());

		origin.x = left;
		origin.y = top;
		size.width = right - left;
		size.height = bottom - top;
	}
void ProgressBar::Render(Rect& rectArea)
{
   int iMid = int(rectArea.Left() + DividerPoint());

   glDisable(GL_TEXTURE_2D);

   glBegin(GL_QUADS);
      // render background quad
      glColor4ubv(m_backColor.m_color);
      glVertex2i(rectArea.Left(), rectArea.Top());
      glVertex2i(rectArea.Left(), rectArea.Bottom());
      glVertex2i(rectArea.Right(), rectArea.Bottom());
      glVertex2i(rectArea.Right(), rectArea.Top());

      // render foreground quad
      glColor4ubv(m_color.m_color);
      glVertex2i(rectArea.Left(), rectArea.Top());
      glVertex2i(rectArea.Left(), rectArea.Bottom());
      glVertex2i(iMid, rectArea.Bottom());
      glVertex2i(iMid, rectArea.Top());
   glEnd();
}
void Checkbox::RenderCheck(Rect& rectArea)
{
    Rect rectBox = rectArea;

    int iBoxMargin = int(rectArea.Height() * 0.2);
    int iBoxMarginRight = int(rectArea.Height() * 0.8 * 0.75);

    rectBox.Left(rectBox.Left() + iBoxMargin);
    rectBox.Right(rectBox.Left() + iBoxMarginRight);
    rectBox.Top(rectBox.Top() + iBoxMargin);
    rectBox.Bottom(rectBox.Bottom() - iBoxMargin);

    OpenGL::PushedAttributes attr(GL_ENABLE_BIT | GL_LINE_BIT | GL_POINT_BIT);

    glDisable(GL_TEXTURE_2D);
    glEnable(GL_LINE_SMOOTH);
    glEnable(GL_POINT_SMOOTH);

    Color cBox = GetAttrAsColor(CheckboxAttr::BoxColor);
    glColor4ubv(cBox.m_color);
    glLineWidth(2.0);
    glBegin(GL_LINE_LOOP);
    glVertex2i(rectBox.Left(), rectBox.Bottom());
    glVertex2i(rectBox.Right(), rectBox.Bottom());
    glVertex2i(rectBox.Right(), rectBox.Top());
    glVertex2i(rectBox.Left(), rectBox.Top());
    glEnd();

    if (IsChecked())
    {
        double iCheckUnit = rectBox.Height() * 0.1;

        Point point1(int(rectBox.Left() + 3 * iCheckUnit), int(rectBox.Bottom() - 6 * iCheckUnit));
        Point point2(int(rectBox.Left() + 6 * iCheckUnit), int(rectBox.Bottom() - 3 * iCheckUnit));
        Point point3(int(rectBox.Left() + 11* iCheckUnit), int(rectBox.Bottom() - 11* iCheckUnit));

        Color cCheck = GetAttrAsColor(CheckboxAttr::CheckColor);
        glColor4ubv(cCheck.m_color);
        glLineWidth(4.0);
        glBegin(GL_LINES);
        glVertex2i(point1.X(), point1.Y());
        glVertex2i(point2.X(), point2.Y());
        glVertex2i(point2.X(), point2.Y());
        glVertex2i(point3.X(), point3.Y());
        glEnd();

        glPointSize(3.0);
        glBegin(GL_POINTS);
        glVertex2i(point1.X(), point1.Y());
        glVertex2i(point2.X(), point2.Y());
        glVertex2i(point3.X(), point3.Y());
        glEnd();
    }

    // adjust rect for size of checkbox
    int iOffset = int(rectArea.Height() * 1.1);
    rectArea.Left(rectArea.Left() + iOffset);
}
void TextTexture::Render(Rect rc)
{
   // draw text
   glEnable(GL_TEXTURE_2D);
   m_tex.Bind();

   double u = 1.0;
   double v = 1.0;

   glBegin(GL_QUADS);
      glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
      glTexCoord2d(0.0, 0.0); glVertex2i(rc.Left(),  rc.Top());
      glTexCoord2d(0.0,   v); glVertex2i(rc.Left(),  rc.Bottom());
      glTexCoord2d(  u,   v); glVertex2i(rc.Right(), rc.Bottom());
      glTexCoord2d(  u, 0.0); glVertex2i(rc.Right(), rc.Top());
   glEnd();

   glDisable(GL_TEXTURE_2D);
}
示例#9
0
文件: ListBox.cpp 项目: lcs2/carpg
//=================================================================================================
void ListBox::Draw(ControlDrawData*)
{
	if(collapsed)
	{
		// box
		GUI.DrawItem(GUI.tBox, global_pos, size, WHITE, 8, 32);

		// element
		if(selected != -1)
		{
			Rect rc = { global_pos.x + 2, global_pos.y + 2, global_pos.x + size.x - 12, global_pos.y + size.y - 2 };
			GUI.DrawText(GUI.default_font, items[selected]->ToString(), DT_SINGLELINE, BLACK, rc, &rc);
		}

		// obrazek
		GUI.DrawSprite(GUI.tDown, Int2(global_pos.x + size.x - 10, global_pos.y + (size.y - 10) / 2));

		// powinno byæ tu ale wtedy by³a by z³a kolejnoœæ rysowania
		//if(menu->visible)
		//	menu->Draw();
	}
	else
	{
		// box
		GUI.DrawItem(GUI.tBox, global_pos, real_size, WHITE, 8, 32);

		// zaznaczenie
		Rect rc = { global_pos.x, global_pos.y, global_pos.x + real_size.x, global_pos.y + real_size.y };
		if(selected != -1)
		{
			Rect rs = { global_pos.x + 2, global_pos.y - int(scrollbar.offset) + 2 + selected*item_height, global_pos.x + real_size.x - 2, 0 };
			rs.Bottom() = rs.Top() + item_height;
			Rect out;
			if(Rect::Intersect(rs, rc, out))
				GUI.DrawSpriteRect(GUI.tPix, out, COLOR_RGBA(0, 255, 0, 128));
		}

		// elementy
		Rect r = { global_pos.x + 2, global_pos.y - int(scrollbar.offset) + 2, global_pos.x + real_size.x - 2, rc.Bottom() - 2 };
		int orig_x = global_pos.x + 2;
		Matrix mat;
		for(GuiElement* e : items)
		{
			if(e->tex)
			{
				Int2 required_size = force_img_size, img_size;
				Vec2 scale;
				Control::ResizeImage(e->tex, required_size, img_size, scale);
				mat = Matrix::Transform2D(nullptr, 0.f, &scale, nullptr, 0.f, &Vec2((float)orig_x, float(r.Top() + (item_height - required_size.y) / 2)));
				GUI.DrawSprite2(e->tex, mat, nullptr, &rc, WHITE);
				r.Left() = orig_x + required_size.x;
			}
			else
				r.Left() = orig_x;
			if(!GUI.DrawText(GUI.default_font, e->ToString(), DT_SINGLELINE, BLACK, r, &rc))
				break;
			r.Top() += item_height;
		}

		// pasek przewijania
		if(require_scrollbar)
			scrollbar.Draw();
	}
}
示例#10
0
文件: Rect.hpp 项目: ekroth/pool
 bool Intersects(const Rect<T>& value) const { return !(this->Left() > value.Right() || this->Right() < value.Left() || this->Bottom() < value.Top() || this->Top() > value.Bottom()); }