Пример #1
0
	void MGUI_VSlider::_AddRenderItem(MGUI_Layout * _layout)
	{
		if (!mVisible)
			return ;

		if (mRect.DX() == 0 || mRect.DY() == 0)
			return ;

		const MGUI_LookFeel * _lookfeel = mLookFeel;
		MGUI_RenderItem * ri = _layout->GetRenderItem(GetAbsOrder(), _lookfeel->GetShader(), _lookfeel->GetSkin());
		int state = MGUI_Helper::Instance()->GetWidgetState(this);

		const MGUI_Rect & myRect = this->GetAbsRect();
		const MGUI_Rect & clRect = this->GetClientRect();
		const MGUI_RectF & uvRect = MGUI_Helper::Instance()->MapUVRect(_lookfeel->GetUVRect(state), _lookfeel->GetSkin());
		const MGUI_RectF & uvClientRect = MGUI_Helper::Instance()->MapUVRect(_lookfeel->GetUVClientRect(state), _lookfeel->GetSkin());
		const MGUI_Rect & clipRect = MGUI_Helper::Instance()->GetClipRect(mParent);

		MGUI_Helper::Instance()->AddRenderItem(ri, myRect, clRect, uvRect, uvClientRect, mColor, clipRect);

		for (int i = 0; i < mChildren.Size(); ++i)
		{
			mChildren[i]->_AddRenderItem(_layout);
		}
	}
Пример #2
0
	void MGUI_Label::_AddRenderItem(MGUI_Layout * _layout)
	{
		if (!mVisible)
			return ;

		const MGUI_LookFeel * _lookfeel = mLookFeel;

		MGUI_Rect clipRect = MGUI_Helper::Instance()->GetClipRect(mParent);

		int state = MGUI_WidgetState::Normal;

		if (!mEnable)
			state = MGUI_WidgetState::Disabled;

		if (_lookfeel)
		{
			MGUI_RenderItem * ri = _layout->GetRenderItem(GetAbsOrder(), _lookfeel->GetShader(), _lookfeel->GetSkin());

			const MGUI_Rect & myRect = this->GetAbsRect();
			const MGUI_Rect & clRect = this->GetClientRect();
			const MGUI_RectF & uvRect = MGUI_Helper::Instance()->MapUVRect(_lookfeel->GetUVRect(state), _lookfeel->GetSkin());
			const MGUI_RectF & uvClientRect = MGUI_Helper::Instance()->MapUVRect(_lookfeel->GetUVClientRect(state), _lookfeel->GetSkin());

			MGUI_Helper::Instance()->AddRenderItem(ri, myRect, clRect, uvRect, uvClientRect, mColor, clipRect);
		}

		const wchar_t * wstr = mCaption.c_str();
		int length = wcslen(wstr);

		const MGUI_Rect & clRect = this->GetAbsClientRect();

		MGUI_RectF myRect;
		myRect.x0 = (float)clRect.x0;
		myRect.y0 = clRect.CenterY() - mCharHeight / 2.0f;
		myRect.x1 = myRect.x0;
		myRect.y1 = clRect.CenterY() + mCharHeight / 2.0f;

		MGUI_RenderItem * ri = _layout->GetRenderItem(GetAbsOrder(),
			MGUI_Engine::Instance()->GetDefaultShader(), MGUI_Font::Instance()->GetTexture().c_ptr());

		MGUI_RectF _rect, _uv;
		Color4 color = mColor;
		
		if (_lookfeel)
			color *= _lookfeel->GetTextColor(state);

		for (int i = 0; i < length; ++i)
		{
			const MGUI_Glyph * glyph = MGUI_Font::Instance()->GetGlyph(wstr[i]);

			if (glyph == NULL)
				glyph = MGUI_Font::Instance()->GetGlyph(MGUI_Helper::Instance()->GetUnknownChar());

			if (glyph == NULL)
				continue;

			myRect.x1 = myRect.x0 + glyph->aspect * mCharHeight;

			if (MGUI_Helper::Instance()->Clip(_rect, _uv, myRect, glyph->uv, clipRect))
			{
				ri->AddQuad(MGUI_Helper::Instance()->GetQuad(_rect, _uv, color));
				ri->AddQuad(MGUI_Helper::Instance()->GetQuad(_rect, _uv, color));
			}

			myRect.x0 = myRect.x1;
		}
	}
Пример #3
0
int ParseHallSymbolCBMx(const char *HSym, T_SgOps *SgOps, int Options,
                        T_RTMx CBMx[2], int *HaveCBMx)
{
  int      Pedantic, NoCType;
  int      iHSym, nAddedMx, iMxSym, i;
  int      Improper, AbsOrder, Screw;
  int      RefAxis, DirCode;
  int      FirstAbsOrder;
  int      FirstRefAxis;
  T_RTMx   SMx[1];

  const T_HallTr  *HTr;

#define cHSym HSym[iHSym]
#define ReturnErr return -(++iHSym)

  rangei(2) InitRTMx(&CBMx[i], CRBF);
  *HaveCBMx = 0;

  Pedantic = NoCType = 0;

  if (Options & PHSymOptPedantic) Pedantic = 1;
  if (Options & PHSymOptNoCType)  NoCType  = 1;

  iHSym = 0;
  nAddedMx = 0;

  if (! NoCType)
  {
    while (IsHSymSpace(cHSym)) iHSym++;

    if (cHSym == '-') {
      if (ExpSgInv(SgOps, NULL) < 0) ReturnErr;
      iHSym++;
      nAddedMx++;
    }

    if (cHSym == '\0') {
      SetSgError("Error: Lattice type not specified");
      ReturnErr;
    }

        i = ExpSgSymCType(SgOps, cHSym);
    if (i < 0) ReturnErr;
    iHSym++;
    nAddedMx += i;
  }

  i = iHSym;

  while (IsHSymSpace(cHSym)) iHSym++;

  if (cHSym == '\0' || cHSym == '(')
  {
    if (Pedantic) {
      SetSgError("Error: Matrix symbol expected");
      ReturnErr;
    }

    if (cHSym == '\0') return nAddedMx;
  }

  if (! NoCType && Pedantic && iHSym == i) {
    SetSgError("Error: Space expected after lattice type symbol");
    ReturnErr;
  }

  iMxSym = 0;
  FirstAbsOrder = 0;
  FirstRefAxis  = '\0';

  while (cHSym != '\0' && cHSym != '(')
  {
    Improper = AbsOrder = Screw = 0;
    RefAxis = DirCode = '\0';
    for (i = 0; i < 3; i++) SMx->s.T[i] = 0;

    if (cHSym == '-')
    {
      Improper = 1;
      iHSym++;

      if (! IsHSymChar(cHSym)) {
        SetSgError("Error: Incomplete matrix symbol");
        ReturnErr;
      }
    }

          AbsOrder = GetAbsOrder(cHSym);
    if (! AbsOrder) {
      SetSgError("Error: Expected a symbol for rotational order");
      ReturnErr;
    }

    iHSym++;

        Screw = GetScrew(cHSym);
    if (Screw)
    {
      if (Screw >= AbsOrder) {
        SetSgError("Error: Improper screw translation");
        ReturnErr;
      }

      iHSym++;
    }

    while (IsHSymChar(cHSym))
    {
      if (  RefAxis == '\0') {
            RefAxis = GetRefAxis(cHSym);
        if (RefAxis != '\0')
        {
          if (    AbsOrder == 1
              || (AbsOrder == 3 && DirCode == '*')) {
            SetSgError("Error: Inconsistent matrix symbol");
            ReturnErr;
          }

          iHSym++;
          continue;
        }
      }
      else if (GetRefAxis(cHSym) != '\0') {
        SetSgError("Error: Multiple axis symbols");
        ReturnErr;
      }

      if (  DirCode == '\0') {
            DirCode = GetDirCode(cHSym);
        if (DirCode != '\0')
        {
          if (   ! (AbsOrder == 2 && (   DirCode ==  '"'
                                      || DirCode == '\''))
              && ! (AbsOrder == 3 && DirCode == '*'))
          {
            SetSgError("Error: Inconsistent matrix symbol");
            ReturnErr;
          }

          if (Screw) {
            SetSgError("Error: Screw translation for non-principal direction");
            ReturnErr;
          }

          iHSym++;
          continue;
        }
      }
      else if (GetDirCode(cHSym) != '\0') {
        SetSgError("Error: Multiple axis symbols");
        ReturnErr;
      }

          HTr = GetTr(cHSym);
      if (HTr)
      {
        for (i = 0; i < 3; i++)
          SMx->s.T[i] = (SMx->s.T[i] + HTr->v[i]) % STBF;

        iHSym++;
        continue;
      }

      if (cHSym == '(')
      {
        if (Pedantic) {
          SetSgError("Error: Space expected before change-of-basis operator");
          ReturnErr;
        }

        break;
      }

      SetSgError("Error: Malformed matrix symbol");
      ReturnErr;
    }

    if (RefAxis == '\0')
    {
      if      (iMxSym == 0)
      {
        if (      AbsOrder != 1
            && ! (AbsOrder == 3 && DirCode == '*'))
          RefAxis = 'z';
      }
      else if (iMxSym == 1)
      {
        if      (AbsOrder == 2)
        {
          if      (FirstAbsOrder == 2 || FirstAbsOrder == 4)
          {
            if (DirCode == '\0')
              RefAxis = 'x';
          }
          else if (FirstAbsOrder == 3 || FirstAbsOrder == 6)
          {
            if (DirCode == '\0')
              DirCode = '\'';

            RefAxis = FirstRefAxis;
          }
        }
        else if (   AbsOrder == 3
                 && (FirstAbsOrder == 2 || FirstAbsOrder == 4)
                 && DirCode == '\0')
          DirCode = '*';
      }
      else if (iMxSym == 2)
      {
        if (AbsOrder == 3 && DirCode == '\0')
          DirCode = '*';
      }
    }

    if (RefAxis == '\0' && (   DirCode ==  '"'
                            || DirCode == '\''))
      RefAxis = 'z';

    if (RefAxis == '\0' && AbsOrder != 1 && DirCode != '*') {
      SetSgError("Error: Need explicit axis symbol");
      ReturnErr;
    }

    if (GetRMx(Improper, AbsOrder, RefAxis, DirCode, SMx) < 0) {
      SetSgError("Internal Error: GetRMx() failed");
      ReturnErr;
    }

    if (Screw)
    {
      switch (RefAxis)
      {
        case 'x': i = 0; break;
        case 'y': i = 1; break;
        default:  i = 2; break;
      }

      SMx->s.T[i] += STBF * Screw / AbsOrder;
    }

    if (ExpSgSMx(SgOps, SMx) < 0)
      ReturnErr;

    if (iMxSym == 0) {
      FirstAbsOrder = AbsOrder;
      FirstRefAxis  = RefAxis;
    }

    iMxSym++;

    if (Improper || AbsOrder != 1)
      nAddedMx++;

    while (IsHSymSpace(cHSym)) iHSym++;
  }

  if (cHSym == '(')
  {
    iHSym++;

        i = ParseShortCBO(&cHSym, ')', CBMx[0].s.T, CTBF);
    if (i <= 0) {
          i = ParseStrXYZ(&cHSym, ')', &CBMx[0], CRBF, CTBF);
      if (i < 0) {
        iHSym += -i - 1;
        SetSgError("Error: Malformed change-of-basis operator");
        ReturnErr;
      }
    }

    iHSym += i - 1;

    while (IsHSymSpace(cHSym)) iHSym++;

    if (cHSym != ')') {
      SetSgError(
        "Error: Closing parenthesis expected after change-of-basis operator");
      ReturnErr;
    }

    if (InverseRTMx(&CBMx[0], &CBMx[1], CRBF) == 0) {
      SetSgError("Error: Change-of-basis operator is not invertible");
      ReturnErr;
    }

    iHSym++;
    *HaveCBMx = -iHSym;
  }

  while (IsHSymSpace(cHSym)) iHSym++;

  if (cHSym != '\0') {
    SetSgError("Error: Unexpected extra character");
    ReturnErr;
  }

#undef cHSym
#undef ReturnErr

  return nAddedMx;
}