Exemplo n.º 1
0
// MakeMainControls():
bool FreeKeyInterface::MakeMainControls() {
  try {
    int x, y, w;

    // Title Image (OpenGL)
    if( !( title_image = OPENGL_CTL( panel_funcs->orig_struct, main_panel,
                                     "", decoded_logo_small->GetWidth() - 25, decoded_logo_small->GetHeight() ) ) )
      throw false;

    MOVE_CON( title_image, -13, -4 );

    // File ItemSelection Conrols
    if( !( source_scene = FILE_CTL( panel_funcs->orig_struct, main_panel,
                                    "Source Scene", 91 ) ) )
      throw false;

    if( !( source_popup = POPDOWN_CTL( panel_funcs->orig_struct, main_panel,
                                       "Source Tools", source_popup_text ) ) )
      throw false;

    if( !( output_scene = FILE_CTL( panel_funcs->orig_struct, main_panel,
                                    "Output Scene", 91 ) ) )
      throw false;

    if( !( output_popup = POPDOWN_CTL( panel_funcs->orig_struct, main_panel,
                                       " Output Tools", output_popup_text ) ) )
      throw false;

//    x = CON_X( source_scene );
//    y = CON_Y( source_scene );
//    MOVE_CON( source_scene, x, y + 35 );

    PanelTools::PutUnder( source_scene, source_scene, -11 );
    PanelTools::AlignLabels( source_scene, output_scene, 5 );
    PanelTools::PutOnLineWith( source_scene, source_popup, -10 );
    PanelTools::PutOnLineWith( output_scene, output_popup, -10 );

    // Default Settings for String/File and Popup Controls
    SET_STR( source_scene,  (char *)fk->GetSource(),   strlen( fk->GetSource()   ) );
    SET_STR( output_scene,  (char *)fk->GetOutput(),   strlen( fk->GetOutput()   ) );

    const int list_x_offset = 130;

    // List Controls
    if( !( list_fold = WBUTTON_CTL( panel_funcs->orig_struct, main_panel,
                                    "Fold", 50 ) ) )
      throw false;

    if( !( list_unfold = WBUTTON_CTL( panel_funcs->orig_struct, main_panel,
                                      "Unfold", 50 ) ) )
      throw false;

    if( !( select_count = INTRO_CTL( panel_funcs->orig_struct, main_panel,
                                     "" ) ) )
      throw false;

    // Display Controls
    if( !( display_key_mode = WPOPUP_CTL( panel_funcs->orig_struct, main_panel,
                                          "Key Mode", display_key_mode_text, 130 ) ) )
      throw false;

    if( !( display_item_mode = WPOPUP_CTL( panel_funcs->orig_struct, main_panel,
                                          "Item List", display_mode_text, 130 ) ) )
      throw false;

    SET_INT( display_key_mode,  fk->GetKeyDisplayMode()  );
    SET_INT( display_item_mode, fk->GetItemDisplayMode() );

    PanelTools::PutUnder( output_scene, list_fold );
    PanelTools::PutUnder( list_fold, list_fold );

    x = CON_X( list_fold );
    y = CON_Y( list_fold );
    MOVE_CON( list_fold, x + 10 + list_x_offset, y-6 );
    PanelTools::PutOnLineWith( list_fold, list_unfold, -7 );
    PanelTools::PutOnLineWith( list_unfold, select_count, 15);
    PanelTools::PutOnLineWith( select_count, display_key_mode, 15 );
    PanelTools::PutOnLineWith( display_key_mode, display_item_mode );

    // Time Controls
    if( !( item_first_frame = FLOAT_CTL( panel_funcs->orig_struct, main_panel,
                                         "Low Frame" ) ) )
      throw false;

    if( !( item_current_frame = FLOAT_CTL( panel_funcs->orig_struct, main_panel,
                                           "Current Frame" ) ) )
      throw false;

    if( !( item_jump_to_frame = WBUTTON_CTL( panel_funcs->orig_struct, main_panel, "", 20 ) ) )
      throw false;

    if( !( item_last_frame = FLOAT_CTL( panel_funcs->orig_struct, main_panel,
                                         "High Frame" ) ) )
      throw false;

    if( !( item_range_presets = POPDOWN_CTL( panel_funcs->orig_struct, main_panel,
                                             " Ranges", item_range_preset_text ) ) )
      throw false;

    SET_FLOAT( item_current_frame, fk->GetCurrentTime() * default_fps );
    SET_FLOAT( item_first_frame,   fk->GetDisplayMin()  * default_fps );
    SET_FLOAT( item_last_frame,    fk->GetDisplayMax()  * default_fps );

    PanelTools::PutUnder( list_fold, item_first_frame );
    x = CON_X( item_first_frame );
    y = CON_Y( item_first_frame );
    MOVE_CON( item_first_frame, x + list_x_offset + 40, y );

    PanelTools::PutOnLineWith( item_first_frame, item_current_frame,   20 );
    PanelTools::PutOnLineWith( item_current_frame, item_jump_to_frame, -5 );
    PanelTools::PutOnLineWith( item_jump_to_frame, item_last_frame,    20 );
    PanelTools::PutOnLineWith( item_last_frame, item_range_presets,    -2 );

    // Item List
    if( !( item_list = CANVAS_CTL( panel_funcs->orig_struct, main_panel,
                                   "", 625, 263 ) ) )
      throw false;

    if( !( opengl_item_list = OPENGL_CTL( panel_funcs->orig_struct, main_panel,
                                          "", 625, 263 ) ) )
      throw false;

    if( !( item_scroll = VSLIDER_CTL( panel_funcs->orig_struct, main_panel,
                                      "", 259, 0, 0 ) ) )
      throw false;

    PanelTools::PutUnder( item_first_frame, item_list );

    x = CON_X( item_list );
    y = CON_Y( item_list );
    MOVE_CON( item_list,        x + list_x_offset, y );
    MOVE_CON( opengl_item_list, x + list_x_offset, y );

    w = CON_W( item_list );
    MOVE_CON( item_scroll, x+w-18 + list_x_offset, y );

    UpdateItemListType( fk->GetUseOpenGLItemList() );

    // MultiSlider/Zoom
    if( !( item_zoom = PERCENT_CTL( panel_funcs->orig_struct, main_panel, "Zoom" ) ) )
      throw false;

    SET_FLOAT( item_zoom, fk->GetZoom() * 100.0 );

    if( !( item_multiscroll = DRAGAREA_CTL( panel_funcs->orig_struct, main_panel,
                                            "", 620 + list_x_offset - CON_W( item_zoom ) - 1, 16 ) ) )
      throw false;

    PanelTools::PutUnder( item_list, item_zoom );
    x = CON_X( item_zoom );
    y = CON_Y( item_zoom );
    MOVE_CON( item_zoom, x+8, y );

    PanelTools::PutOnLineWith( item_zoom, item_multiscroll );
    x = CON_X( item_multiscroll );
    y = CON_Y( item_multiscroll );
    MOVE_CON( item_multiscroll, x, y+1 );

    // Tabs
    if( !( tool_options_tabs = TABCHOICE_CTL( panel_funcs->orig_struct, main_panel,
                                             "", tool_option_tab_text ) ) )
      throw false;

    PanelTools::PutUnder( item_multiscroll, tool_options_tabs );
    PanelTools::PutUnder( tool_options_tabs, tool_options_tabs );

    // Group List
    if( !( group_list = CUSTPOPUP_CTL( panel_funcs->orig_struct, main_panel,
                                       "Group", 200,
                                       GroupNames, GroupCount ) ) )
      throw false;

    PanelTools::PutOnLineWith( tool_options_tabs, group_list, 12 );
    x = CON_X( group_list );
    y = CON_Y( group_list );
    MOVE_CON( group_list, x, y-5 );

    // About FreeKey button
    if( !( about = WBUTTON_CTL( panel_funcs->orig_struct, main_panel,
                            "About", 63 ) ) )
      throw false;

    // F1 (Keyboard Help) Button
    if( !( f1 = WBUTTON_CTL( panel_funcs->orig_struct, main_panel,
                             "F1", 30 ) ) )
      throw false;

    PanelTools::PutOnLineWith( group_list, about );
    PanelTools::PutOnLineWith( about, f1 );

    // Range Controls
    if( !( range_low = MINISLIDER_CTL( panel_funcs->orig_struct, main_panel,
                                       "Range   Low", 30, 0, 1000000 ) ) )
      throw false;

    if( !( range_high = MINISLIDER_CTL( panel_funcs->orig_struct, main_panel,
                                        "High", 30, 0, 1000000 ) ) )
      throw false;
    SET_INT( range_high, 1000000 );

    PanelTools::PutUnder( tool_options_tabs, range_low );
    PanelTools::PutUnder( range_low, range_low );
    PanelTools::PutUnder( range_low, range_low );
    PanelTools::PutUnder( range_low, range_low );
    PanelTools::PutUnder( range_low, range_low );
    PanelTools::PutOnLineWith( range_low, range_high );

    // Remove Mode
    if( !( remove_mode = WPOPUP_CTL( panel_funcs->orig_struct, main_panel,
                                     "Remove Mode", remove_mode_text, 250 ) ) )
      throw false;
    PanelTools::PutOnLineWith( range_high, remove_mode, 20 );
    y = CON_Y( remove_mode );
    MOVE_CON( remove_mode, 325, y );

    // Step
    if( !( step_amount = MINISLIDER_CTL( panel_funcs->orig_struct, main_panel,
                                         "Step Amount", 30, 0, 32767 ) ) )
      throw false;

    if( !( step_mode = WPOPUP_CTL( panel_funcs->orig_struct, main_panel,
                                   "Step Mode", step_mode_text, 250 ) ) )
      throw false;

    PanelTools::PutUnder( range_low, step_amount );
    PanelTools::PutOnLineWith( step_amount, step_mode );

    // Delta
    if( !( delta_amount = MINISLIDER_CTL( panel_funcs->orig_struct, main_panel,
                                          "Delta Amount", 30, -32768, 32767 ) ) )
      throw false;

    if( !( delta_mode = BOOL_CTL( panel_funcs->orig_struct, main_panel,
                                  "Enable Time Delta" ) ) )
      throw false;

    PanelTools::PutUnder( step_amount, delta_amount );
    PanelTools::PutOnLineWith( delta_amount, delta_mode );

    // Direction
    if( !( direction_mode = WPOPUP_CTL( panel_funcs->orig_struct, main_panel,
                                   "Direction", direction_mode_text, 250 ) ) )
      throw false;

    PanelTools::PutOnLineWith( delta_amount, direction_mode );

    // Scale
    if( !( scale_amount = FLOAT_CTL( panel_funcs->orig_struct, main_panel,
                                          "Scale Factor" ) ) )
      throw false;

    if( !( scale_mode = BOOL_CTL( panel_funcs->orig_struct, main_panel,
                                  "Enable Scale Keys" ) ) )
      throw false;

    PanelTools::PutUnder( delta_amount, scale_amount );
    PanelTools::PutOnLineWith( scale_amount, scale_mode );

    // Fix Some Alignments
    LWControl *align1[] = { range_low, step_amount, delta_amount, scale_amount, NULL };
    PanelTools::AlignLabels( align1 );
    PanelTools::PutOnLineWith( range_low, range_high );

    LWControl *align2[] = { remove_mode, step_mode, direction_mode, NULL };
    PanelTools::AlignLabels( align2 );

    PanelTools::PutOnLineWith( delta_amount, delta_mode );
    x = CON_X( delta_mode );
    y = CON_Y( scale_mode );
    MOVE_CON( scale_mode, x, y );

    // Status Line
    if( !( status_line = CANVAS_CTL( panel_funcs->orig_struct, main_panel,                     // Compare Mode pop-up
                                     "", 600, 15 ) ) )
      throw false;
  
    PanelTools::PutUnder( scale_amount, status_line );
    PanelTools::PutUnder( status_line, status_line );

    // FreeKey-ify button
    if( !( freekey = WBUTTON_CTL( panel_funcs->orig_struct, main_panel,
                                  "FreeKey-ify!", 150 ) ) )
      throw false;
    PanelTools::PutOnLineWith( status_line, freekey, -8 );

    // Right-Align the F1 Button
    int x2 = CON_X( item_scroll );
    int w2 = CON_W( item_scroll );
    y = CON_Y( f1 );
    w = CON_W( f1 );
    MOVE_CON( f1, x2+w2-w, y );

    // Move the About Button just to the left of the F1 Button
    y = CON_Y( about );
    w = CON_W( about );
    x = CON_X( f1 );
    MOVE_CON( about, x-w+5, y );

    PAN_SETW( panel_funcs->orig_struct, main_panel, decoded_logo_small->GetWidth() - 30 );

    // Envent Handler Functions
    CON_SETEVENT( about,                   OnAbout,              this );
    CON_SETEVENT( source_scene,            OnSourceFile,         this );
    CON_SETEVENT( output_scene,            OnOutputFile,         this );
    CON_SETEVENT( source_popup,            OnSourcePopup,        this );
    CON_SETEVENT( output_popup,            OnOutputPopup,        this );
    CON_SETEVENT( item_first_frame,        OnFirstFrame,         this );
    CON_SETEVENT( item_last_frame,         OnLastFrame,          this );
    CON_SETEVENT( item_range_presets,      OnItemRangePresets,   this );
    CON_SETEVENT( item_scroll,             OnItemScroll,         this );
    CON_SETEVENT( item_multiscroll,        OnItemMultiScroll2,   this );
    CON_SETEVENT( item_zoom,               OnItemZoom,           this );
    CON_SETEVENT( list_fold,               OnFoldList,           this );
    CON_SETEVENT( list_unfold,             OnUnFoldList,         this );
    CON_SETEVENT( display_key_mode,        OnKeyFrameMode,       this );
    CON_SETEVENT( display_item_mode,       OnDisplayMode,        this );
    CON_SETEVENT( tool_options_tabs,       OnToolOptionsTabs,    this );
    CON_SETEVENT( group_list,              OnGroupList,          this );

    CON_SETEVENT( range_low,               OnRangeLow,           this );
    CON_SETEVENT( range_high,              OnRangeHigh,          this );
    CON_SETEVENT( remove_mode,             OnRemoveMode,         this );
    CON_SETEVENT( step_amount,             OnStepAmount,         this );
    CON_SETEVENT( step_mode,               OnStepMode,           this );
    CON_SETEVENT( delta_amount,            OnDeltaAmount,        this );
    CON_SETEVENT( delta_mode,              OnDeltaMode,          this );
    CON_SETEVENT( scale_amount,            OnScaleAmount,        this );
    CON_SETEVENT( scale_mode,              OnScaleMode,          this );
    CON_SETEVENT( direction_mode,          OnDirectionMode,      this );

    CON_SETEVENT( f1,                      OnF1,                 this );
    CON_SETEVENT( freekey,                 OnFreeKey,            this );

    CON_SETEVENT( item_list,               OnItemList,           this );
//    CON_SETEVENT( opengl_item_list,        OnItemList,           this );

    // Set the Draw Functions
    ival.intv.value = (int)&DrawItemJumpToFrame;
    (*item_jump_to_frame->set)( item_jump_to_frame, CTL_USERDRAW, &ival );

    ival.intv.value = (int)&DrawItemListbox;
    (*item_list->set)( item_list, CTL_USERDRAW, &ival );

    // For some inexplicable reason, the draw function is an event for OpenGL controls.  Go fig.
//    ival.intv.value = (int)&DrawOpenGLItemListbox;
//    (*opengl_item_list->set)( opengl_item_list, CTL_USERDRAW, &ival );
    CON_SETEVENT( opengl_item_list, DrawOpenGLItemListbox, this );

    ival.intv.value = (int)&DrawItemMultiScroll;
    (*item_multiscroll->set)( item_multiscroll, CTL_USERDRAW, &ival );

    ival.intv.value = (int)&DrawStatusLine;
    (*status_line->set)( status_line, CTL_USERDRAW, &ival );

    CON_SETEVENT( title_image, DrawTitleImage, this );

    return true;
  } catch( bool ) {
    return false;
  }

  return true;
}
Exemplo n.º 2
0
int open_choicepan( LWPanelFuncs *panf )
{
   LWPanControlDesc desc;
   LWValue
      ival = { LWT_INTEGER },
      sval = { LWT_STRING };
   LWPanelID panel;
   LWControl *ctl[ 11 ] = { NULL };
   LWChannelInfo *chinfo;
   LWItemInfo *iteminfo;
   int n, w, ok;

   chinfo = panf->globalFun( LWCHANNELINFO_GLOBAL, GFUSE_TRANSIENT );
   iteminfo = panf->globalFun( LWITEMINFO_GLOBAL, GFUSE_TRANSIENT );
   if ( !chinfo || !iteminfo ) return 0;

   if ( !id )
      id = pid = iteminfo->first( LWI_CAMERA, LWITEM_NULL );

   if ( !chan )
      chan = chinfo->nextChannel( iteminfo->chanGroup( id ), NULL );

   if( !( panel = PAN_CREATE( panf, "Choice" )))
      return 0;

   ctl[ 0 ] = TABCHOICE_CTL( panf, panel, "Tab Choice", choices );
   ctl[ 1 ] = HCHOICE_CTL( panf, panel, "Horizontal Choice", choices );
   ctl[ 2 ] = VCHOICE_CTL( panf, panel, "Vertical Choice", choices );
   ctl[ 3 ] = POPUP_CTL( panf, panel, "Popup", choices );
   ctl[ 4 ] = CUSTPOPUP_CTL( panf, panel, "Custom Popup", 100, name, count );
   ctl[ 5 ] = POPDOWN_CTL( panf, panel, "Popdown", choices );
   ctl[ 6 ] = LISTBOX_CTL( panf, panel, "List Box", 100, 5, name, count );
   ctl[ 7 ] = MULTILIST_CTL( panf, panel, "Multi List Box", 200, 3, mname, count, colwidth );
   ctl[ 8 ] = ITEM_CTL( panf, panel, "Item", panf->globalFun, LWI_CAMERA );
   ctl[ 9 ] = PIKITEM_CTL( panf, panel, "Pikitem", panf->globalFun, LWI_CAMERA, 100 );
   ctl[ 10 ] = CHANNEL_CTL( panf, panel, "Channel", 200, 140 );

   /* align */

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

   SET_INT( ctl[ 0 ], tab );
   SET_INT( ctl[ 1 ], hc );
   SET_INT( ctl[ 2 ], vc );
   SET_INT( ctl[ 3 ], pop );
   SET_INT( ctl[ 4 ], cpop );
   SET_INT( ctl[ 5 ], dpop );
   SET_INT( ctl[ 6 ], list );
   SET_INT( ctl[ 7 ], mlist );
   SET_INT( ctl[ 8 ], ( int ) id );
   SET_INT( ctl[ 9 ], ( int ) pid );
   SET_INT( ctl[ 10 ], ( int ) chan );

   /* need these so that Panels can do some formatting */

   CON_SETEVENT( ctl[ 6 ], NULL, NULL );
   CON_SETEVENT( ctl[ 7 ], NULL, NULL );

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

   if ( ok ) {
      GET_INT( ctl[ 1 ], hc );
      GET_INT( ctl[ 2 ], vc );
      GET_INT( ctl[ 3 ], pop );
      GET_INT( ctl[ 4 ], cpop );
      GET_INT( ctl[ 5 ], dpop );
      GET_INT( ctl[ 6 ], list );
      GET_INT( ctl[ 7 ], mlist );

      ctl[ 8 ]->get( ctl[ 8 ], CTL_VALUE, &ival );
      id = ( LWItemID ) ival.intv.value;

      ctl[ 9 ]->get( ctl[ 9 ], CTL_VALUE, &ival );
      pid = ( LWItemID ) ival.intv.value;

      ctl[ 10 ]->get( ctl[ 10 ], CTL_VALUE, &ival );
      chan = ( LWChannelID ) ival.ptr.ptr;
   }

   PAN_KILL( panf, panel );

   return 1;
}