예제 #1
0
파일: CameraDemo.cpp 프로젝트: bacchus/JUCE
    void buttonClicked (Button* b) override
    {
        if (cameraDevice != nullptr)
        {
            if (b == &recordMovieButton)
            {
                // The user has clicked the record movie button..
                if (! recordingMovie)
                {
                    // Start recording to a file on the user's desktop..
                    recordingMovie = true;

                    File file (File::getSpecialLocation (File::userDesktopDirectory)
                               .getNonexistentChildFile ("JuceCameraDemo",
                                                         CameraDevice::getFileExtension()));

                    cameraDevice->startRecordingToFile (file);
                    recordMovieButton.setButtonText ("Stop Recording");
                }
                else
                {
                    // Already recording, so stop...
                    recordingMovie = false;
                    cameraDevice->stopRecording();
                    recordMovieButton.setButtonText ("Start recording (to a file on your desktop)");
                }
            }
            else
            {
                // When the user clicks the snapshot button, we'll attach ourselves to
                // the camera as a listener, and wait for an image to arrive...
                cameraDevice->addListener (this);
            }
        }
    }
예제 #2
0
void HadronLabel::mouseDoubleClick(const MouseEvent& e) 
{
    if (use_modal_editor_) {
        
        if (isEditableOnDoubleClick() && ! e.mods.isPopupMenu()) {
            
            ModalComponentManager::Callback* userCallback = 0;
            ScopedPointer<ModalComponentManager::Callback> userCallbackDeleter (userCallback);
            Component::SafePointer<Component> prevFocused (Component::getCurrentlyFocusedComponent());
            Component::SafePointer<Component> prevTopLevel ((prevFocused != 0) ? prevFocused->getTopLevelComponent() : 0);
            
            ScopedPointer <TextEditor> texteditor (createEditorComponent());
            texteditor->setColour(TextEditor::backgroundColourId, Colours::white);
            texteditor->setWantsKeyboardFocus (true);
            texteditor->setAlwaysOnTop (true);
            
            // Find screen position
            Rectangle<int> sr (getBounds ());
            sr.setPosition (getScreenX(), getScreenY());
            int fontheight = static_cast<int>(texteditor->getFont().getHeight()) + 4;
            if (sr.getHeight() > fontheight) {
                sr.translate (0, (sr.getHeight() - fontheight)/2);
                sr.setHeight (fontheight);
            }
            texteditor->setBounds(sr);
            
            texteditor->setText(getText(),false);
            texteditor->setHighlightedRegion (Range <int> (0, getText().length ()));
            texteditor->setVisible (true);
            texteditor->grabKeyboardFocus();
            texteditor->addToDesktop (ComponentPeer::windowIsTemporary, 0);
            
            texteditor->addListener (this);
            texteditor->enterModalState (false);
            texteditor->grabKeyboardFocus();
            
            texteditor->runModalLoop();
            
            if (prevTopLevel != 0)
                prevTopLevel->toFront (true);
            if (prevFocused != 0)
                prevFocused->grabKeyboardFocus();
        }
    }
    else {
        Label::mouseDoubleClick(e);
    }
}