Пример #1
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
cRect&
cRect::expandBy(int amount)
{
    position_ -= cPoint(amount, amount);
    size_ += cPoint(amount*2, amount*2);
    return *this;
}
Пример #2
0
void cProbabDistrib::SetPoints(const cProbabDistrib::cPoints & a_Points)
{
	ASSERT(!a_Points.empty());
	m_Sum = 0;
	m_Cumulative.clear();
	m_Cumulative.reserve(a_Points.size() + 1);
	int ProbSum = 0;
	int LastProb = 0;
	int LastValue = -1;
	if (a_Points[0].m_Value != 0)
	{
		m_Cumulative.push_back(cPoint(0, 0));  // Always push in the [0, 0] point for easier search algorithm bounds
		LastValue = 0;
	}
	for (cPoints::const_iterator itr = a_Points.begin(), end = a_Points.end(); itr != end; ++itr)
	{
		if (itr->m_Value == LastValue)
		{
			continue;
		}
		
		// Add the current trapezoid to the sum:
		ProbSum += (LastProb + itr->m_Probability) * (itr->m_Value - LastValue) / 2;
		LastProb = itr->m_Probability;
		LastValue = itr->m_Value;
		m_Cumulative.push_back(cPoint(itr->m_Value, ProbSum));
	}  // for itr - a_Points[]
	if (LastValue != m_MaxValue)
	{
		m_Cumulative.push_back(cPoint(m_MaxValue, 0));  // Always push in the last point for easier search algorithm bounds
	}
	m_Sum = ProbSum;
}
Пример #3
0
bool cPopMenu::processTouchMessage( const cTouchMessage & msg )
{
    bool ret = false;
    if( msg.id() == cMessage::touchUp ) {
        if( windowBelow( cPoint( msg.position().x, msg.position().y ) ) && !_skipTouch ) {
            hide();
            itemClicked( _selectedItemIndex );
        } else
            hide();

        _skipTouch = false;
        ret = true;
    }
    if( msg.id() == cMessage::touchMove || msg.id() == cMessage::touchDown ) {
        const INPUT & input = getInput();
        size_t item = itemBelowPoint( cPoint( input.touchPt.px, input.touchPt.py ) );
        if( (size_t)-1 == item )
            _skipTouch = true;
        else
            _selectedItemIndex = item;
        ret = true;
    }

    return ret;
}
Пример #4
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
cRect&
cRect::expandHeightBy(int amount)
{
    position_ -= cPoint(0, amount);
    size_ += cPoint(0, amount*2);

    return *this;
}
Пример #5
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
cRect&
cRect::expandWidthBy(int amount)
{
    position_ -= cPoint(amount, 0);
    size_ += cPoint(amount*2, 0);

    return *this;
}
Пример #6
0
bool cProbabDistrib::SetDefString(const AString & a_DefString)
{
	AStringVector Points = StringSplitAndTrim(a_DefString, ";");
	if (Points.empty())
	{
		return false;
	}
	cPoints Pts;
	for (AStringVector::const_iterator itr = Points.begin(), end = Points.end(); itr != end; ++itr)
	{
		AStringVector Split = StringSplitAndTrim(*itr, ",");
		if (Split.size() != 2)
		{
			// Bad format
			return false;
		}
		int Value = atoi(Split[0].c_str());
		int Prob  = atoi(Split[1].c_str());
		if (
			((Value == 0) && (Split[0] != "0")) ||
			((Prob  == 0) && (Split[1] != "0"))
		)
		{
			// Number parse error
			return false;
		}
		Pts.push_back(cPoint(Value, Prob));
	}  // for itr - Points[]
	
	SetPoints(Pts);
	return true;
}
Пример #7
0
int cSpace(CBotVar* &var, CBotString& retClass, void* user)
{
    int     ret;

    retClass = "point";

    if ( var == 0 )  return CBotTypIntrinsic;
    ret = cPoint(var, retClass, user);
    if ( ret != 0 )  return ret;

    if ( var == 0 )  return CBotTypIntrinsic;
    if ( var->GivType() > CBotTypDouble )  return CBotErrBadNum;
    var = var->GivNext();

    if ( var == 0 )  return CBotTypIntrinsic;
    if ( var->GivType() > CBotTypDouble )  return CBotErrBadNum;
    var = var->GivNext();

    if ( var == 0 )  return CBotTypIntrinsic;
    if ( var->GivType() > CBotTypDouble )  return CBotErrBadNum;
    var = var->GivNext();

    if ( var != 0 )  return CBotErrOverParam;
    return CBotTypIntrinsic;
}
Пример #8
0
cForm::cForm( s32 x, s32 y, u32 w, u32 h, cWindow * parent, const std::string & text )
:cWindow( parent, text )
//_renderDesc(NULL)
{
    _size = cSize( w, h );
    _position = cPoint( x, y );
    _modalRet = -1;
}
Пример #9
0
void LoginImageView::ResizeBackground()
{
	os::Desktop cDesktop;
	os::Point cPoint(cDesktop.GetResolution());
	if (cPoint != pcImage->GetSize())
	{
		pcImage->SetSize(cPoint);
	}
}
Пример #10
0
cPixmap *cTrueColorDemo::CreateTextPixmap(const char *s, int Line, int Layer, tColor ColorFg, tColor ColorBg, const cFont *Font)
{
  const int h = Font->Height(s);
  int w = Font->Width(s);
  cPixmap *Pixmap = osd->CreatePixmap(Layer, cRect((osd->Width() - w) / 2, Line, w, h));
  if (Pixmap) {
     Pixmap->Clear();
     Pixmap->SetAlpha(0);
     Pixmap->DrawText(cPoint(0, 0), s, ColorFg, ColorBg, Font);
     }
  return Pixmap;
}
Пример #11
0
cPopMenu::cPopMenu( s32 x, s32 y, u32 w, u32 h, cWindow * parent, const std::string & text )
: cWindow( parent, text )
{
    _size = cSize( w, h );
    _position = cPoint( x, y );

    _selectedItemIndex = 0;
    _itemHeight = 0;
    _itemWidth = 0;
    _barLeft = 2;

    _textColor = uiSettings().popMenuTextColor;
    _textHighLightColor = uiSettings().popMenuTextHighLightColor;
    _barColor = uiSettings().popMenuBarColor;

    _renderDesc = new cBitmapDesc();
    _renderDesc->setBltMode( BM_MASKBLT );

    _skipTouch = false;
}
Пример #12
0
CBotTypResult   cSpace(CBotVar* &var, void* user)
{
    CBotTypResult       ret;

    if ( var == 0 )  return CBotTypResult( CBotTypIntrinsic, "point" );
    ret = cPoint(var, user);
    if ( !ret.Eq(0) )  return ret;

    if ( var == 0 )  return CBotTypIntrinsic;
    if ( var->GivType() > CBotTypDouble )  return CBotTypResult( CBotErrBadNum );
    var = var->GivNext();

    if ( var == 0 )  return CBotTypIntrinsic;
    if ( var->GivType() > CBotTypDouble )  return CBotTypResult( CBotErrBadNum );
    var = var->GivNext();

    if ( var == 0 )  return CBotTypIntrinsic;
    if ( var->GivType() > CBotTypDouble )  return CBotTypResult( CBotErrBadNum );
    var = var->GivNext();

    if ( var != 0 )  return CBotErrOverParam;
    return CBotTypResult( CBotTypIntrinsic, "point" );
}
Пример #13
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
cPoint
cRect::bottomLeft() const
{
    return cPoint(minX(), maxY());
}
Пример #14
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
cRect::cRect(int _x1, int _y1, int _x2, int _y2)
{
    (*this) = cRect(cPoint(_x1, _y1), cPoint(_x2, _y2));
}
Пример #15
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
cPoint
cRect::topRight() const
{
    return cPoint(maxX(), minY());
}
Пример #16
0
void cTrueColorDemo::Action(void)
{
  cPixmap *FadeInPixmap = NULL;
  cPixmap *FadeOutPixmap = NULL;
  cPixmap *MovePixmap = NULL;
  cPixmap *NextPixmap = NULL;
  cPixmap *TilePixmap = NULL;
  cPixmap *ScrollPixmap = NULL;
  cPixmap *AnimPixmap = NULL;
  int FrameTime = 40; // ms
  int FadeTime = 1000; // ms
  int MoveTime = 4000; // ms
  int TileTime = 6000; // ms
  int ScrollWaitTime = 1000; // ms
  int ScrollLineTime = 200; // ms
  int ScrollTotalTime = 8000; // ms
  uint64_t Start = 0;
  uint64_t ScrollStartTime = 0;
  int ScrollLineNumber = 0;
  cPoint MoveStart, MoveEnd;
  cPoint TileStart, TileEnd;
  cPoint ScrollStart, ScrollEnd;
  int Line = osd->Height() / 20;
  int StartLine = Line;
  cPoint OldCursor;
  int State = 0;
  while (Running()) {
        cPixmap::Lock();
        bool Animated = false;
        uint64_t Now = cTimeMs::Now();
        if (FadeInPixmap) {
           double t = std::min(double(Now - Start) / FadeTime, 1.0);
           int Alpha = t * ALPHA_OPAQUE;
           FadeInPixmap->SetAlpha(Alpha);
           if (t >= 1)
              FadeInPixmap = NULL;
           Animated = true;
           }
        if (FadeOutPixmap) {
           double t = std::min(double(Now - Start) / FadeTime, 1.0);
           int Alpha = ALPHA_OPAQUE - t * ALPHA_OPAQUE;
           FadeOutPixmap->SetAlpha(Alpha);
           if (t >= 1)
              FadeOutPixmap = NULL;
           Animated = true;
           }
        if (MovePixmap) {
           double t = std::min(double(Now - Start) / MoveTime, 1.0);
           int x = MoveStart.X() + t * (MoveEnd.X() - MoveStart.X());
           int y = MoveStart.Y() + t * (MoveEnd.Y() - MoveStart.Y());
           cRect r = MovePixmap->ViewPort();
           r.SetPoint(x, y);
           MovePixmap->SetViewPort(r);
           if (t >= 1)
              MovePixmap = NULL;
           Animated = true;
           }
        if (TilePixmap) {
           double t = std::min(double(Now - Start) / TileTime, 1.0);
           int x = TileStart.X() + t * (TileEnd.X() - TileStart.X());
           int y = TileStart.Y() + t * (TileEnd.Y() - TileStart.Y());
           TilePixmap->SetDrawPortPoint(cPoint(x, y));
           if (t >= 1) {
              destroyablePixmap = TilePixmap;
              TilePixmap = NULL;
              }
           Animated = true;
           }
        if (ScrollPixmap) {
           if (int(Now - Start) > ScrollWaitTime) {
              if (ScrollStartTime) {
                 double t = std::min(double(Now - ScrollStartTime) / ScrollLineTime, 1.0);
                 int x = ScrollStart.X() + t * (ScrollEnd.X() - ScrollStart.X());
                 int y = ScrollStart.Y() + t * (ScrollEnd.Y() - ScrollStart.Y());
                 ScrollPixmap->SetDrawPortPoint(cPoint(x, y));
                 if (t >= 1) {
                    if (int(Now - Start) < ScrollTotalTime) {
                       cRect r = ScrollPixmap->DrawPort();
                       r.SetPoint(-r.X(), -r.Y());
                       ScrollPixmap->Pan(cPoint(0, 0), r);
                       const cFont *Font = cFont::GetFont(fontOsd);
                       cString s = cString::sprintf("Line %d", ++ScrollLineNumber);
                       ScrollPixmap->DrawRectangle(cRect(0, ScrollPixmap->ViewPort().Height(), ScrollPixmap->DrawPort().Width(), ScrollPixmap->DrawPort().Height()), clrTransparent);
                       ScrollPixmap->DrawText(cPoint(0, ScrollPixmap->ViewPort().Height()), s, clrYellow, clrTransparent, Font);
                       ScrollStartTime = Now;
                       }
                    else {
                       FadeOutPixmap = ScrollPixmap;
                       ScrollPixmap = NULL;
                       Start = cTimeMs::Now();
                       }
                    }
                 }
              else
                 ScrollStartTime = Now;
              }
           Animated = true;
           }
        if (AnimPixmap) {
           int d = AnimPixmap->ViewPort().Height();
           if (clockwise)
              d = -d;
           cPoint p = AnimPixmap->DrawPort().Point().Shifted(0, d);
           if (clockwise && p.Y() <= -AnimPixmap->DrawPort().Height())
              p.SetY(0);
           else if (!clockwise && p.Y() > 0)
              p.SetY(-(AnimPixmap->DrawPort().Height() - AnimPixmap->ViewPort().Height()));
           AnimPixmap->SetDrawPortPoint(p);
           }
        if (!Animated) {
           switch (State) {
             case 0: {
                       if (cFont *Font = cFont::CreateFont(DefaultFontOsd, osd->Height() / 10)) {
                          FadeInPixmap = CreateTextPixmap("VDR", Line, 1, clrYellow, clrTransparent, Font);
                          if (FadeInPixmap)
                             Line += FadeInPixmap->DrawPort().Height();
                          delete Font;
                          Start = cTimeMs::Now();
                          }
                       State++;
                     }
                     break;
             case 1: { 
                       FadeInPixmap = CreateTextPixmap("Video Disk Recorder", Line, 3, clrYellow, clrTransparent);
                       if (FadeInPixmap)
                          Line += FadeInPixmap->DrawPort().Height();
                       Start = cTimeMs::Now();
                       State++;
                     }
                     break;
             case 2: {
                       FadeInPixmap = CreateTextPixmap("True Color OSD Demo", Line, 1, clrYellow, clrTransparent);
                       if (FadeInPixmap)
                          Line += FadeInPixmap->DrawPort().Height();
                       Start = cTimeMs::Now();
                       State++;
                     }
                     break;
             case 3: {
                       if (cFont *Font = cFont::CreateFont(DefaultFontOsd, osd->Height() / 10)) {
                          NextPixmap = CreateTextPixmap("Millions of colors", Line, 1, clrYellow, clrTransparent, Font);
                          delete Font;
                          if (NextPixmap) {
                             FadeInPixmap = NextPixmap;
                             Start = cTimeMs::Now();
                             StartLine = Line;
                             Line += NextPixmap->DrawPort().Height();
                             }
                          }
                       State++;
                     }
                     break;
             case 4: {
                       Line += osd->Height() / 10;
                       int w = osd->Width() / 2;
                       int h = osd->Height() - Line - osd->Height() / 10;
                       cImage Image(cSize(w, h));
                       for (int y = 0; y < h; y++) {
                           for (int x = 0; x < w; x++)
                               Image.SetPixel(cPoint(x, y), HsvToColor(360 * double(x) / w, 1 - double(y) / h, 1) | 0xDF000000);
                           }
                       if (cPixmap *Pixmap = osd->CreatePixmap(2, cRect((osd->Width() - w) / 2, Line, w, h))) {
                          Pixmap->DrawImage(cPoint(0, 0), Image);
                          toggleablePixmap = Pixmap;
                          }
                       State++;
                     }
                     break;
             case 5: {
                       if (NextPixmap) {
                          MovePixmap = NextPixmap;
                          MoveStart = MovePixmap->ViewPort().Point();
                          MoveEnd.Set(osd->Width() - MovePixmap->ViewPort().Width(), osd->Height() - MovePixmap->ViewPort().Height());
                          Start = cTimeMs::Now();
                          }
                       State++;
                     }
                     break;
             case 6: {
                       TilePixmap = CreateTextPixmap("Tiled Pixmaps", StartLine, 1, clrRed, clrWhite);
                       if (TilePixmap) {
                          TilePixmap->SetViewPort(TilePixmap->ViewPort().Grown(TilePixmap->DrawPort().Width(), TilePixmap->DrawPort().Height()));
                          TilePixmap->SetAlpha(200);
                          TilePixmap->SetTile(true);
                          TileStart = TilePixmap->DrawPort().Point();
                          TileEnd = TileStart.Shifted(TilePixmap->ViewPort().Width(), TilePixmap->ViewPort().Height());
                          MovePixmap = TilePixmap;
                          MoveStart = MovePixmap->ViewPort().Point();
                          MoveEnd.Set(10, osd->Height() - MovePixmap->ViewPort().Height() - 10);
                          Start = cTimeMs::Now();
                          }
                       State++;
                     }
                     break;
             case 7: {
                       const cFont *Font = cFont::GetFont(fontOsd);
                       const char *Text = "Scrolling Pixmaps";
                       int w = Font->Width(Text);
                       int h = Font->Height();
                       if (cPixmap *Pixmap = osd->CreatePixmap(2, cRect((osd->Width() - w) / 2, StartLine, w, 2 * h), cRect(0, 0, w, 3 * h))) {
                          Pixmap->Clear();
                          Pixmap->DrawText(cPoint(0, 0), Text, clrYellow, clrTransparent, Font);
                          cString s = cString::sprintf("Line %d", ++ScrollLineNumber);
                          Pixmap->DrawText(cPoint(0, Pixmap->ViewPort().Height()), s, clrYellow, clrTransparent, Font);
                          ScrollPixmap = Pixmap;
                          ScrollStart.Set(0, 0);
                          ScrollEnd.Set(0, -h);
                          Start = cTimeMs::Now();
                          }
                       State++;
                     }
                     break;
             case 8: {
                       const cFont *Font = cFont::GetFont(fontSml);
                       const char *Text = "Animation";
                       const int Size = Font->Width(Text) + 10;
                       const int NumDots = 12;
                       const int AnimFrames = NumDots;
                       // Temporarily using pixmap layer 0 to have the text alpha blended:
                       AnimPixmap = osd->CreatePixmap(0, cRect((osd->Width() - Size) / 2, StartLine, Size, Size), cRect(0, 0, Size, Size * AnimFrames));
                       if (AnimPixmap) {
                          AnimPixmap->SetAlpha(0);
                          AnimPixmap->Clear();
                          const int Diameter = Size / 5;
                          int xc = Size / 2 - Diameter / 2;
                          for (int Frame = 0; Frame < AnimFrames; Frame++) {
                              AnimPixmap->DrawEllipse(cRect(0, Frame * Size, Size, Size), 0xDDFFFFFF);
                              int yc = Frame * Size + Size / 2 - Diameter / 2;
                              int Color = 0xFF;
                              int Delta = Color / NumDots / 3;
                              for (int a = 0; a < NumDots; a++) {
                                  double t = 2 * M_PI * (Frame + a) / NumDots;
                                  int x = xc + ((Size - Diameter) / 2 - 5) * cos(t);
                                  int y = yc + ((Size - Diameter) / 2 - 5) * sin(t);
                                  AnimPixmap->DrawEllipse(cRect(x, y, Diameter, Diameter), ArgbToColor(0xFF, Color, Color, Color));
                                  Color -= Delta;
                                  }
                              AnimPixmap->DrawText(cPoint(0, Frame * Size), Text, clrBlack, clrTransparent, cFont::GetFont(fontSml), Size, Size, taCenter);
                              }
                          AnimPixmap->SetLayer(3); // now setting the actual pixmap layer
                          FadeInPixmap = AnimPixmap;
                          LOCK_THREAD;
                          OldCursor = cursor = AnimPixmap->ViewPort().Point();
                          cursorLimits.Set(0, 0, osd->Width(), osd->Height());
                          cursorLimits.SetRight(cursorLimits.Right() - Size);
                          cursorLimits.SetBottom(cursorLimits.Bottom() - Size);
                          cursorLimits.Grow(-10, -10);
                          Start = cTimeMs::Now();
                          }
                       State++;
                     }
                     break;
             case 9: {
                       LOCK_THREAD;
                       if (cursor != OldCursor) {
                          MovePixmap = AnimPixmap;
                          MoveStart = MovePixmap->ViewPort().Point();
                          MoveEnd = OldCursor = cursor;
                          MoveTime = 500;
                          Start = cTimeMs::Now();
                          }
                     }
                     break;
             }
           }
        osd->Flush();
        cPixmap::Unlock();
        int Delta = cTimeMs::Now() - Now;
        if (Delta < FrameTime)
           cCondWait::SleepMs(FrameTime - Delta);
        }
}