Ejemplo n.º 1
0
MainAppWindow::MainAppWindow()
    : DocumentWindow (JUCEApplication::getInstance()->getApplicationName(),
                      Colours::lightgrey,
                      DocumentWindow::allButtons)
{
    setUsingNativeTitleBar (true);
    setResizable (true, false);
    setResizeLimits (400, 400, 10000, 10000);

   #if JUCE_IOS || JUCE_ANDROID
    setFullScreen (true);
   #else
    setBounds ((int) (0.1f * getParentWidth()),
               (int) (0.1f * getParentHeight()),
               jmax (850, (int) (0.5f * getParentWidth())),
               jmax (600, (int) (0.7f * getParentHeight())));
   #endif

    contentComponent = new ContentComponent();
    setContentNonOwned (contentComponent, false);
    setVisible (true);

    // this lets the command manager use keypresses that arrive in our window to send out commands
    addKeyListener (getApplicationCommandManager().getKeyMappings());

   #if JUCE_WINDOWS || JUCE_LINUX || JUCE_MAC
    taskbarIcon = new DemoTaskbarComponent();
   #endif

   #if JUCE_ANDROID
    setOpenGLRenderingEngine();
   #endif

    triggerAsyncUpdate();
}
Ejemplo n.º 2
0
void CabbageEnvelopeHandleComponent::mouseDrag (const MouseEvent& e)
{
    CabbageEnvelopeHandleComponent* previousHandle = getPreviousHandle();
    CabbageEnvelopeHandleComponent* nextHandle = getNextHandle();
    bool fixed = this->getProperties().getWithDefault("fixedPos", false);


    int leftLimit = previousHandle == 0 ? 0 : previousHandle->getX()+1;
    int rightLimit = nextHandle == 0 ? getParentWidth()-previousHandle->getHeight() : nextHandle->getX()-1;
    int topLimit = previousHandle == 0 ? 0 : previousHandle->getX()+1;
    int bottomLimit = nextHandle == 0 ? getParentWidth()-previousHandle->getHeight() : nextHandle->getX()-1;
    int dragX = x+e.getDistanceFromDragStartX();
    int dragY = y+e.getDistanceFromDragStartY();

    //dragger.dragComponent(this, e, &resizeLimits);
    if(dragX < leftLimit)
        dragX = leftLimit;
    if(dragX > rightLimit)
        dragX = rightLimit;
    if(dragY< 0)
        dragY = 0;
    if(dragY > height-5)
        dragY = height-5;
    if(fixed)
        dragX = x;

    this->setTopLeftPosition(dragX, dragY);

    getParentComponent()->repaint();
}
Ejemplo n.º 3
0
void ResizableWindow::setFullScreen (const bool shouldBeFullScreen)
{
    if (shouldBeFullScreen != isFullScreen())
    {
        updateLastPos();
        fullscreen = shouldBeFullScreen;

        if (isOnDesktop())
        {
            if (ComponentPeer* const peer = getPeer())
            {
                // keep a copy of this intact in case the real one gets messed-up while we're un-maximising
                const Rectangle<int> lastPos (lastNonFullScreenPos);

                peer->setFullScreen (shouldBeFullScreen);

                if ((! shouldBeFullScreen) && ! lastPos.isEmpty())
                    setBounds (lastPos);
            }
            else
            {
                jassertfalse;
            }
        }
        else
        {
            if (shouldBeFullScreen)
                setBounds (0, 0, getParentWidth(), getParentHeight());
            else
                setBounds (lastNonFullScreenPos);
        }

        resized();
    }
}
    void update()
    {
        if (bounds.isEmpty())
            setBounds (0, 0, getParentWidth(), getParentHeight());
        else
            setBounds (bounds);

        bluetoothDevicesList.setBounds (getOverlayBounds().withTrimmedTop (40));
    }
void EnvelopeHandleComponent::mouseDown(const MouseEvent& e)
{
#ifdef MYDEBUG
	printf("MyEnvelopeHandleComponent::mouseDown (%d, %d)\n", e.x, e.y);
#endif
	
	setMouseCursor(MouseCursor::NoCursor);
	
	if(e.mods.isShiftDown()) {
		
        if(!shouldLockTime && !shouldLockValue)
        {
            getParentComponent()->setLegendTextToDefault();
            removeThisHandle();
		}
        
        return; // dont send drag msg
		
	} 
	else if(e.mods.isCtrlDown())
	{
		if(getParentComponent()->getAllowNodeEditing())
		{
			ignoreDrag = true;
			
			if(PopupComponent::getActivePopups() < 1)
			{
				EnvelopeNodePopup::create(this, getScreenX()+e.x, getScreenY()+e.y);
			}
		}
	}
	else 
	{
		
		offsetX = e.x;
		offsetY = e.y;
		
		resizeLimits.setMinimumOnscreenAmounts(HANDLESIZE,HANDLESIZE,HANDLESIZE,HANDLESIZE);
		
		EnvelopeHandleComponent* previousHandle = getPreviousHandle();
		EnvelopeHandleComponent* nextHandle = getNextHandle();
		
		int leftLimit = previousHandle == 0 ? 0 : previousHandle->getX()+2;
		int rightLimit = nextHandle == 0 ? getParentWidth()-HANDLESIZE : nextHandle->getX()-2;
//		int leftLimit = previousHandle == 0 ? 0 : previousHandle->getX();
//		int rightLimit = nextHandle == 0 ? getParentWidth()-HANDLESIZE : nextHandle->getX();

		
		resizeLimits.setAdjacentHandleLimits(leftLimit, rightLimit);

		dragger.startDraggingComponent(this, e);//&resizeLimits);
	
	}
    
    getParentComponent()->sendStartDrag();
}
Ejemplo n.º 6
0
/* The track component can contain a number of region components, regions can be added using drag and drop or with a menu */
TrackComponent::TrackComponent(ApplicationCommandManager& commands, Audio::Track *track, int trackID, const Audio::Engine& engine, int64 pixelsPerClip)
: _track(track), _engine(engine), _trackID(trackID), _commands(commands), _sampleRate(engine.getCurrentSamplerate()), _mixerOffset(200), _pixelsPerClip(pixelsPerClip), _numberOfClips(100)
{
    // add and make visible the TrackMixerComponent
    addAndMakeVisible(_trackMixer = new TrackMixerComponent(_trackID, _engine, _commands));
    _trackMixer->setAlwaysOnTop(true);
    // set the track length to the arrange width - the mixer offset in px
	_trackLength = getParentWidth() - static_cast<int>(_mixerOffset);

}
    BluetoothMidiSelectorOverlay()
    {
        setAlwaysOnTop (true);
        setVisible (true);
        addToDesktop (ComponentPeer::windowHasDropShadow);
        setBounds (0, 0, getParentWidth(), getParentHeight());
        toFront (true);

        addAndMakeVisible (bluetoothDevicesList);
        enterModalState (true, nullptr, true);
    }
    Rectangle<int> getOverlayBounds() const noexcept
    {
        if (bounds.isEmpty())
        {
            const int pw = getParentWidth();
            const int ph = getParentHeight();

            return Rectangle<int> (pw, ph).withSizeKeepingCentre (jmin (400, pw - 14),
                                                                  jmin (300, ph - 40));
        }

        return bounds.withZeroOrigin();
    }
Ejemplo n.º 9
0
void Node::mouseDrag (const MouseEvent& e)
{
    dragger.dragComponent (this, e, nullptr);

    auto node = graph.getNodeForID (id);

    node->setPosition (
        std::make_tuple<float, float> (
            (getX () + getWidth () / 2.0f) / (float)getParentWidth (), 
            (getY () + getHeight () / 2.0f) / (float)getParentHeight ())
        );

    getGraph ()->updateGraph ();
}
void EnvelopeHandleComponent::updateLegend()
{	
	EnvelopeComponent *env = getParentComponent();
	EnvelopeLegendComponent* legend = env->getLegend();

	if(legend == 0) return;

	String text;
	
	int width = getParentWidth();
	int places;
	
	if(width >= 165) {
		
		if(env && env->isLoopNode(this))
			text << "(Loop) ";
		else if(env && env->isReleaseNode(this))
			text << "(Release) ";
		else
			text << "Point ";
		
		places = 3;
	}
	else if(width >= 140) {
		text << "Point ";
		places = 3;
	} else if(width >= 115) {
		text << "Pt ";
		places = 3;
	} else if(width >= 100) {
		text << "Pt ";
		places = 2;
	} else if(width >= 85) {
		text << "Pt ";
		places = 1;
	} else if(width >= 65) {
		text << "P ";
		places = 1;
	} else {
		places = 1;
	}
	
	text << (getHandleIndex())
		 << ": "
		 << String(legend->mapTime(time), places) << legend->getTimeUnits()
		 << ", "
		 << String(legend->mapValue(value), places) << legend->getValueUnits();
	
	getParentComponent()->setLegendText(text);
}
double EnvelopeHandleComponent::constrainDomain(double domainToConstrain) const
{ 
	EnvelopeHandleComponent* previousHandle = getPreviousHandle();
	EnvelopeHandleComponent* nextHandle = getNextHandle();

	int leftLimit = previousHandle == 0 ? 0 : previousHandle->getX();
	int rightLimit = nextHandle == 0 ? getParentWidth()-HANDLESIZE : nextHandle->getX();
	
	double left = getParentComponent()->convertPixelsToDomain(leftLimit);
	double right = getParentComponent()->convertPixelsToDomain(rightLimit);
	
	if(previousHandle != 0) left += FINETUNE;
	if(nextHandle != 0) right -= FINETUNE;
		
	return jlimit(left, right, shouldLockTime ? time : domainToConstrain);
}
Ejemplo n.º 12
0
    void mouseDrag (const MouseEvent& e)
    {
        if (! e.mods.isPopupMenu())
        {
            Point<int> pos (originalPos + Point<int> (e.getDistanceFromDragStartX(), e.getDistanceFromDragStartY()));

            if (getParentComponent() != nullptr)
                pos = getParentComponent()->getLocalPoint (nullptr, pos);

            graph.setNodePosition (filterID,
                                   (pos.getX() + getWidth() / 2) / (double) getParentWidth(),
                                   (pos.getY() + getHeight() / 2) / (double) getParentHeight());

            getGraphPanel()->updateComponents();
        }
    }
Ejemplo n.º 13
0
void NodeComponent::mouseDrag (const MouseEvent& e)
{
  if (! e.mods.isPopupMenu())
  {
    Point<int> pos (originalPos + Point<int> (e.getDistanceFromDragStartX(), e.getDistanceFromDragStartY()));
    
    if (getParentComponent() != nullptr)
      pos = getParentComponent()->getLocalPoint (nullptr, pos);
    
    endPos.x = (pos.getX() + getWidth() / 2) / (double) getParentWidth();
    endPos.y = (pos.getY() + getHeight() / 2) / (double) getParentHeight();
    
    audioEngine.getDoc().setNodePosition (nodeID, endPos.x, endPos.y);
    
    getGraphEditor()->updateComponents();
  }
}
Ejemplo n.º 14
0
PlayContentComponent::PlayContentComponent ()
{
    addAndMakeVisible(toolBarControls = new ToolBarControls());
    
    
    addAndMakeVisible(waveformLiveScroller = new LiveScrollDisplay(0));
    
    addAndMakeVisible(spectrumLiveScroller = new LiveScrollDisplay(1));
    
    
    addAndMakeVisible(shapeButtonArray = new ClassButtonArray);
    
    addAndMakeVisible(metroDisplay = new MetronomeComponent);

    
    setSize (getParentWidth(), getParentHeight());

}
Ejemplo n.º 15
0
void TooltipWindow::showFor (const String& tip)
{
    jassert (tip.isNotEmpty());
    if (tipShowing != tip)
        repaint();

    tipShowing = tip;

    Point<int> mousePos (Desktop::getMousePosition());

    if (getParentComponent() != 0)
        mousePos = getParentComponent()->getLocalPoint (0, mousePos);

    int x, y, w, h;
    getLookAndFeel().getTooltipSize (tip, w, h);

    if (mousePos.getX() > getParentWidth() / 2)
        x = mousePos.getX() - (w + 12);
    else
        x = mousePos.getX() + 24;

    if (mousePos.getY() > getParentHeight() / 2)
        y = mousePos.getY() - (h + 6);
    else
        y = mousePos.getY() + 6;

    setBounds (x, y, w, h);
    setVisible (true);

    if (getParentComponent() == 0)
    {
        addToDesktop (ComponentPeer::windowHasDropShadow
                        | ComponentPeer::windowIsTemporary
                        | ComponentPeer::windowIgnoresKeyPresses);
    }

    toFront (false);
}
Ejemplo n.º 16
0
void AlertWindow::updateLayout (const bool onlyIncreaseSize)
{
    const int titleH = 24;
    const int iconWidth = 80;

    const Font font (getLookAndFeel().getAlertWindowMessageFont());

    const int wid = jmax (font.getStringWidth (text),
                          font.getStringWidth (getName()));

    const int sw = (int) std::sqrt (font.getHeight() * wid);
    int w = jmin (300 + sw * 2, (int) (getParentWidth() * 0.7f));
    const int edgeGap = 10;
    const int labelHeight = 18;
    int iconSpace = 0;

    AttributedString attributedText;
    attributedText.append (getName(), font.withHeight (font.getHeight() * 1.1f).boldened());

    if (text.isNotEmpty())
        attributedText.append ("\n\n" + text, font);

    attributedText.setColour (findColour (textColourId));

    if (alertIconType == NoIcon)
    {
        attributedText.setJustification (Justification::centredTop);
        textLayout.createLayoutWithBalancedLineLengths (attributedText, (float) w);
    }
    else
    {
        attributedText.setJustification (Justification::topLeft);
        textLayout.createLayoutWithBalancedLineLengths (attributedText, (float) w);
        iconSpace = iconWidth;
    }

    w = jmax (350, (int) textLayout.getWidth() + iconSpace + edgeGap * 4);
    w = jmin (w, (int) (getParentWidth() * 0.7f));

    const int textLayoutH = (int) textLayout.getHeight();
    const int textBottom = 16 + titleH + textLayoutH;
    int h = textBottom;

    int buttonW = 40;
    int i;
    for (i = 0; i < buttons.size(); ++i)
        buttonW += 16 + buttons.getUnchecked(i)->getWidth();

    w = jmax (buttonW, w);

    h += (textBoxes.size() + comboBoxes.size() + progressBars.size()) * 50;

    if (buttons.size() > 0)
        h += 20 + buttons.getUnchecked(0)->getHeight();

    for (i = customComps.size(); --i >= 0;)
    {
        Component* c = customComps.getUnchecked(i);
        w = jmax (w, (c->getWidth() * 100) / 80);
        h += 10 + c->getHeight();

        if (c->getName().isNotEmpty())
            h += labelHeight;
    }

    for (i = textBlocks.size(); --i >= 0;)
    {
        const AlertTextComp* const ac = static_cast <const AlertTextComp*> (textBlocks.getUnchecked(i));
        w = jmax (w, ac->getPreferredWidth());
    }

    w = jmin (w, (int) (getParentWidth() * 0.7f));

    for (i = textBlocks.size(); --i >= 0;)
    {
        AlertTextComp* const ac = static_cast <AlertTextComp*> (textBlocks.getUnchecked(i));
        ac->updateLayout ((int) (w * 0.8f));
        h += ac->getHeight() + 10;
    }

    h = jmin (getParentHeight() - 50, h);

    if (onlyIncreaseSize)
    {
        w = jmax (w, getWidth());
        h = jmax (h, getHeight());
    }

    if (! isVisible())
    {
        centreAroundComponent (associatedComponent, w, h);
    }
    else
    {
        const int cx = getX() + getWidth() / 2;
        const int cy = getY() + getHeight() / 2;

        setBounds (cx - w / 2,
                   cy - h / 2,
                   w, h);
    }

    textArea.setBounds (edgeGap, edgeGap, w - (edgeGap * 2), h - edgeGap);

    const int spacer = 16;
    int totalWidth = -spacer;

    for (i = buttons.size(); --i >= 0;)
        totalWidth += buttons.getUnchecked(i)->getWidth() + spacer;

    int x = (w - totalWidth) / 2;
    int y = (int) (getHeight() * 0.95f);

    for (i = 0; i < buttons.size(); ++i)
    {
        TextButton* const c = buttons.getUnchecked(i);
        int ny = proportionOfHeight (0.95f) - c->getHeight();
        c->setTopLeftPosition (x, ny);
        if (ny < y)
            y = ny;

        x += c->getWidth() + spacer;

        c->toFront (false);
    }

    y = textBottom;

    for (i = 0; i < allComps.size(); ++i)
    {
        Component* const c = allComps.getUnchecked(i);
        h = 22;

        const int comboIndex = comboBoxes.indexOf (dynamic_cast <ComboBox*> (c));
        if (comboIndex >= 0 && comboBoxNames [comboIndex].isNotEmpty())
            y += labelHeight;

        const int tbIndex = textBoxes.indexOf (dynamic_cast <TextEditor*> (c));
        if (tbIndex >= 0 && textboxNames[tbIndex].isNotEmpty())
            y += labelHeight;

        if (customComps.contains (c))
        {
            if (c->getName().isNotEmpty())
                y += labelHeight;

            c->setTopLeftPosition (proportionOfWidth (0.1f), y);
            h = c->getHeight();
        }
        else if (textBlocks.contains (c))
        {
            c->setTopLeftPosition ((getWidth() - c->getWidth()) / 2, y);
            h = c->getHeight();
        }
        else
        {
            c->setBounds (proportionOfWidth (0.1f), y, proportionOfWidth (0.8f), h);
        }

        y += h + 10;
    }

    setWantsKeyboardFocus (getNumChildComponents() == 0);
}
Ejemplo n.º 17
0
 void moved() override
 {
     if (isMouseButtonDown())
         relativePos = getBounds().getCentre().toFloat() / Point<int> (getParentWidth(), getParentHeight()).toFloat();
 }
Ejemplo n.º 18
0
 void parentSizeChanged()
 {
     setBounds (0, 0, getParentWidth(), getParentHeight());
 }
Ejemplo n.º 19
0
void ResizableWindow::parentSizeChanged()
{
    if (isFullScreen() && getParentComponent() != nullptr)
        setBounds (0, 0, getParentWidth(), getParentHeight());
}
Ejemplo n.º 20
0
 void parentSizeChanged() override
 {
     parentWidth = getParentWidth() - size;
     parentHeight = getParentHeight() - size;
 }