Esempio n. 1
0
void StickyNoteActor::launchEditDialog(bool selectExistingText)
{
	_selectExistingText = selectExistingText;

	// NOTE: for the future, we may want QuickLook-like behaviour where
	// we follow the sticky notes as the user clicks around on the screen.
	// If so, then we should keep a reference to the existing dialog some
	// where and pass it into this launch process?
	
	// if one does not exist, create a new sticky not dialog
	// and center it
	if (!_editDialog)
		_editDialog = new StickyNoteEditDialog();
	else
	{
		// close the dialog and disconnect all signals
		_editDialog->accept();
		_editDialog->disconnect();
	}
	
	// setup all the connections
	connect(_editDialog, SIGNAL(finished(int)), this, SLOT(finishedEditing()));
	connect(_editDialog, SIGNAL(accepted()), this, SLOT(finishedEditing()));
	connect(_editDialog, SIGNAL(rejected()), this, SLOT(finishedEditing()));

	// move it to the appropriate place
	const int marginLeftRight = 20;
	const int marginTopBottom = -20;
	Bounds b = this->getScreenBoundingBox();
	POINT windowPos = {0, 0};
	ClientToScreen(winOS->GetWindowsHandle(), &windowPos);
	Vec3 screenMin = b.getMin() + Vec3(windowPos.x, windowPos.y, 0);
	Vec3 screenMax = b.getMax() + Vec3(windowPos.x, windowPos.y, 0);
	Vec3 screenDims = Vec3(winOS->GetWindowWidth(), winOS->GetWindowHeight(), 0);
	Vec3 tr(NxMath::max(screenMin.x, screenMax.x), NxMath::min(screenMin.y, screenMax.y), 0);
	Vec3 tl(NxMath::min(screenMin.x, screenMax.x), NxMath::min(screenMin.y, screenMax.y), 0);
	int yBound = NxMath::min(NxMath::max((int) tr.y + marginTopBottom, windowPos.y + abs(marginTopBottom)), windowPos.y + (int) screenDims.y - abs(marginTopBottom) - _editDialog->height());
	if ((tr.x + marginLeftRight + _editDialog->width()) <= (windowPos.x + screenDims.x - marginLeftRight))
	{
		// put this note to the right of this actor
		_editDialog->move(tr.x + marginLeftRight, yBound);
	}
	else if ((tl.x - marginLeftRight - _editDialog->width()) >= marginLeftRight)
	{
		// put this note to the left of this actor
		_editDialog->move((tl.x - marginLeftRight - _editDialog->width()), yBound);
	}

	Mat34 finalPose;
	Vec3 finalDims;
	calculateDialogPoseDims(finalPose, finalDims);
	const int StickyNoteActorNumTempActorSteps = 13;
	const int StickyNoteActorNumStickySteps = 8;
	
	// create a new proxy actor
	assert(!_tmpAnimationActor);
	_tmpAnimationActor = new Actor();
	_tmpAnimationActor->pushActorType(Temporary);
	_tmpAnimationActor->setObjectToMimic(this);
	_tmpAnimationActor->setFrozen(false);
	_tmpAnimationActor->setGravity(false);
	_tmpAnimationActor->setCollisions(false);
	_tmpAnimationActor->setAlphaAnim(0.0f, 1.0f, StickyNoteActorNumTempActorSteps);
	_tmpAnimationActor->setSizeAnim(lerpRange(getDims(), finalDims, StickyNoteActorNumTempActorSteps, SoftEase));
	_tmpAnimationActor->setPoseAnim(slerpPose(getGlobalPose(), finalPose, StickyNoteActorNumTempActorSteps, SoftEase), (FinishedCallBack) EditStickyNoteAfterAnim, NULL);
	setAlphaAnim(getAlpha(), 0.4f, StickyNoteActorNumStickySteps);
}
Esempio n. 2
0
// FIXME: maybe mmap isn't such a good idea for giant files?
int main(int argc, char *argv[])
{
    int i, out, count;
    MPEG2Parser *mpeg2parser;


    // check for our arguments
#ifdef WRITEOUT
    if (argc < 3)
    {
        fprintf(stderr, _("Usage: %s INPUT OUTPUT\n"), argv[0]);
        exit(1);
    }
#else // WRITEOUT
    if (argc < 2)
    {
        fprintf(stderr, _("Usage: %s INPUT\n"), argv[0]);
        exit(1);
    }
#endif // WRITEOUT

    decode_init();

    mpeg2parser = new MPEG2Parser();
    if (!mpeg2parser->init(argv[1], ticker))
    {
        fprintf(stderr, "%s\n", mpeg2parser->getError());
        exit(1);
    }

    mpeg2parser->parse();

    if (mpeg2parser->getError())
        fprintf(stderr, "%s\n", mpeg2parser->getError());

#ifdef WRITEOUT
    // open our output file for writing
    if ((out = open(argv[2], O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE,
                    S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) < 0)
    {
        perror(argv[2]);
        exit(1);
    }
#endif // WRITEOUT


    List *GOPs = mpeg2parser->getGOPs();

    printf(_("GOPs: %d\n"), GOPs->getNum());

#ifdef RENDEROUT
    int GOPmax = GOPs->getNum();
    for (i = 0; i < GOPmax; i++)
    {
        Pack *packet;
        GroupOfPictures *GOP;
        Bounds *bounds;
        ElementStream *ves;
        int start, stop;
        int ves_start, ves_stop;

        uint8_t *loc;
        size_t len;

        ticker(_("Rendering GOPs"), (float) ((float) i / (float) GOPmax));

        GOP = (GroupOfPictures *) GOPs->vector(i);

        bounds = GOP->getPacketBounds();
        start = bounds->getFirst();
        stop = bounds->getMax();

        for (int j = start; j < stop; j++)
        {
            if (!(packet = (Pack *) mpeg2parser->getPackets()->vector(j)))
            {
                printf("%s", _("NULL packet?!\n"));
                exit(1);
            }

            ves_start = packet->getVideoFirst();
            ves_stop = packet->getVideoMax();

#ifdef WRITEOUT
            /* write packets to disk */
            if (loc =
                mpeg2parser->bytesAvail(packet->getStart(), packet->getLen()))
            {
                write(out, loc, packet->getLen());
            }
            else
                printf("%s", _("NULL vector area?!\n"));
#endif // WRITEOUT

            for (int k = ves_start; k < ves_stop; k++)
            {
                if (!
                    (ves =
                     (ElementStream *) mpeg2parser->getVideo()->vector(k)))
                {
                    printf("%s", _("NULL ves?!\n"));
                    exit(1);
                }
#ifdef WATCHOUT
                len = ves->getLen();
                (void *) loc = mpeg2parser->bytesAvail(ves->getStart(), len);
                if (loc && len)
                {
                    printf("%" OFF_T_FORMAT ": %ld\n", ves->getStart(), len);
                    fflush(NULL);
                    mpeg2_decode_data(&mpeg2dec, loc, loc + len);
                }
#endif // WATCHOUT
            }
        }
    }
    ticker("Rendering GOPs", 1.0);
#endif // RENDEROUT

    /*
       printf("%s",_("dumping audio ES...\n"));
       for (i=0;i<audio_list->getNum();i++)
       {
       ElementStream * audio;

       if (!(audio=(ElementStream*)audio_list->vector(i)))
       {
       Error("NULL audio vector?!");
       exit(1);
       }

       write(out,audio->getStart(),audio->getLen());
       }

       // close outfile
       close(out);

     */

    /*
       char user[512];

       printf(_("view GOPs avail: 0-%d\n"),pack_list->getNum()-1);
       printf("%s",_("Dump which GOP? "));
       fflush(NULL);
       while (fgets(user,512,stdin))
       {
       int which;
       int first, last;

       which=atoi(user);

       if (which<pack_list->getNum())
       {
       Pack * pack;
       ElementStream * video;

       if ((pack=(Pack*)pack_list->vector(which)))
       {
       first=pack->getMin();
       last=pack->getMax();

       printf(_("Showing ES %d to %d...\n"),
       first,last);
       for (i=first;i<last;i++)
       {

       if ((video=(ElementStream*)video_list->vector(i)))
       {

       mpeg2_decode_data(&mpeg2dec,
       video->getStart(),
       video->getStart()+
       video->getLen());
       }
       else
       Error("ES not found");
       }
       }
       else
       Error("Pack not found");
       }

       printf("%s",_("Dump which GOP? "));
       fflush(NULL);
       }
     */

#ifdef WRITEOUT
    close(out);
#endif

#if 0
    printf("%s", _("press enter to quit..."));
    fflush(NULL);
    char userin[128];
    fgets(userin, 128, stdin);
#endif

    // shutdown decoder
    mpeg2_close(&mpeg2dec);
    vo_close(output);

    // shutdown parser
    delete mpeg2parser;

    return 0;
}