Example #1
0
static void devent( LWControl *ctl, void *data )
{
   LWPanelFuncs *panf;
   const LWDisplayMetrics *dmet;
   LWPanelID panel;
   LWValue
      ival = { LWT_INTEGER },
      ivecval = { LWT_VINT };
   int x, y, md[ 3 ];
   char a[ 32 ];


   /* panel, panf, dmet */

   panel = ( LWPanelID ) CON_PAN( ctl );
   panf = ( LWPanelFuncs * ) CON_PANFUN( ctl );
   dmet = panf->drawFuncs->dispMetrics();

   /* control dimensions */

   x = CON_HOTX( ctl );
   y = CON_HOTY( ctl );

   /* mouse drag coordinates */

   GETV_IVEC( ctl, md );
   sprintf( a, "%d %d %d", md[ 0 ], md[ 1 ], md[ 2 ] );
   panf->drawFuncs->drawBox( panel, COLOR_LT_YELLOW, x - 90, y, 80,
      dmet->textHeight );
   panf->drawFuncs->drawText( panel, a, COLOR_BLACK, x - 88, y );
}
Example #2
0
int get_user( UnwrapParams *uwp )
{
   static char *text[] = {
      "Draws polygons in the 2D coordinate system of the selected texture layer.",
      NULL
   };
   static char *fgopt[] = {
      "Use Color",
      "Invert Background",
      "Brighten",
      "Darken",
      NULL
   };
   static char *bgopt[] = {
      "Use Color",
      "Copy Image Map",
      NULL
   };

   LWPanControlDesc desc;
   LWValue
      ival    = { LWT_INTEGER },
      sval    = { LWT_STRING },
      ivecval = { LWT_VINT };
   LWPanelID panel;
   LWControl *ctl[ 10 ], *bdr[ 2 ];
   Node *root;
   int i, x, y, w, ph, ok;


   root = make_list( panf->globalFun );
   if ( !root ) return 0;

   if( !( panel = PAN_CREATE( panf, "Unwrap" ))) {
      free_tree( root, 1 );
      return 0;
   }

   if ( !uwp->filename[ 0 ] ) {
      strcpy( uwp->filename, "unwrapped" );
      filename_ext( uwp->saver, uwp->filename );
      uwp->bgcolor[ 0 ] = uwp->bgcolor[ 1 ] = uwp->bgcolor[ 2 ] = 255;
   }

   TEXT_CTL( panf, panel, "", text );

   ctl[ 0 ] = TREE_CTL( panf, panel, "Texture Layer", 200, 200, tree_info,
      tree_count, tree_child );

   ph = PAN_GETH( panf, panel );
   ph -= CON_X( ctl[ 0 ] );
   ph -= CON_H( ctl[ 0 ] );

   ctl[ 1 ] = SAVE_CTL( panf, panel, "Save As", 40 );
   ctl[ 2 ] = CUSTPOPUP_CTL( panf, panel, "", 150, sname, scount );
   ctl[ 3 ] = INT_CTL( panf, panel, "Width" );
   ctl[ 4 ] = INT_CTL( panf, panel, "Height" );
   ctl[ 5 ] = BUTTON_CTL( panf, panel, "From Image Map" );
   ctl[ 6 ] = WPOPUP_CTL( panf, panel, "Edges", fgopt, 150 );
   ctl[ 7 ] = MINIRGB_CTL( panf, panel, "" );
   ctl[ 8 ] = WPOPUP_CTL( panf, panel, "Background", bgopt, 150 );
   ctl[ 9 ] = MINIRGB_CTL( panf, panel, "" );

   w = CON_W( ctl[ 1 ] );
   w -= CON_LW( ctl[ 1 ] );

   bdr[ 0 ] = BORDER_CTL( panf, panel, "", w, 2 );
   bdr[ 1 ] = BORDER_CTL( panf, panel, "", w, 2 );

   x = CON_X( ctl[ 0 ] );
   x += CON_W( ctl[ 0 ] );
   x += CON_LW( ctl[ 8 ] ) + 8;
   y = CON_Y( ctl[ 0 ] );

   w = CON_LW( ctl[ 1 ] );
   MOVE_CON( ctl[ 1 ], x - w, y );

   w = CON_LW( ctl[ 2 ] );
   y += CON_HOTH( ctl[ 1 ] ) + 4;
   MOVE_CON( ctl[ 2 ], x - w, y );

   y += CON_HOTH( ctl[ 2 ] ) + 6;
   MOVE_CON( bdr[ 0 ], x, y );

   w = CON_LW( ctl[ 3 ] );
   y += 6;
   MOVE_CON( ctl[ 3 ], x - w, y );

   w = CON_X( ctl[ 3 ] );
   w += CON_W( ctl[ 3 ] );
   MOVE_CON( ctl[ 5 ], w + 16, y );

   w = CON_LW( ctl[ 4 ] );
   y += CON_HOTH( ctl[ 3 ] ) + 4;
   MOVE_CON( ctl[ 4 ], x - w, y );

   y += CON_HOTH( ctl[ 2 ] ) + 6;
   MOVE_CON( bdr[ 1 ], x, y );

   y += 6;
   for ( i = 6; i <= 9; i++ ) {
      w = CON_LW( ctl[ i ] );
      MOVE_CON( ctl[ i ], x - w, y );
      y += CON_HOTH( ctl[ i ] ) + 4;
   }

   y = CON_Y( ctl[ 9 ] );
   y += CON_H( ctl[ 9 ] );
   PAN_SETH( panf, panel, y + ph );

   SET_STR( ctl[ 1 ], uwp->filename, sizeof( uwp->filename ));
   SET_INT( ctl[ 2 ], uwp->saver );
   SET_INT( ctl[ 3 ], uwp->width );
   SET_INT( ctl[ 4 ], uwp->height );
   SET_INT( ctl[ 6 ], uwp->fgoptions );
   SET_INT( ctl[ 8 ], uwp->bgoptions );
   SETV_IVEC( ctl[ 7 ], uwp->fgcolor );
   SETV_IVEC( ctl[ 9 ], uwp->bgcolor );

   CON_SETEVENT( ctl[ 0 ], tree_event, root );
   CON_SETEVENT( ctl[ 2 ], saver_event, ctl[ 1 ] );
   CON_SETEVENT( ctl[ 5 ], sizebtn_event, ctl );

   ok = panf->open( panel, PANF_BLOCKING | PANF_CANCEL );

   if ( ok ) {
      GET_STR( ctl[ 1 ], uwp->filename, sizeof( uwp->filename ));
      GET_INT( ctl[ 2 ], uwp->saver );
      GET_INT( ctl[ 3 ], uwp->width );
      GET_INT( ctl[ 4 ], uwp->height );
      GET_INT( ctl[ 6 ], uwp->fgoptions );
      GET_INT( ctl[ 8 ], uwp->bgoptions );
      GETV_IVEC( ctl[ 7 ], uwp->fgcolor );
      GETV_IVEC( ctl[ 9 ], uwp->bgcolor );

      ctl[ 0 ]->get( ctl[ 0 ], CTL_VALUE, &ival );
      if ( !getsel_tree( uwp, ( Node * ) ival.ptr.ptr )) {
         msgf->error( "No texture layer selected", NULL );
         ok = 0;
      }
   }

   PAN_KILL( panf, panel );

   free_tree( root, 1 );
   return ok;
}
Example #3
0
XCALL_(int)BlotchInterface (
	long			 version,
	GlobalFunc		*global,
	Blotch			*inst,
	void			*serverData)
{
	LWPanelFuncs	*panl;
	LWPanelID		panID;
	LWControl		*col,*cen,*sof,*rad;
	MessageFuncs	*message;
	int	x=200,y=0,w=400,h=300;

	XCALL_INIT;
	if (version != 1)
		return AFUNC_BADVERSION;
	message = (*global) ("Info Messages", GFUSE_TRANSIENT);
	if (!message )
		return AFUNC_BADGLOBAL;
	
panl = (*global) (PANEL_SERVICES_NAME, GFUSE_TRANSIENT);
	if(!panl)
	{
		(*message->error)("Unable to activate global "PANEL_SERVICES_NAME, "     please add plugin lwpanels.p" );
		return AFUNC_BADGLOBAL;
	}

	if( panID=PAN_CREATE(panl,"Blotch") )
	{
		LWValue	val = {LWT_INTEGER}; 
		int lw;
#ifdef RGB
		int rgb[3];
		if(!(col = MINIRGB_CTL(panl,panID,"Color"))) 
			goto controlError;
#else
		if(!(col = MINIHSV_CTL(panl,panID,"Color"))) 
			goto controlError;
#endif
		if(!(cen = FVEC_CTL(panl,panID,"Center"))) 
			goto controlError;
		if(!(rad = FLOAT_CTL(panl,panID,"Radius"))) 
			goto controlError;
		if(!(sof = FLOAT_CTL(panl,panID,"Softness"))) 
			goto controlError;
		lw = maxLabel(panl,panID);
		ctlVAlign(lw,col);
		ctlVAlign(lw,cen);
		ctlVAlign(lw,rad);
		ctlOneLine(rad,sof,NULL,NULL,NULL,NULL);
#ifdef RGB
		rgb[0] = (int)(255.0*inst->color[0]);
		rgb[1] = (int)(255.0*inst->color[1]);
		rgb[2] = (int)(255.0*inst->color[2]);
		SETV_IVEC(col,rgb);
#else
		SETV_FVEC(col,inst->color);
#endif
		SETV_FVEC(cen,inst->center);
		SET_FLOAT(rad,inst->radius);
		SET_FLOAT(sof,inst->softness);

		if(PAN_POST(panl,panID))
		{
#ifdef RGB
			GETV_IVEC(col,rgb); 
			inst->color[0] = ((double)rgb[0])/255.0;
			inst->color[1] = ((double)rgb[1])/255.0;
			inst->color[2] = ((double)rgb[2])/255.0;
#else
			GETV_FVEC(col,inst->color);
#endif
			GETV_FVEC(cen,inst->center);
			GET_FLOAT(rad,inst->radius);
			GET_FLOAT(sof,inst->softness);
		}
		PAN_KILL(panl,panID);
		return (AFUNC_OK);
controlError:
		PAN_KILL(panl,panID);
		(*message->error)("Duoooh!:","Unable to create panel");
	}
	else 
	{
		(*message->error)("Duoooh!:","Unable to create panel");
	}
	return AFUNC_BADGLOBAL;
}