Beispiel #1
0
/*
 * CreateSpyTool - create the spy toolbar
 */
void CreateSpyTool( HWND parent )
{
    TOOLDISPLAYINFO     dinfo;
    RECT                r;
    int                 i;

    GetClientRect( parent, &r );
    r.bottom = r.top + GET_TOOLBAR_HEIGHT( BITMAP_Y );

    memset( &dinfo, 0, sizeof( dinfo ) );
    dinfo.button_size.x = BITMAP_X;
    dinfo.button_size.y = BITMAP_Y;
    dinfo.border_size.x = BORDER_X( BITMAP_X );
    dinfo.border_size.y = BORDER_Y( BITMAP_Y );
    dinfo.style = TOOLBAR_FIXED_STYLE;
    dinfo.is_fixed = TRUE;
    dinfo.area = r;
    dinfo.hook = MyToolBarProc;
    dinfo.helphook = spyToolBarHint;
    dinfo.background = NULL;
    dinfo.use_tips = TRUE;
    toolBar = ToolBarInit( parent );

    ToolBarDisplay( toolBar, &dinfo );

    for( i = 0; i < sizeof( toolList ) / sizeof( button ); i++ ) {
        addToolButton( &toolList[i] );
    }

    ShowWindow( ToolBarWindow( toolBar ), SW_SHOWNORMAL );
    UpdateWindow( ToolBarWindow( toolBar ) );

} /* CreateSpyTool */
static void inline
fxHorizontalFoldsModelStepObject(CompWindow * w,
				 Model * model,
				 Object * object,
				 float forwardProgress,
				 float sinForProg, float foldMaxAmp, int rowNo)
{
	ANIM_WINDOW(w);

	float origx = w->attrib.x + (WIN_W(w) * object->gridPosition.x -
				     w->output.left) * model->scale.x;
	float origy = w->attrib.y + (WIN_H(w) * object->gridPosition.y -
				     w->output.top) * model->scale.y;

	object->position.x = origx;

	if (aw->com.curWindowEvent == WindowEventShade ||
	    aw->com.curWindowEvent == WindowEventUnshade) {
		// Execute shade mode

		float relDistToFoldCenter = (rowNo % 2 == 1 ? 0.5 : 0);

		if (object->gridPosition.y == 0) {
			object->position.y = WIN_Y(w);
			object->position.z = 0;
		} else if (object->gridPosition.y == 1) {
			object->position.y =
			    (1 - forwardProgress) * origy +
			    forwardProgress *
			    (WIN_Y(w) + model->topHeight + model->bottomHeight);
			object->position.z = 0;
		} else {
			object->position.y =
			    (1 - forwardProgress) * origy +
			    forwardProgress * (WIN_Y(w) + model->topHeight);
			object->position.z =
			    getObjectZ(model, forwardProgress, sinForProg,
				       relDistToFoldCenter, foldMaxAmp);
		}
	} else {
		// Execute normal mode

		float relDistToFoldCenter;

		relDistToFoldCenter = (rowNo % 2 == 0 ? 0.5 : 0);

		object->position.y =
		    (1 - forwardProgress) * origy +
		    forwardProgress * (BORDER_Y(w) + BORDER_H(w) / 2.0);
		object->position.z =
		    getObjectZ(model, forwardProgress, sinForProg,
			       relDistToFoldCenter, foldMaxAmp);
	}
}
Beispiel #3
0
static void newToolBarWindow( void )
{
    RECT                rect;
    POINT               tl;
    int                 height, width;
    TOOLDISPLAYINFO     dinfo;

    userClose = false;

    GetWindowRect( edit_container_id, &rect );
    width = rect.right - rect.left;
    height = rect.bottom - rect.top;

    tl.x = rect.left;
    tl.y = 0;
    ScreenToClient( root_window_id, &tl );

    if( fixedToolBar ) {
        // make it float
        tl.y = 0;
        height += (fixedRect.bottom - fixedRect.top) + 1;
        dinfo.area = ToolBarFloatRect;
        dinfo.style = TOOLBAR_FLOAT_STYLE;
        dinfo.is_fixed = false;
    } else {
//      tl.y = fixedRect.bottom + 1;
//      height -= (fixedRect.bottom - fixedRect.top) + 1;
        tl.y = fixedRect.bottom;
        height -= (fixedRect.bottom - fixedRect.top);
        dinfo.area = fixedRect;
        dinfo.style = TOOLBAR_FIXED_STYLE;
        dinfo.is_fixed = true;
    }
    dinfo.button_size.x = ToolBarButtonWidth;
    dinfo.button_size.y = ToolBarButtonHeight;
    dinfo.border_size.x = BORDER_X( ToolBarButtonWidth );
    dinfo.border_size.y = BORDER_Y( ToolBarButtonHeight );
    dinfo.background = buttonPattern;
    dinfo.hook = myToolBarProc;
    dinfo.helphook = toolBarHelp;

    ToolBarDisplay( toolBar, &dinfo );

    MoveWindow( edit_container_id, tl.x, tl.y, width, height, TRUE );
    ShowWindow( ToolBarWindow( toolBar ), SW_SHOWNORMAL );
    UpdateWindow( ToolBarWindow( toolBar ) );
    fixedToolBar = !fixedToolBar;

    userClose = true;

} /* newToolBarWindow */
Beispiel #4
0
/*
 * createToolBar - create the tool bar
 */
static void createToolBar( RECT *rect )
{
    int                 toolbar_height;
    TOOLDISPLAYINFO     dinfo;

    fixedToolBar = true;
    dinfo.button_size.x = EditVars.ToolBarButtonWidth;
    dinfo.button_size.y = EditVars.ToolBarButtonHeight;
    dinfo.border_size.x = BORDER_X( EditVars.ToolBarButtonWidth );
    dinfo.border_size.y = BORDER_Y( EditVars.ToolBarButtonHeight );
    dinfo.style = TOOLBAR_FIXED_STYLE;
    dinfo.is_fixed = true;
    toolbar_height = TOOLBAR_HEIGHT( EditVars.ToolBarButtonHeight );
    dinfo.area = *rect;
    dinfo.area.bottom = ((dinfo.area.top + toolbar_height + 1) & ~1) - 1;
    dinfo.area.top -= 1;
    dinfo.area.bottom -= 1;
    dinfo.area.left -= 1;
    dinfo.area.right += 1;
    dinfo.hook = myToolBarProc;
    dinfo.helphook = toolBarHelp;
    dinfo.background = LoadBitmap( InstanceHandle, "BUTTONPATTERN" );
    dinfo.use_tips = 1;
    buttonPattern = dinfo.background;
    toolBar = ToolBarInit( root_window_id );
#if defined( __NT__ )
    ToolBarChangeSysColors( GetSysColor( COLOR_BTNFACE ),
#else
    ToolBarChangeSysColors( GetRGB( EditVars.ToolBarColor ),
#endif
                            GetSysColor( COLOR_BTNHIGHLIGHT ),
                            GetSysColor( COLOR_BTNSHADOW ) );
    ToolBarDisplay( toolBar, &dinfo );
    if( toolBar != NULL ) {
        // CopyRect( &fixedRect, &dinfo.area );
        // WARNING: These are some pretty stupid arbitrary constants here
        rect->top = dinfo.area.bottom;
        ShowWindow( ToolBarWindow( toolBar ), SW_SHOWNORMAL );
        // UpdateWindow( ToolBarWindow( toolBar ) );
    }

} /* createToolBar */
// Divide the window in 8 polygons (6 quadrilaters and 2 triangles (all of them draw as quadrilaters))
// Based on tessellateIntoRectangles and tessellateIntoHexagons. Improperly called tessellation.
static Bool
tessellateIntoAirplane (CompWindow * w)
{
    ANIMADDON_WINDOW (w);

    PolygonSet *pset = aw->eng.polygonSet;

    if (!pset)
	return FALSE;

    float winLimitsX;		// boundaries of polygon tessellation
    float winLimitsY;
    float winLimitsW;
    float winLimitsH;

    winLimitsX = BORDER_X (w);
    winLimitsY = BORDER_Y (w);
    winLimitsW = BORDER_W (w);
    winLimitsH = BORDER_H (w);

    int numpol = 8;
    if (pset->nPolygons != numpol)
    {
	if (pset->nPolygons > 0)
	    freePolygonObjects (pset);

	pset->nPolygons = numpol;

	pset->polygons = calloc (pset->nPolygons, sizeof (PolygonObject));
	if (!pset->polygons)
	{
	    compLogMessage ("animationaddon", CompLogLevelError,
			    "Not enough memory");
	    pset->nPolygons = 0;
	    return FALSE;
	}
    }

    float thickness = 0;
    thickness /= w->screen->width;
    pset->thickness = thickness;
    pset->nTotalFrontVertices = 0;

    float W = (float)winLimitsW;
    float H2 = (float)winLimitsH / 2;
    float H3 = (float)winLimitsH / 3;
    float H6 = (float)winLimitsH / 6;
    float halfThick = pset->thickness / 2;

    /**
     *
     * These correspond to the polygons:
     * based on GLUT sample origami.c code by Mark J. Kilgard
     *                  
     *       |-               W              -| 
     *       |-    H2     -|
     *
     * - --  +----+--------+------------------+
     * |     |    |       /                   |
     *       |    | 6   /                     | 
     *       | 7  |   /              5        |
     *   H2  |    | +                         |
     *       |    +--------+------------------+
     *       |  /                 4           |
     * H __  |/____________.__________________|
     *       |\          center               |
     *       |  \                 3           |
     *       |    +--------+------------------+
     *       |    | +                         |
     *       | 0  |   \                       |
     *       |    |  1  \            2        |  
     * |     |    |       \                   |
     * -     +----+--------+------------------+
     *
     *
     */

    PolygonObject *p = pset->polygons;
    int i;

    for (i = 0; i < 8; i++, p++)
    {
	float topRightY, topLeftY, bottomLeftY, bottomRightY;
	float topLeftX, topRightX, bottomLeftX, bottomRightX;

	p->centerPos.x = p->centerPosStart.x = winLimitsX + H2;
	p->centerPos.y = p->centerPosStart.y = winLimitsY + H2;
	p->centerPos.z = p->centerPosStart.z = -halfThick;
	p->rotAngle = p->rotAngleStart = 0;

	p->nSides = 4;
	p->nVertices = 2 * 4;
	pset->nTotalFrontVertices += 4;

	switch (i)
	{
	case 0:
	    topLeftX = -H2;
	    topLeftY = 0;
	    bottomLeftX = -H2;
	    bottomLeftY = H2;
	    bottomRightX = -H3;
	    bottomRightY = H2;
	    topRightX = -H3;
	    topRightY = H6;
	    break;
	case 1:
	    topLeftX = -H3;
	    topLeftY = H6;
	    bottomLeftX = -H3;
	    bottomLeftY = H2;
	    bottomRightX = 0;
	    bottomRightY = H2;
	    topRightX = 0;
	    topRightY = H2;
	    break;
	case 2:
	    topLeftX = -H3;
	    topLeftY = H6;
	    bottomLeftX = 0;
	    bottomLeftY = H2;
	    bottomRightX = W - H2;
	    bottomRightY = H2;
	    topRightX = W - H2;
	    topRightY = H6;
	    break;
	case 3:
	    topLeftX = -H2;
	    topLeftY = 0;
	    bottomLeftX = -H3;
	    bottomLeftY = H6;
	    bottomRightX = W - H2;
	    bottomRightY = H6;
	    topRightX = W - H2;
	    topRightY = 0;
	    break;
	case 4:
	    topLeftX = -H3;
	    topLeftY = -H6;
	    bottomLeftX = -H2;
	    bottomLeftY = 0;
	    bottomRightX = W - H2;
	    bottomRightY = 0;
	    topRightX = W - H2;
	    topRightY = -H6;
	    break;
	case 5:
	    topLeftX = 0;
	    topLeftY = -H2;
	    bottomLeftX = -H3;
	    bottomLeftY = -H6;
	    bottomRightX = W - H2;
	    bottomRightY = -H6;
	    topRightX = W - H2;
	    topRightY = -H2;
	    break;
	case 6:
	    topLeftX = -H3;
	    topLeftY = -H2;
	    bottomLeftX = -H3;
	    bottomLeftY = -H6;
	    bottomRightX = -H3;
	    bottomRightY = -H6;
	    topRightX = 0;
	    topRightY = -H2;
	    break;
	default:
	    topLeftX = -H2;
	    topLeftY = -H2;
	    bottomLeftX = -H2;
	    bottomLeftY = 0;
	    bottomRightX = -H3;
	    bottomRightY = -H6;
	    topRightX = -H3;
	    topRightY = -H2;
	    break;
	}

	// 4 front, 4 back vertices
	if (!p->vertices)
	{
	    p->vertices = calloc (8 * 3, sizeof (GLfloat));
	}
	if (!p->vertices)
	{
	    compLogMessage ("animation", CompLogLevelError,
			    "Not enough memory");
	    freePolygonObjects (pset);
	    return FALSE;
	}

	GLfloat *pv = p->vertices;

	// Determine 4 front vertices in ccw direction
	pv[0] = topLeftX;
	pv[1] = topLeftY;
	pv[2] = halfThick;

	pv[3] = bottomLeftX;
	pv[4] = bottomLeftY;
	pv[5] = halfThick;

	pv[6] = bottomRightX;
	pv[7] = bottomRightY;
	pv[8] = halfThick;

	pv[9] = topRightX;
	pv[10] = topRightY;
	pv[11] = halfThick;

	// Determine 4 back vertices in cw direction
	pv[12] = topRightX;
	pv[13] = topRightY;
	pv[14] = -halfThick;

	pv[15] = bottomRightX;
	pv[16] = bottomRightY;
	pv[17] = -halfThick;

	pv[18] = bottomLeftX;
	pv[19] = bottomLeftY;
	pv[20] = -halfThick;

	pv[21] = topLeftX;
	pv[22] = topLeftY;
	pv[23] = -halfThick;

	// 16 indices for 4 sides (for quad strip)
	if (!p->sideIndices)
	{
	    p->sideIndices = calloc (4 * 4, sizeof (GLushort));
	}
	if (!p->sideIndices)
	{
	    compLogMessage ("animation", CompLogLevelError,
			    "Not enough memory");
	    freePolygonObjects (pset);
	    return FALSE;
	}

	GLushort *ind = p->sideIndices;
	int id = 0;

	ind[id++] = 0;
	ind[id++] = 7;
	ind[id++] = 6;
	ind[id++] = 1;

	ind[id++] = 1;
	ind[id++] = 6;
	ind[id++] = 5;
	ind[id++] = 2;

	ind[id++] = 2;
	ind[id++] = 5;
	ind[id++] = 4;
	ind[id++] = 3;

	ind[id++] = 3;
	ind[id++] = 4;
	ind[id++] = 7;
	ind[id++] = 0;

	if (i < 4)
	{
	    p->boundingBox.x1 = p->centerPos.x + topLeftX;
	    p->boundingBox.y1 = p->centerPos.y + topLeftY;
	    p->boundingBox.x2 = ceil (p->centerPos.x + bottomRightX);
	    p->boundingBox.y2 = ceil (p->centerPos.y + bottomRightY);
	}
	else
	{
	    p->boundingBox.x1 = p->centerPos.x + bottomLeftX;
	    p->boundingBox.y1 = p->centerPos.y + topLeftY;
	    p->boundingBox.x2 = ceil (p->centerPos.x + bottomRightX);
	    p->boundingBox.y2 = ceil (p->centerPos.y + bottomLeftY);
	}
    }
    return TRUE;
}
Beispiel #6
0
static void
fxCurvedFoldModelStepObject(CompWindow *w,
                            Model *model,
                            Object *object,
                            float forwardProgress, float curveMaxAmp)
{
    ANIM_WINDOW(w);

    float origx = w->attrib.x + (WIN_W(w) * object->gridPosition.x -
                                 w->output.left) * model->scale.x;
    float origy = w->attrib.y + (WIN_H(w) * object->gridPosition.y -
                                 w->output.top) * model->scale.y;

    if (aw->curWindowEvent == WindowEventShade ||
            aw->curWindowEvent == WindowEventUnshade)
    {
        // Execute shade mode

        // find position in window contents
        // (window contents correspond to 0.0-1.0 range)
        float relPosInWinContents =
            (object->gridPosition.y * WIN_H(w) -
             model->topHeight) / w->height;
        float relDistToCenter = fabs(relPosInWinContents - 0.5);

        if (object->gridPosition.y == 0)
        {
            object->position.x = origx;
            object->position.y = WIN_Y(w);
        }
        else if (object->gridPosition.y == 1)
        {
            object->position.x = origx;
            object->position.y =
                (1 - forwardProgress) * origy +
                forwardProgress *
                (WIN_Y(w) + model->topHeight + model->bottomHeight);
        }
        else
        {
            object->position.x =
                origx + sin(forwardProgress * M_PI / 2) *
                (0.5 - object->gridPosition.x) * 2 * model->scale.x *
                curveMaxAmp *
                (1 - pow (pow(2 * relDistToCenter, 1.3), 2));
            object->position.y =
                (1 - forwardProgress) * origy +
                forwardProgress * (WIN_Y(w) + model->topHeight);
        }
    }
    else
    {
        // Execute normal mode

        // find position within window borders
        // (border contents correspond to 0.0-1.0 range)
        float relPosInWinBorders =
            (object->gridPosition.y * WIN_H(w) -
             (w->output.top - w->input.top)) / BORDER_H(w);
        float relDistToCenter = fabs(relPosInWinBorders - 0.5);

        // prevent top & bottom shadows from extending too much
        if (relDistToCenter > 0.5)
            relDistToCenter = 0.5;

        object->position.x =
            origx + sin(forwardProgress * M_PI / 2) *
            (0.5 - object->gridPosition.x) * 2 * model->scale.x *
            curveMaxAmp *
            (1 - pow (pow(2 * relDistToCenter, 1.3), 2));
        object->position.y =
            (1 - forwardProgress) * origy +
            forwardProgress * (BORDER_Y(w) + BORDER_H(w) / 2.0);
    }
}