コード例 #1
0
ファイル: panctl.c プロジェクト: jangellx/TMProLWPlugIns
static LWPanelID get_panel( void )
{
   LWPanControlDesc desc;
   LWPanelID panel;
   LWValue ival = { LWT_INTEGER };
   LWControl *ctl[ 9 ];
   int i;

   if( !( panel = PAN_CREATE( panf, "Panels Control Test" )))
      return NULL;

   ctl[ 0 ] = BUTTON_CTL( panf, panel, "Edit" );
   ctl[ 1 ] = BUTTON_CTL( panf, panel, "Slider" );
   ctl[ 2 ] = BUTTON_CTL( panf, panel, "Choice" );
   ctl[ 3 ] = BUTTON_CTL( panf, panel, "Tree" );
   ctl[ 4 ] = BUTTON_CTL( panf, panel, "Color" );
   ctl[ 5 ] = BUTTON_CTL( panf, panel, "File" );
   ctl[ 6 ] = BUTTON_CTL( panf, panel, "Draw" );

   ctl[ 7 ] = BOOL_CTL( panf, panel, "Boolean" );
   ctl[ 8 ] = BOOLBUTTON_CTL( panf, panel, "Bool Button" );

   CON_SETEVENT( ctl[ 0 ], event, open_editpan );
   CON_SETEVENT( ctl[ 1 ], event, open_sliderpan );
   CON_SETEVENT( ctl[ 2 ], event, open_choicepan );
   CON_SETEVENT( ctl[ 3 ], event, open_treepan );
   CON_SETEVENT( ctl[ 4 ], event, open_colorpan );
   CON_SETEVENT( ctl[ 5 ], event, open_filepan );
   CON_SETEVENT( ctl[ 6 ], event, open_drawpan );

   /* align */

   for ( i = 0; i < 9; i++ ) {
      ival.intv.value = 100 - CON_LW( ctl[ i ] );
      ctl[ i ]->set( ctl[ i ], CTL_X, &ival );
   }

   return panel;
}
コード例 #2
0
ファイル: ui.c プロジェクト: DimondTheCat/xray
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;
}