Example #1
0
        void OnSubViewportButtonPressEvent(object o, ButtonPressEventArgs args)
        {
            /* FIXME: The pointer is grabbed when the event box is clicked.
             * Make sure to ungrab it in order to avoid clicks outisde the window
             * triggering this callback. This should be fixed properly.*/
            Gdk.Pointer.Ungrab(Gtk.Global.CurrentEventTime);

            /* Do not allow switching ports when is a drawing is displayed */
            if (DrawingsVisible)
            {
                return;
            }

            SubViewport subviewport = FindSubViewportFromVideoWindow(o);

            if (subviewport == null)
            {
                return;
            }

            int ndx = subviewport.Index;

            Log.Debug("Clicked on subviewport " + ndx);

            /* Swap main and clicked viewport */
            CameraConfig tmp = playerVM.CamerasConfig [0];

            playerVM.CamerasConfig [0]   = playerVM.CamerasConfig [ndx];
            playerVM.CamerasConfig [ndx] = tmp;
            playerVM.SetCamerasConfig(playerVM.CamerasConfig);
            /* Make the combo box match the current camera in the viewport */
            UpdateCombo(subviewport);

            DebugCamerasVisible();
        }
Example #2
0
 void UpdateCombo(SubViewport viewport)
 {
     if (ViewModel.FileSet != null && viewport.Index < ViewModel.FileSet.ViewModels.Count &&
         viewport.Index < playerVM.CamerasConfig.Count)
     {
         viewport.Visible = true;
         viewport.Combo.Clear();
         var cell = new CellRendererText();
         viewport.Combo.PackStart(cell, false);
         viewport.Combo.AddAttribute(cell, "text", 0);
         var store = new ListStore(typeof(string), typeof(MediaFile));
         foreach (var f in ViewModel.FileSet)
         {
             store.AppendValues(f.Name, f.Model);
         }
         viewport.Combo.Model = store;
         /* Do not trigger the Changed callback from here */
         viewport.Combo.Changed -= OnSubViewportChangedEvent;
         viewport.Combo.Active   = playerVM.CamerasConfig [viewport.Index].Index;
         viewport.Combo.Changed += OnSubViewportChangedEvent;
     }
     else
     {
         viewport.Visible = false;
     }
 }
Example #3
0
        void OnSubViewportChangedEvent(object o, EventArgs args)
        {
            mainviewport.GrabFocus();
            if (ViewModel.FileSet == null)
            {
                return;
            }
            SubViewport subviewport = FindSubViewportFromComboBox(o);

            if (subviewport == null)
            {
                return;
            }

            int ndx = subviewport.Index;

            Log.Debug("Selected camera " + subviewport.Combo.Active + " on subviewport " + ndx);

            // Store in a dropped CameraConfig List the CameraConfig that is going to be drop (in order to reuse it later)
            CameraConfig cam = playerVM.CamerasConfig.FirstOrDefault(x => x.Index == playerVM.CamerasConfig [ndx].Index);

            if (playerVM.CamerasConfig.Count(x => x.Index == playerVM.CamerasConfig [ndx].Index) == 1)
            {
                cameraConfigsOutOfScreen.Add(cam);
            }
            // If the camera in the principal viewport is selected, use his configuration
            cam = playerVM.CamerasConfig.FirstOrDefault(x => x.Index == subviewport.Combo.Active);
            if (cam != null)
            {
                playerVM.CamerasConfig [ndx] = cam;
            }
            else                // If the selected camera was previously on screen, use his configuration and delete it from the dropped CameraConfig list
            {
                cam = cameraConfigsOutOfScreen.FirstOrDefault(x => x.Index == subviewport.Combo.Active);
                if (cam != null)
                {
                    playerVM.CamerasConfig [ndx] = cam;
                    cameraConfigsOutOfScreen.RemoveAll(x => x.Index == subviewport.Combo.Active);
                }
                else                     // In other case, create a new CameraConfig
                {
                    playerVM.CamerasConfig [ndx] = new CameraConfig(subviewport.Combo.Active);
                }
            }

            playerVM.SetCamerasConfig(playerVM.CamerasConfig);
            var file = ViewModel.FileSet.ViewModels [playerVM.CamerasConfig [ndx].Index];

            subviewport.Viewport.Ratio = (float)file.Par * file.VideoWidth / (float)file.VideoHeight;

            DebugCamerasVisible();
        }