Пример #1
0
void testing_$$_expand(bool verbose)
{
	if (verbose) {
		fprintf( stdout, "\n----- testing_$$_expand ----\n\n");
	}

	REQUIRE( next$$("$$(STUFF)", 0) == "STUFF" );
	REQUIRE( next$$_left("$$(STUFF)", 0) == "" );
	REQUIRE( next$$_right("$$(STUFF)", 0) == "" );
	REQUIRE( next$$("_$$(STUFF:a,b,c) $(BAR)", 0) == "STUFF:a,b,c" );
	REQUIRE( next$$("$$(DOLLARDOLLAR)", 0) == "DOLLARDOLLAR" );

	REQUIRE( next$$("$$([1+2])", 0) == "[1+2]" );
	REQUIRE( next$$("$$([ 1 + 2*3 ])", 0) == "[ 1 + 2*3 ]" );
	REQUIRE( next$$("$$([ splitslotname(Target.Name)[0] ])", 0) == "[ splitslotname(Target.Name)[0] ]" );

	REQUIRE( next$$("$(FOO) $$(STUFF:2) $(BAR)", 0) == "STUFF:2" );
	REQUIRE( next$$_left("$(FOO) $$(STUFF:2) $(BAR)", 0) == "$(FOO) " );
	REQUIRE( next$$_right("$(FOO) $$(STUFF:2) $(BAR)", 0) == " $(BAR)" );

	REQUIRE( next$$("_$$(STUFF:2) $$([1+2])$$(BAR)", 0) == "STUFF:2" );
	REQUIRE( next$$("_$$(STUFF:2) $$([1+2])$$(BAR)", 2) == "[1+2]" );
	REQUIRE( next$$("_$$(STUFF:2) $$([1+2])$$(BAR)", 20) == "BAR" );

	REQUIRE( next$$_left("_$$(STUFF:2) $$([1+2])$$(BAR)", 0) == "_" );
	REQUIRE( next$$_left("_$$(STUFF:2) $$([1+2])$$(BAR)", 12) == "_$$(STUFF:2) " );
	REQUIRE( next$$_left("_$$(STUFF:2) $$([1+2])$$(BAR)", 20) == "_$$(STUFF:2) $$([1+2])" );

	REQUIRE( next$$_right("_$$(STUFF:2) $$([1+2])$$(BAR)", 0) == " $$([1+2])$$(BAR)" );
	REQUIRE( next$$_right("_$$(STUFF:2) $$([1+2])$$(BAR)", 2) == "$$(BAR)" );
	REQUIRE( next$$_right("_$$(STUFF:2) $$([1+2])$$(BAR)", 20) == "" );
}
Пример #2
0
IPTR Register__MUIM_Layout(struct IClass *cl, Object *obj, struct MUIP_Layout *msg)
{
    struct Register_DATA *data = INST_DATA(cl, obj);
    ULONG retval = 1;
    IPTR active;

    get(obj, MUIA_Group_ActivePage, &active);

    if (active != data->active)
    {
        data->oldactive = data->active;
        data->active = active;
    }
    SetHardCoord(obj,data);
    DoMethod(obj, MUIM_UpdateInnerSizes);

    DoSuperMethodA(cl, obj, (Msg)msg);

    data->left        = _left(obj);
    data->top         = _top(obj);
    data->framewidth  = _width(obj);
    data->frameheight = _height(obj) - data->tab_height;

    LayoutTabItems(obj,data);

    /*      D(bug("Register_Layout : left=%d, top=%d / framewidth=%d, frameheight=%d\n", */
    /*   	  data->left, data->top, data->framewidth, data->frameheight)); */

    return retval;
}
Пример #3
0
void Bluetooth() 
{ 


    if(Serial.available()>0) 
    { 
      uint8_t readbuf=Serial.read(); 
      r_buffer[num]=readbuf; 
      num++; 
      delay(2); 
      Serial.println(num); 
      if(readbuf==0X3B) 
      { 
        if(num==3) 
        { 


          recivevalue=(r_buffer[0]<<8)|(r_buffer[1]); 


        } 


        num=0; 
        mark0=1; 
      }  
    }     






    if(mark0==1) 
    { 
      mark0=0; 


      switch(recivevalue) 
      { 
      case up    : //Serial.println(up,HEX); 
        _up(); 
        break; 
      case down  : //Serial.println(down,HEX); 
        _down(); 
        break; 
      case left  :  
        _left(); 
        break; 
      case right :  
        _right(); 
        break; 
      } 
     
  } 
} 
Пример #4
0
void HeapSort::maxHeapify( int* heap, int heapSize, int parent )
{
	int largest;
	if (_left(parent) < heapSize && heap[_left(parent)] > heap[parent])
		largest = _left(parent);
	else largest = parent;

	if (_right(parent) < heapSize && heap[_right(parent)] > heap[largest])
		largest = _right(parent);

	if (largest != parent)
	{
		int tmp = heap[parent];
		heap[parent] = heap[largest];
		heap[largest] = tmp;
		++mCost;++mCost;
		maxHeapify(heap, heapSize, largest);
	}
}
Пример #5
0
/**
 * Main loop function that will handle the current auton state. This functions
 * could take a large finite amount of time to run due to the nature of the
 * robot.
 * @param hw is Hardware object to manipulate
 */
void auto_update(Hardware& hw){
  // Run current state and update for next update call
  switch(_state){
    case MOVE_FWD:
      _state = _forward(hw);
      break;
    case MOVE_BWD:
      _state = _backward(hw);
      break;
    case MOVE_LEFT:
      _state = _left(hw);
      break;
    case MOVE_RIGHT:
      _state = _right(hw);
      break;
    case HEAD_LEFT:
      _state = _headLeft(hw);
      break;
    case HEAD_CENTER:
      _state = _headCenter(hw);
      break;
    case HEAD_RIGHT:
      _state = _headRight(hw);
      break;
    case MEASURE_DISTANCE:
      _state = _measureDistance(hw);
      break;
    case WHICH_WAY_SLCT:
      _state = _whichWay(hw);
      break;
    case STUCK_FRONT:
      _state = _stuckFront(hw);
        break;
    case STUCK_BACK:
      _state = _stuckBack(hw);
      break;
    case DELAY_FWD_HEAD:
      _state = _delayForwardToHead(hw);
      break;
    case DELAY_BWD_HEAD:
      _state = _delayBackwardToHead(hw);
      break;
    case ERROR:
      hw.stopMoving();
      auto_reset(); // reset state-machine due to error
      break;
    default:
      hw.stopMoving();
      auto_reset(); //something broke, reset state-machine
      break;
  }
}
Пример #6
0
IPTR Register__MUIM_Draw(struct IClass *cl, Object *obj, struct MUIP_Draw *msg)
{
    struct Register_DATA *data = INST_DATA(cl, obj);

    /* Before all the current page is drawn erase the part of the area covered
     * by tabs which is not erased (between _left(obj) and _mleft(obj) and so on */
    if (data->oldactive != data->active && (msg->flags & MADF_DRAWUPDATE) && (data->active/data->columns != data->oldactive/data->columns))
    {
        int left,top,width,height;

        left = _mright(obj)+1;
        top = _mtop(obj);
        width = _right(obj) - left; /* +1 - 1*/
        height = _mheight(obj);

        DoMethod(obj, MUIM_DrawBackground, left, top, width, height, left, top, 0);

        left = _left(obj)+1; /* +1 because the register frame shouldn't be ereased */
        width = _mleft(obj) - left; /* + 1 - 1 */

        DoMethod(obj, MUIM_DrawBackground, left, top, width, height, left, top, 0);

        top = _top(obj) + data->tab_height;
        height = _mtop(obj) - top; /* + 1 - 1 */
        width = _width(obj)-2;

        if (height > 0 && width > 0)
            DoMethod(obj, MUIM_DrawBackground, left, top, width, height, left, top, 0);

        top = _mbottom(obj);
        height = _bottom(obj) - top; /* + 1 - 1 */

        if (height > 0 && width > 0)
            DoMethod(obj, MUIM_DrawBackground, left, top, width, height, left, top, 0);
    }

    DoSuperMethodA(cl,obj,(Msg)msg);

    /*      D(bug("Register_Draw : flags = %d\n", msg->flags)); */
    if (!(msg->flags & (MADF_DRAWOBJECT | MADF_DRAWUPDATE)))
        return(0);

    RenderRegisterTab(cl, obj, msg->flags);

    data->oldactive = data->active;
    return TRUE;
}
Пример #7
0
    /*
    ** Layout function. Here, we have to call MUI_Layout() for each
    ** our children. MUI wants us to place them in a rectangle
    ** defined by (0,0,lm->lm_Layout.Width-1,lm->lm_Layout.Height-1)
    ** You are free to put the children anywhere in this rectangle.
    */
BOOL MUI_Layout (Object *obj, LONG left, LONG top, LONG width, LONG height,
		 ULONG flags)
{
    static ULONG method = MUIM_Layout;
    Object *parent = _parent(obj);

/*
 * Called only by groups, never by windows
 */
    g_assert(parent != NULL);

    _left(obj) = left + _mleft(parent);
    _top(obj) = top + _mtop(parent);
    _width(obj) = width;
    _height(obj) = height;

    DoMethodA(obj, (Msg)&method);

    return TRUE;
}
Пример #8
0
int32_t _read_withvector( struct buffer * self, int32_t fd  )
{
    struct iovec vec[ 2 ];
    char extra[ RECV_BUFFER_SIZE ];
    int32_t nread = 0, left = _left(self);

    vec[0].iov_base = self->buffer + self->length;
    vec[0].iov_len = left;
    vec[1].iov_base = extra;
    vec[1].iov_len = sizeof( extra );

    nread = (int32_t)readv( fd, vec, left < sizeof(extra) ? 2 : 1 );
    if ( nread > left )
    {
        self->length += left;
        buffer_append( self, extra, (uint32_t)(nread-left) );
    }
    else if ( nread > 0 )
    {
        self->length += nread;
    }

    return nread;
}
Пример #9
0
void FlLayout::updateLayout()
{
	int cury=5;

	mWindow->begin();
	intvectorn guidelines;
	for(int i=0; i<mWidgets.size()-1; i++)
	{
		guidelines.setSize(mWidgets[i].mState.mGuideLines.size());

		for(int j=0; j<guidelines.size(); j++)
			guidelines[j]=sop::interpolateInt(mWidgets[i].mState.mGuideLines[j], 3, w()-2);

		// widget?? 5??? ?????? ????? ???.

		//int gap=5;
		int gap=mWidgets[i].mState.mHorizSpace;
#define _left(i)	(guidelines[mWidgets[i].mState.mStartSlot]+gap/2)
#define _right(i) (guidelines[MIN(mWidgets[i].mState.mEndSlot, guidelines.size()-1)]-(gap-gap/2))
#define _currWidth(i)	   (_right(i)-_left(i))
#define _curHeight(i)		(mWidgets[i].mState.mWidgetHeight)


		/*
		// title ??? ??????? offset ??? ????? ?????. ????????? ????? widget pos?? ??????? ?? ??.
		if((mWidgets[i].mType=="Slider" ||
			mWidgets[i].mType=="Choice" ||
			mWidgets[i].mType=="Input"||
			mWidgets[i].mType.right(8)=="Adjuster") && mWidgets[i].widget()->label())
		{
			int offset=60;
			if(mWidgets[i].mType=="Slider" && mWidgets[i].mState.mSliderType==VALUE_VERT_SLIDER)
				offset=0;

			Fl_Widget* o=(Fl_Widget*)mWidgets[i].mWidget;
			o->resize(_left(i)+offset, cury, _currWidth(i)-offset, _curHeight(i));
		}
		else */
		if(mWidgets[i].mType=="Layout" || mWidgets[i].mType=="LayoutGroup")
		{
			FlLayoutGroup* o=(FlLayoutGroup*)mWidgets[i].mWidget;

			_curHeight(i)=o->minimumHeight()+30;
			if(o)
				o->resize(_left(i), cury+15, _currWidth(i), _curHeight(i)-15);

			o->updateLayout();
		}
		else
		{
			Fl_Widget* o=(Fl_Widget*)mWidgets[i].mWidget;
			if(o)
				o->resize(_left(i), cury, _currWidth(i), _curHeight(i));
		}

		if(mWidgets[i].mState.mEndSlot>=mWidgets[i].mState.mGuideLines.size()-1)
		{
			cury+=_curHeight(i)+mWidgets[i+1].mState.mLineSpace;
		}
	}

	mWindow->end();
	end();

	m_minimumHeight=cury;
#ifndef NO_GUI

	if(m_minimumHeight>h())
	{
		mScrollbar->show();
		mScrollbar->value(0, h(), 0, m_minimumHeight);
	}
	else
	{
		mScrollbar->value(0, h(), 0, m_minimumHeight);
		mScrollbar->hide();
	}
	// connect
	for(int i=0; i<mWidgets.size()-1; i++)
	{
		// parent?? ???? ??? ??? widget?? ????? ???? layout?? ??????? ?????????.
		// ?????????? ????????? parent??u?? callee?? ????? ??б╞? ???? ??????.
		// ?? parent??  Fl_Group(??? Fl_Window ??)?? FlLayout?? ???u??.

		Fl_Widget*o=mWidgets[i].mWidget;


		if(mWidgets[i].mType=="Choice")
		{
			FlMenu* o=&(((FlChoice*)mWidgets[i].mWidget)->menu);
			for(int item=0; item<o->m_nMenu; item++)
				o->m_aMenuItem[item].callback(cbFunc);
		}
	}
	mWindow->redraw();
#endif
}
Пример #10
0
/**************************************************************************
   Render tab bar
**************************************************************************/
static void RenderRegisterTab(struct IClass *cl, Object *obj, ULONG flags)
{
    struct Register_DATA *data = INST_DATA(cl, obj);
    WORD tabx;

    /*
     * Erase / prepare for drawing
     */
    if (flags & MADF_DRAWOBJECT)
    {
        DoMethod(obj, MUIM_DrawParentBackground, data->left, data->top,
                 data->framewidth, data->tab_height - 1, data->left, data->top, 0);
    }
    else
    {
        /* draw parent bg over oldactive */
        IPTR method;
        WORD old_left, old_top, old_width, old_height;
        struct RegisterTabItem *ri = &data->items[data->oldactive];
        if (data->oldactive >= data->columns) method = MUIM_DrawBackground;
        else method = MUIM_DrawParentBackground;

        old_left = _left(obj) + ri->x1 - 2;
        old_top = _top(obj) + ri->y1;
        old_width = ri->x2 - ri->x1 + 5;
        old_height = data->tab_height - 1;
        DoMethod(obj, method, old_left, old_top,
                 old_width, old_height, old_left, old_top, 0);
        SetDrMd(_rp(obj), JAM1);
        SetAPen(_rp(obj), _pens(obj)[MPEN_SHINE]);
        RectFill(_rp(obj), old_left, old_top + old_height, old_left + old_width, old_top + old_height);
    }

    SetDrMd(_rp(obj), JAM1);
    SetAPen(_rp(obj), _pens(obj)[MPEN_SHINE]);
    SetFont(_rp(obj), _font(obj));
    SetSoftStyle(_rp(obj), FS_NORMAL, AskSoftStyle(_rp(obj)));


    /*
     * Draw new graphics
     */
    /* register frame */
    if (flags & MADF_DRAWOBJECT || (data->active / data->columns != data->oldactive / data->columns))
    {
        int i,y,tabs_on_bottom = 0;

        SetAPen(_rp(obj), _pens(obj)[MPEN_SHINE]);

        RectFill(_rp(obj), data->left,
                 data->top + data->tab_height - 1,
                 data->left,
                 data->top + data->tab_height + data->frameheight - 1);

        y = data->top + data->tab_height - 1;

        for (i=0; i<data->rows; i++)
        {
            if (!tabs_on_bottom && (i > data->active/data->columns))
            {
                y = _bottom(obj) - muiAreaData(obj)->mad_InnerBottom + data->tab_height;
                tabs_on_bottom = 1;
            }

            RectFill(_rp(obj), data->left + 1, y, data->left + data->framewidth - 2, y);
            y += data->tab_height;
        }

        SetAPen(_rp(obj), _pens(obj)[MPEN_SHADOW]);

        RectFill(_rp(obj), data->left + data->framewidth - 1,
                 data->top + data->tab_height - 1,
                 data->left + data->framewidth - 1,
                 data->top + data->tab_height + data->frameheight - 1);

        RectFill(_rp(obj), data->left + 1,
                 data->top + data->tab_height + data->frameheight - 1,
                 data->left + data->framewidth - 2,
                 data->top + data->tab_height + data->frameheight - 1);
        for(i = 0, tabx = 0; i < data->numitems; i++)
        {
            RenderRegisterTabItem(cl, obj, i);
        }
    }
    else
    {
        /* If active register has been changed and is on same row we simply draw both registers only */
        RenderRegisterTabItem(cl, obj, data->active);
        RenderRegisterTabItem(cl, obj, data->oldactive);
    }

}
Пример #11
0
/**************************************************************************
   Render one item
**************************************************************************/
static void RenderRegisterTabItem(struct IClass *cl, Object *obj,  WORD item)
{
    struct Register_DATA *data = INST_DATA(cl, obj);
    struct RegisterTabItem *ri = &data->items[item];
    struct TextExtent extent;
    WORD fitlen;  /* text len fitting in alloted space */
    WORD fitpix;  /* text pixels fitting in alloted space */
    WORD x, y;
    WORD top_item_bar_y;
    WORD bottom_item_bar_y;
    WORD left_item_bar_x;
    WORD right_item_bar_x;
    WORD item_bar_width;
    WORD text_y;
    WORD item_bg_height;
    WORD fitwidth;

    if ((item < 0) || (item >= data->numitems)) return;

    y = data->top + ri->y1;

    if (data->active == item)
    {
        top_item_bar_y = _top(obj) + ri->y1;
        bottom_item_bar_y = _top(obj) + ri->y2 - 2;
        left_item_bar_x = _left(obj) + ri->x1 - 1;
        right_item_bar_x = _left(obj) + ri->x2 + 1;
        item_bg_height = data->tab_height;
        text_y = y + data->ty;
        item_bar_width = right_item_bar_x - left_item_bar_x + 1;
        /* fill tab with register background */
        DoMethod(obj,MUIM_DrawBackground, left_item_bar_x, top_item_bar_y + 4,
                 item_bar_width, item_bg_height - 4,
                 left_item_bar_x, top_item_bar_y + 4, 0);
        DoMethod(obj,MUIM_DrawBackground, left_item_bar_x + 2, top_item_bar_y + 2,
                 item_bar_width - (2 * 2), 2,
                 left_item_bar_x + 2, top_item_bar_y + 2, 0);
        DoMethod(obj,MUIM_DrawBackground, left_item_bar_x + 4, top_item_bar_y + 1,
                 item_bar_width - (2 * 4), 1,
                 left_item_bar_x + 4, top_item_bar_y + 1, 0);
    }
    else
    {
        top_item_bar_y = _top(obj) + ri->y1 + 2;
        bottom_item_bar_y = _top(obj) + ri->y2 - 1;
        left_item_bar_x = _left(obj) + ri->x1;
        right_item_bar_x = _left(obj) + ri->x2;
        item_bg_height = data->tab_height - 3;
        text_y = y + data->ty + 1;
        item_bar_width = right_item_bar_x - left_item_bar_x + 1;
        SetAPen(_rp(obj), _pens(obj)[MPEN_BACKGROUND]);
        RectFill(_rp(obj), left_item_bar_x, top_item_bar_y + 4,
                 right_item_bar_x, bottom_item_bar_y);
        RectFill(_rp(obj), left_item_bar_x + 2, top_item_bar_y + 2,
                 right_item_bar_x - 2, top_item_bar_y + 3);
        RectFill(_rp(obj), left_item_bar_x + 4, top_item_bar_y + 1,
                 right_item_bar_x - 4, top_item_bar_y + 1);
    }

    /* top horiz bar */
    SetAPen(_rp(obj), _pens(obj)[MPEN_SHINE]);
    RectFill(_rp(obj), left_item_bar_x + 4, top_item_bar_y, right_item_bar_x - 4, top_item_bar_y);
    /* left vert bar */
    RectFill(_rp(obj), left_item_bar_x, top_item_bar_y + 4, left_item_bar_x, bottom_item_bar_y);
    WritePixel(_rp(obj), left_item_bar_x + 1, top_item_bar_y + 3);
    WritePixel(_rp(obj), left_item_bar_x + 1, top_item_bar_y + 2);
    WritePixel(_rp(obj), left_item_bar_x + 2, top_item_bar_y + 1);
    WritePixel(_rp(obj), left_item_bar_x + 3, top_item_bar_y + 1);
    SetAPen(_rp(obj), _pens(obj)[MPEN_HALFSHINE]);
    WritePixel(_rp(obj), left_item_bar_x + 3, top_item_bar_y);
    WritePixel(_rp(obj), left_item_bar_x + 4, top_item_bar_y + 1);
    WritePixel(_rp(obj), left_item_bar_x + 2, top_item_bar_y + 2);
    WritePixel(_rp(obj), left_item_bar_x + 3, top_item_bar_y + 2);
    WritePixel(_rp(obj), left_item_bar_x + 2, top_item_bar_y + 3);
    WritePixel(_rp(obj), left_item_bar_x, top_item_bar_y + 3);
    WritePixel(_rp(obj), left_item_bar_x + 1, top_item_bar_y + 4);

    if (data->active == item)
    {
        /* bottom horiz bar */
        SetAPen(_rp(obj), _pens(obj)[MPEN_SHINE]);
        WritePixel(_rp(obj), left_item_bar_x - 1, bottom_item_bar_y + 1);
        SetAPen(_rp(obj), _pens(obj)[MPEN_SHADOW]);
        WritePixel(_rp(obj), right_item_bar_x + 1, bottom_item_bar_y + 1);
        DoMethod(obj,MUIM_DrawBackground, left_item_bar_x - 1, bottom_item_bar_y + 2,
                 item_bar_width + (2 * 1), 1,
                 left_item_bar_x - 1, bottom_item_bar_y + 2, 0);

    }
    /* right vert bar */
    SetAPen(_rp(obj), _pens(obj)[MPEN_SHADOW]);
    WritePixel(_rp(obj), right_item_bar_x - 1, top_item_bar_y + 2);
    RectFill(_rp(obj), right_item_bar_x, top_item_bar_y + 4, right_item_bar_x, bottom_item_bar_y);
    SetAPen(_rp(obj), _pens(obj)[MPEN_HALFSHADOW]);
    WritePixel(_rp(obj), right_item_bar_x - 2, top_item_bar_y + 1);
    WritePixel(_rp(obj), right_item_bar_x - 1, top_item_bar_y + 3);
    WritePixel(_rp(obj), right_item_bar_x, top_item_bar_y + 3);
    SetAPen(_rp(obj), _pens(obj)[MPEN_BACKGROUND]);
    WritePixel(_rp(obj), right_item_bar_x - 3, top_item_bar_y + 1);

    /* text */
    fitwidth = item_bar_width - TEXTSPACING;
    fitlen = TextFit(_rp(obj), ri->text, ri->textlen, &extent, NULL, 1, fitwidth, data->tab_height);
    fitpix = extent.te_Width;
    /*      D(bug("extent for %s (len=%d) in %d pix = %d chars, %d pix [%x,%x,%x]\n", */
    /*  	  ri->text, ri->textlen, fitwidth, fitlen, fitpix, _rp(obj), _rp(obj)->Font, _font(obj))); */
    x = left_item_bar_x + (item_bar_width - fitpix) / 2;
    SetDrMd(_rp(obj), JAM1);
    SetAPen(_rp(obj), _pens(obj)[MPEN_TEXT]);
    Move(_rp(obj), x, text_y);
    Text(_rp(obj), ri->text, fitlen);
}
Пример #12
0
void ParticleLayer3D::Draw(Camera * camera)
{
    if(!sprite)
        return;

    Matrix4 rotationMatrix = Matrix4::IDENTITY;
    switch(RenderManager::Instance()->GetRenderOrientation())
    {
    case Core::SCREEN_ORIENTATION_LANDSCAPE_LEFT:
        //glRotatef(90.0f, 0.0f, 0.0f, 1.0f);
        rotationMatrix.CreateRotation(Vector3(0.0f, 0.0f, 1.0f), DegToRad(90.0f));
        break;
    case Core::SCREEN_ORIENTATION_LANDSCAPE_RIGHT:
        //glRotatef(-90.0f, 0.0f, 0.0f, 1.0f);
        rotationMatrix.CreateRotation(Vector3(0.0f, 0.0f, 1.0f), DegToRad(-90.0f));
        break;
    }

    Matrix4 mv = RenderManager::Instance()->GetMatrix(RenderManager::MATRIX_MODELVIEW)*rotationMatrix;

    Vector3 _up(mv._01, mv._11, mv._21);
    Vector3 _left(mv._00, mv._10, mv._20);

    verts.clear();
    textures.clear();
    colors.clear();
    int32 totalCount = 0;

    Particle * current = head;
    if(current)
    {
        renderBatch->GetMaterial()->GetRenderState()->SetTexture(sprite->GetTexture(current->frame));
    }

    while(current != 0)
    {
        Vector3 dx(_left);
        Vector3 dy(_up);

        //dx *= sqrt(2.f);
        //dy *= sqrt(2.f);

        float32 sine;
        float32 cosine;
        SinCosFast(current->angle, sine, cosine);

        float32 pivotRight = ((sprite->GetWidth()-pivotPoint.x)*current->size.x*current->sizeOverLife)/2.f;
        float32 pivotLeft = (pivotPoint.x*current->size.x*current->sizeOverLife)/2.f;
        float32 pivotUp = (pivotPoint.y*current->size.y*current->sizeOverLife)/2.f;
        float32 pivotDown = ((sprite->GetHeight()-pivotPoint.y)*current->size.y*current->sizeOverLife)/2.f;

        Vector3 dxc = dx*cosine;
        Vector3 dxs = dx*sine;
        Vector3 dyc = dy*cosine;
        Vector3 dys = dy*sine;

        Vector3 topLeft = current->position+(-dxc+dys)*pivotUp + (dxs+dyc)*pivotLeft;
        Vector3 topRight = current->position+(-dxs-dyc)*pivotRight + (-dxc+dys)*pivotUp;
        Vector3 botLeft = current->position+(dxs+dyc)*pivotLeft + (dxc-dys)*pivotDown;
        Vector3 botRight = current->position+(dxc-dys)*pivotDown + (-dxs-dyc)*pivotRight;

        verts.push_back(topLeft.x);//0
        verts.push_back(topLeft.y);
        verts.push_back(topLeft.z);

        verts.push_back(topRight.x);//1
        verts.push_back(topRight.y);
        verts.push_back(topRight.z);

        verts.push_back(botLeft.x);//2
        verts.push_back(botLeft.y);
        verts.push_back(botLeft.z);

        verts.push_back(botLeft.x);//2
        verts.push_back(botLeft.y);
        verts.push_back(botLeft.z);

        verts.push_back(topRight.x);//1
        verts.push_back(topRight.y);
        verts.push_back(topRight.z);

        verts.push_back(botRight.x);//3
        verts.push_back(botRight.y);
        verts.push_back(botRight.z);

        float32 *pT = sprite->GetTextureVerts(current->frame);

        textures.push_back(pT[0]);
        textures.push_back(pT[1]);

        textures.push_back(pT[2]);
        textures.push_back(pT[3]);

        textures.push_back(pT[4]);
        textures.push_back(pT[5]);

        textures.push_back(pT[4]);
        textures.push_back(pT[5]);

        textures.push_back(pT[2]);
        textures.push_back(pT[3]);

        textures.push_back(pT[6]);
        textures.push_back(pT[7]);

        // Yuri Coder, 2013/04/03. Need to use drawColor here instead of just colot
        // to take colorOverlife property into account.
        uint32 color = (((uint32)(current->drawColor.a*255.f))<<24) |  (((uint32)(current->drawColor.b*255.f))<<16) | (((uint32)(current->drawColor.g*255.f))<<8) | ((uint32)(current->drawColor.r*255.f));
        for(int32 i = 0; i < 6; ++i)
        {
            colors.push_back(color);
        }

        totalCount++;
        current = TYPE_PARTICLES == type ? current->next : 0;
    }

    renderBatch->SetTotalCount(totalCount);
    if(totalCount > 0)
    {
        renderData->SetStream(EVF_VERTEX, TYPE_FLOAT, 3, 0, &verts.front());
        renderData->SetStream(EVF_TEXCOORD0, TYPE_FLOAT, 2, 0, &textures.front());
        renderData->SetStream(EVF_COLOR, TYPE_UNSIGNED_BYTE, 4, 0, &colors.front());

        renderBatch->SetRenderDataObject(renderData);
    }
}
Пример #13
0
/**************************************************************************
 MUIM_HandleEvent
**************************************************************************/
IPTR Numericbutton__MUIM_HandleEvent(struct IClass *cl, Object *obj, struct MUIP_HandleEvent *msg)
{
    struct Numericbutton_DATA *data = INST_DATA(cl, obj);

    if (!msg->imsg)
    {
        return 0;
    }

    switch(msg->imsg->Class)
    {
    case IDCMP_MOUSEBUTTONS:
        switch(msg->imsg->Code)
        {
        case SELECTDOWN:
            if (_between(_left(obj), msg->imsg->MouseX, _right(obj)) &&
                    _between(_top(obj), msg->imsg->MouseY, _bottom(obj)) &&
                    (muiAreaData(obj)->mad_Flags & MADF_CANDRAW) &&
                    !data->popwin)
            {
                data->knob_clickoffset_x = msg->imsg->MouseX - _mleft(obj);

                if (MakePopupWin(obj, data))
                {
                    DoMethod(_win(obj), MUIM_Window_RemEventHandler, (IPTR)&data->ehn);
                    data->ehn.ehn_Events |= IDCMP_MOUSEMOVE;
                    DoMethod(_win(obj), MUIM_Window_AddEventHandler, (IPTR)&data->ehn);

                    return 0;
                }
            }
            break;

        case SELECTUP:
        case MENUUP:
        case MIDDLEUP:
        default:
            if (data->popwin)
            {
                KillPopupWin(obj, data);
                if ((msg->imsg->Code == SELECTUP))
                {
                    set(obj, MUIA_Numeric_Value, data->knob_val);
                }
                return 0;
            }
            break;


        } /* switch(msg->imsg->Code) */
        break;

    case IDCMP_MOUSEMOVE:
        if (data->popwin)
        {
            DrawKnob(obj, data, FALSE);

            return 0;
        }
        break;

    } /* switch(msg->imsg->Class) */

    return 0;
}
Пример #14
0
IPTR Popimage__MUIM_Popimage_OpenWindow(struct IClass *cl, Object *obj, Msg msg)
{
    struct Popimage_DATA *data = INST_DATA(cl, obj);

    if (!data->wnd)
    {
    	Object *ok_button, *cancel_button;
    	char *img_spec;
	ULONG x = 0, y = 0;

	get(_win(obj), MUIA_Window_LeftEdge, &x);
	get(_win(obj), MUIA_Window_TopEdge, &y);

	get(obj,MUIA_Imagedisplay_Spec, &img_spec);

    	data->wnd = (Object *)WindowObject,
            MUIA_Window_Title,       (IPTR) data->wintitle,
            MUIA_Window_Activate,           TRUE,
            MUIA_Window_IsSubWindow,        TRUE,
            MUIA_Window_LeftEdge,           _left(obj) + x,
            MUIA_Window_TopEdge,            _bottom(obj) + y + 1,
            
            WindowContents, (IPTR) VGroup,
                Child, (IPTR) (data->imageadjust = MUI_NewObject
                (
                    MUIC_Imageadjust,
                    MUIA_CycleChain,              1,
                    MUIA_Imageadjust_Spec,        (IPTR) img_spec,
                    MUIA_Imageadjust_Type,        data->adjust_type,
		    MUIA_Imageadjust_Originator,  (IPTR) obj,
                    TAG_DONE
                )),
                Child, (IPTR) HGroup,
                    MUIA_Group_SameWidth, TRUE,
                    Child, (IPTR) (ok_button = MUI_MakeObject
                    (
                        MUIO_Button, (IPTR) "_Ok"
                    )),
                    Child, (IPTR) HVSpace,
                    Child, (IPTR) HVSpace,
                    Child, (IPTR) (cancel_button = MUI_MakeObject
                    (
                        MUIO_Button, (IPTR) "_Cancel"
                    )),
                End,
            End,
        End;

	if (data->wnd)
	{
	    set(ok_button, MUIA_CycleChain, 1);
	    set(cancel_button, MUIA_CycleChain, 1);

	    DoMethod(_app(obj),OM_ADDMEMBER,(IPTR)data->wnd);

	    DoMethod
            (
                ok_button, MUIM_Notify, MUIA_Pressed, FALSE, 
                (IPTR) _app(obj), 5, MUIM_Application_PushMethod, 
                (IPTR) obj, 2, MUIM_Popimage_CloseWindow, TRUE
            );
	    DoMethod
            (
                cancel_button, MUIM_Notify, MUIA_Pressed, FALSE, 
                (IPTR) _app(obj), 5, MUIM_Application_PushMethod, 
                (IPTR) obj, 2, MUIM_Popimage_CloseWindow, FALSE
            );
	    DoMethod
            (
                data->wnd, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, 
                (IPTR) _app(obj), 5, MUIM_Application_PushMethod, 
                (IPTR) obj, 2, MUIM_Popimage_CloseWindow, FALSE
            );
	}
    }

    if (data->wnd)
    {
	ULONG opened;

	set(data->wnd, MUIA_Window_Open,TRUE);
	get(data->wnd, MUIA_Window_Open, &opened);
	if (!opened)
	{
	    DoMethod(obj, MUIM_Popimage_CloseWindow, FALSE);
	}
    }

    return 1;
}
Пример #15
0
QVariant ZStringFormatter::transform(QVariant val){
    if(method() == ZFMT_METHOD_STR_CONCAT){ //!                      concat( with )
        return _concat(val,arg("with",ZML_DEFAULT_PARAM_NAME));

    }else if(method() == ZFMT_METHOD_STR_DOWNCASE){ //!              downcase
        return _downcase(val);

    }else if(method() == ZFMT_METHOD_STR_ELIDE){ //!                 elide( [maxLength [, placeholder]] )
        if(arg("placeholder").isValid())
            return _elide(val, arg("maxLength",ZML_DEFAULT_PARAM_NAME).toInt(), arg("placeholder").toString());
        else
            return _elide(val, arg("maxLength",ZML_DEFAULT_PARAM_NAME).toInt());

    }else if(method() == ZFMT_METHOD_STR_LEFT){ //!                  left( length )
        return _left(val, arg("length",ZML_DEFAULT_PARAM_NAME).toUInt());

    }else if(method() == ZFMT_METHOD_STR_LEFTOF){ //!                leftOf( delimiter )
        return _leftOf(val, arg("delimiter",ZML_DEFAULT_PARAM_NAME).toString());

    }else if(method() == ZFMT_METHOD_STR_LELIDE){ //!                lelide( [maxLength [, placeholder]] )
        if(arg("placeholder").isValid())
            return _lelide(val, arg("maxLength",ZML_DEFAULT_PARAM_NAME).toInt(), arg("placeholder").toString());
        else
            return _lelide(val, arg("maxLength",ZML_DEFAULT_PARAM_NAME).toInt());

    }else if(method() == ZFMT_METHOD_STR_LPAD){ //!                  lpad( length [, symbol] )
        if(arg("symbol").isValid())
            return _lpad(val, arg("length",ZML_DEFAULT_PARAM_NAME).toUInt(), arg("symbol").toChar());
        else
            return _lpad(val, arg("length",ZML_DEFAULT_PARAM_NAME).toUInt());

    }else if(method() == ZFMT_METHOD_STR_LSHIFT){ //!                lshift( places )
        return _lshift(val, arg("places", ZML_DEFAULT_PARAM_NAME).toUInt());

    }else if(method() == ZFMT_METHOD_STR_LTRIM){ //!                 ltrim( [pattern] )
        if(arg("pattern").isValid())
            return _ltrim(val, arg("pattern",ZML_DEFAULT_PARAM_NAME).toString());
        else
            return _ltrim(val);

    }else if(method() == ZFMT_METHOD_STR_RELIDE){ //!                relide( [maxLength [, placeholder]] )
        if(arg("placeholder").isValid())
            return _relide(val, arg("maxLength",ZML_DEFAULT_PARAM_NAME).toInt(), arg("placeholder").toString());
        else
            return _relide(val, arg("maxLength",ZML_DEFAULT_PARAM_NAME).toInt());

    }else if(method() == ZFMT_METHOD_STR_REPEAT){ //!                repeat( times )
        return _repeat(val, arg("times",ZML_DEFAULT_PARAM_NAME).toUInt());

    }else if(method() == ZFMT_METHOD_STR_REVERSE){ //!               reverse
        return _reverse(val);

    }else if(method() == ZFMT_METHOD_STR_RIGHT){ //!                 right( length )
        return _right(val, arg("length",ZML_DEFAULT_PARAM_NAME).toUInt());

    }else if(method() == ZFMT_METHOD_STR_RIGHTOF){ //!               rightOf( delimiter )
        return _rightOf(val, arg("delimiter",ZML_DEFAULT_PARAM_NAME).toString());

    }else if(method() == ZFMT_METHOD_STR_RPAD){ //!                  rpad( length [, symbol] )
        if(arg("symbol").isValid())
            return _rpad(val, arg("length",ZML_DEFAULT_PARAM_NAME).toUInt(), arg("symbol").toChar());
        else
            return _rpad(val, arg("length",ZML_DEFAULT_PARAM_NAME).toUInt());

    }else if(method() == ZFMT_METHOD_STR_RSHIFT){ //!                rshift( places )
        return _rshift(val, arg("places",ZML_DEFAULT_PARAM_NAME).toUInt());

    }else if(method() == ZFMT_METHOD_STR_RTRIM){ //!                 rtrim( [pattern] )
        if(arg("pattern").isValid())
            return _rtrim(val, arg("pattern",ZML_DEFAULT_PARAM_NAME).toString());
        else
            return _rtrim(val);

    }else if(method() == ZFMT_METHOD_STR_SCASE){ //!                 capitalize
        return _sentenceCase(val);

    }else if(method() == ZFMT_METHOD_STR_SQUEEZE){ //!               squeeze( [symbol] )
        if(arg("symbol").isValid())
            return _squeeze(val, arg("symbol",ZML_DEFAULT_PARAM_NAME).toChar());
        else
            return _squeeze(val);

    }else if(method() == ZFMT_METHOD_STR_TCASE){ //!                 titleize
        return _titleCase(val);

    }else if(method() == ZFMT_METHOD_STR_TRIM){ //!                  trim( [pattern] )
        if(arg("pattern").isValid())
            return _trim(val, arg("pattern",ZML_DEFAULT_PARAM_NAME).toString());
        else
            return _trim(val);

    }else if(method() == ZFMT_METHOD_STR_UPCASE){ //!                upcase
        return _upcase(val);
    }

    return val;
}