示例#1
0
static void create_controls( ConvolveInst *inst )
{
   const LWDisplayMetrics *dm;
   int x, y, dx, dy, w, i, pw, ph;


   /* create a control */

   ctl[ 0 ] = FLOAT_CTL( panf, panel, "" );

   /* find out how much vertical space the panel wants for drawing its
      own decorations */

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

   /* create the rest of the controls */

   for ( i = 1; i < 9; i++ )
      ctl[ i ] = FLOAT_CTL( panf, panel, "" );

   ctl[ 9 ] = WPOPUP_CTL( panf, panel, "Presets", preset, 150 );

   /* position all of the controls */

   x  = CON_X( ctl[ 0 ] );
   y  = CON_Y( ctl[ 0 ] );
   dx = CON_HOTW( ctl[ 0 ] ) + 8;
   dy = CON_HOTH( ctl[ 0 ] ) + 4;

   for ( i = 1; i < 9; i++ )
      MOVE_CON( ctl[ i ], x + dx * ( i % 3 ), y + dy * ( i / 3 ));

   w = CON_W( ctl[ 9 ] );
   MOVE_CON( ctl[ 9 ], x + 3 * dx - w, y + 10 * dy / 3 );

   /* now that we know how much room the controls will take up, set the
      height of the panel and center it */

   ph += CON_Y( ctl[ 9 ] );
   ph += CON_HOTH( ctl[ 9 ] );
   PAN_SETH( panf, panel, ph - 6 );

   pw = PAN_GETW( panf, panel );
   dm = panf->drawFuncs->dispMetrics();
   MOVE_PAN( panf, panel, ( dm->width - pw ) / 2, ( dm->height - ph ) / 2 );

   /* initialize the controls */

   set_kernctl( inst );
   SET_INT( ctl[ 9 ], pindex );

   /* set the control event callbacks */

   CON_SETEVENT( ctl[ 9 ], handle_preset, inst );
}
示例#2
0
static void handle_preset( LWControl *ectl, ConvolveInst *inst )
{
   int i;

   GET_INT( ectl, pindex );

   for ( i = 0; i < 9; i++ )
      inst->kern[ i / 3 ][ i % 3 ] = pkern[ pindex ][ i / 3 ][ i % 3 ];

   set_kernctl( inst );
}