Esempio n. 1
0
void AutomationUI::mouseDown(const MouseEvent & e)
{
	BaseManagerUI::mouseDown(e);

	if (e.eventComponent == this)
	{
		if (e.mods.isLeftButtonDown() && e.mods.isCtrlDown())
		{
			manager->addItem(getPosForX(e.getPosition().x), (1 - e.getPosition().y*1.f / getHeight()));
		}else
		{
			Array<Component *> selectables;
			Array<Inspectable *> inspectables;
			for (auto &i : itemsUI) if (i->isVisible())
			{
				selectables.add(&i->handle);
				inspectables.add(i->inspectable);
			}

			if (transformer != nullptr)
			{
				removeChildComponent(transformer);
				transformer = nullptr;
			}

			if(InspectableSelector::getInstance()) InspectableSelector::getInstance()->startSelection(this, selectables, inspectables,manager->selectionManager);
		}
	}
	
}
Esempio n. 2
0
void SliderBank::mouseDrag (const MouseEvent& event)
{
	// choose slider to operate on
	MicronSlider* slider = 0;
	if (lockedSliderBeingDragged)
		slider = lockedSliderBeingDragged;
	else
		if ( event.getPosition().getX() >= minBoundX && event.getPosition().getX() < maxBoundX )
			slider = findSliderAtPos(event.getPosition());

	if ( ! slider )
		return; // no slider

	if (slider != prevSlider)
	{ // different slider from last time
		if (resettingValuesToDefault)
		{ // reset slider to default value
			bool dummy;
			slider->setValue(slider->getDoubleClickReturnValue(dummy));
		}
		else
		{ // set slider value at mouse position
			slider->resetDoubleClickTimer(); // ensure we don't reset sliders just by dragging back and forth over them
			slider->mouseDown(event.getEventRelativeTo(slider));
		}
	}
	else
	{ // same slider as last time
		if ( ! resettingValuesToDefault )
			slider->mouseDrag(event.getEventRelativeTo(slider));
	}

	prevSlider = slider;
}
Esempio n. 3
0
//--------------------------------------------------------------------
void SidebarPanel::mouseDrag(const MouseEvent& event)
{
    if(canResize)
    {
        this->setSize(event.getPosition().getX(), this->getHeight());
        sendActionMessage("SidebarWidth:"+String(event.getPosition().getX()));
    }
}
void MidiKeyboardComponent::mouseDrag (const MouseEvent& e)
{
    float mousePositionVelocity;
    const int newNote = xyToNote (e.getPosition(), mousePositionVelocity);

    if (newNote >= 0)
        mouseDraggedToKey (newNote, e);

    updateNoteUnderMouse (e.getPosition());
}
Esempio n. 5
0
 void mouse_drag(const MouseEvent& e) override {
     if (auto strong = item_.lock()) {
         const auto initial = compute_world_mouse_position(glm::vec2{
                 e.getMouseDownPosition().x, e.getMouseDownPosition().y});
         const auto current = compute_world_mouse_position(
                 glm::vec2{e.getPosition().x, e.getPosition().y});
         const auto new_pos = initial_position_ + current - initial;
         strong->set_position(new_pos);
     }
 }
void GuitarNeckComponent::mouseDrag (const MouseEvent& e)
{
    float mousePositionVelocity;
    const FrettedNote newNote = xyToNote (e.getPosition(), mousePositionVelocity);

	if (newNote.isValid())
		mouseDraggedToKey (newNote.fret,newNote.string, e);

    updateNoteUnderMouse (e.getPosition());
	repaint();
}
Esempio n. 7
0
 void mouse_drag(const MouseEvent& e) override {
     //  Find mouse position on plane perpendicular to camera direction
     //  through the rotation origin.
     const auto initial = compute_world_mouse_position(glm::vec2{
             e.getMouseDownPosition().x, e.getMouseDownPosition().y});
     const auto current = compute_world_mouse_position(
             glm::vec2{e.getPosition().x, e.getPosition().y});
     //  Adjust the model origin based on the difference between the initial
     //  and current mouse positions.
     model_.set_origin(initial_position_ + current - initial);
 }
Esempio n. 8
0
    void mouseDrag (const MouseEvent& e) override
    {
        Trail* t = getTrail (e.source);

        if (t == nullptr)
        {
            t = new Trail (e.source);
            t->path.startNewSubPath (e.getPosition().toFloat());
            trails.add (t);
        }

        t->pushPoint (e.getPosition().toFloat(), e.mods);
        repaint();
    }
Esempio n. 9
0
  void mouseDrag (MouseEvent const& e)
  {
    if (m_edit != nullptr)
    {
      Rectangle <int> const bounds = getLocalBounds ();

      int x = jlimit (0, bounds.getWidth (), e.getPosition ().getX () - bounds.getX ());
      int y = jlimit (0, bounds.getHeight (), e.getPosition ().getY () - bounds.getY ());

      m_edit->in = float (x) / bounds.getWidth ();
      m_edit->out = 1.f - (float (y) / bounds.getHeight ());

      repaint ();
    }
  }
Esempio n. 10
0
void AdsrWidget::mouseDoubleClick (const MouseEvent& e){

	if(e.getPosition().getX() <= (*(adsrHandleSet.begin()))->getX()){
		//refuse to add that point
	}else if(e.getPosition().getX() >= (*(adsrHandleSet.rbegin()))->getX()){
		//refuse to add that point
	}else{
		AdsrHandleWidget* temp = new AdsrHandleWidget(this, e.getPosition().getX(), e.getPosition().getY(), AdsrHandleWidget::MOVE_HORIZONTAL|AdsrHandleWidget::MOVE_VERTICAL);
		
		AdsrHandleSetType::iterator it = (adsrHandleSet.insert(temp)).first;
		addAndMakeVisible (*it);
		
		repaint();
	}
}
void LuftikusAudioProcessorEditor::mouseDown(const MouseEvent& e)
{
	juce::Rectangle<int> rect;

	switch (guiType)
	{
	//case LuftikusAudioProcessor::kLuftikus:
	//	rect = juce::Rectangle<int> (13, 120, 100, 18);
	//	break;
	//case LuftikusAudioProcessor::kLkjb:
	//	rect = juce::Rectangle<int> (22, 119, 102, 22);
	//	break;
	default:
	case LuftikusAudioProcessor::kGui:
		rect = juce::Rectangle<int> (108, 156, 115, 40);
		break;
	}

	if (rect.contains(e.getPosition()) && showTooltips == nullptr)
	{
		showTooltips = new PopupMenu();
		showTooltips->addItem(1, "Show Tooltips", true, tooltips != nullptr);
		showTooltips->showMenuAsync(PopupMenu::Options(), modalCallback = new ModalCallback(this));
		//showInfo = ! showInfo;
		//resized();
		//repaint();
	}
}
Esempio n. 12
0
void HoaMap::mouseDrag (const MouseEvent &event)
{
    Point<float> mouse = event.getPosition().toFloat();
    Point<float> newPos;
    ModifierKeys modifierKey = event.mods;
    // conversion en cartesien :
    //mouse.applyTransform(AffineTransform::translation(m_padding, m_padding));
    mouse.applyTransform(AffineTransform::fromTargetPoints(0, 0, -1, 1,
                                                           getPadWidth(), 0, 1, 1,
                                                           getPadWidth(), getPadWidth(), 1, -1));
    
    newPos = mouse;
    
    if (m_sourcePointed >= 0 && m_sourcePointed < m_nbSources) {
        setMouseCursor(MouseCursor::DraggingHandCursor);
        m_sources_dragState[m_sourcePointed] = -1; // reset dragging state
        m_sources_ValueChanged[m_sourcePointed] = 1;
        if (modifierKey.isShiftDown()) { // constrain move to distance
            setPolarCoordinates(m_sourcePointed, Tools::radius(newPos.x, newPos.y), m_sources[m_sourcePointed].getAzimuth());
        }
        else if (modifierKey.isCtrlDown()) { // constrain move to angle
            setPolarCoordinates(m_sourcePointed, m_sources[m_sourcePointed].getRadius(), Tools::angle(newPos.x, newPos.y));
        }
        else {
            setCartesianCoordinates(m_sourcePointed, newPos.x, newPos.y, sendNotificationSync);
        }
    }
}
Esempio n. 13
0
std::unique_ptr<controller::mouse_action> controller::start_action(
        const MouseEvent& e) {
    //  If middle and left mouse buttons are pressed, start panning action.
    if (e.mods.isMiddleButtonDown()) {
        return std::make_unique<pan_action>(model_.scene);
    }

    //  If middle mouse button is pressed, start rotation action.
    if (e.mods.isRightButtonDown()) {
        return std::make_unique<rotate_action>(model_.scene);
    }

    //  If left mouse button is pressed, check for hovered items.
    //  If any, start move action with hovered item.
    //  Else, do nothing.
    if (allow_edit_ && e.mods.isLeftButtonDown()) {
        return do_action_with_closest_thing(
                wayverb::core::to_vec2{}(e.getPosition()),
                *model_.project.persistent.sources(),
                *model_.project.persistent.receivers(),
                [this](const auto& shared) -> std::unique_ptr<mouse_action> {
                    return make_move_item_action_ptr(model_.scene, shared);
                });
    }

    //  If nothing (important) is pressed then do nothing.
    return nullptr;
}
Esempio n. 14
0
void controller::mouse_move(const MouseEvent& e) {
    if (allow_edit_) {
        //  Temporarily block connections to minimize redraw requests:

        model_.project.persistent.sources().block();
        model_.project.persistent.receivers().block();

        //  Ensure nothing is hovered.
        for (auto& i : *model_.project.persistent.sources()) {
            i->hover_state()->set_hovered(false);
        }
        for (auto& i : *model_.project.persistent.receivers()) {
            i->hover_state()->set_hovered(false);
        }

        //  Allow notifications to propagate again.
        model_.project.persistent.sources().unblock();
        model_.project.persistent.receivers().unblock();

        //  look for hovered items, notify if something is hovered.
        do_action_with_closest_thing(
                wayverb::core::to_vec2{}(e.getPosition()),
                *model_.project.persistent.sources(),
                *model_.project.persistent.receivers(),
                [](const auto& shared) {
                    shared->hover_state()->set_hovered(true);
                    return true;
                });
    }
}
void MidiKeyboardComponent::mouseUp (const MouseEvent& e)
{
    mouseDragging = false;
    updateNoteUnderMouse (e.getPosition());

    stopTimer();
}
Esempio n. 16
0
void HoaMapComponent::mouseMove(const MouseEvent &event)
{
    Point<float> point;
    Point<float> mouse = event.getPosition().toFloat();
    mouse.applyTransform(AffineTransform::fromTargetPoints(0, 0, -1, 1, getWidth(), 0, 1, 1, getWidth(), getWidth(), 1, -1));
    
    m_source_selected   = -1;
    for (int i = 0; i < m_sources->getNumberOfSources(); i++)
    {
        if(m_sources->sourceGetExistence(i))
        {
            point.setXY(m_sources->sourceGetAbscissa(i) * m_sources->getZoom(), m_sources->sourceGetOrdinate(i) * m_sources->getZoom());
            if(mouse.getDistanceFrom(point) < m_sources_size * 0.002)
            {
                m_source_selected = i;
                setMouseCursor(MouseCursor::PointingHandCursor);
                repaint();
                return;
            }
        }
    }
    m_drag_mode = 0;
    repaint();
    setMouseCursor(MouseCursor::NormalCursor);
}
Esempio n. 17
0
void OpenGLCanvas::mouseDownInCanvas(const MouseEvent& e)
{

	if (getTotalHeight() > getHeight()) {

	Point<int> pos = e.getPosition();
	int xcoord = pos.getX();

	if (xcoord > getWidth()-scrollBarWidth) {

		int ycoord = pos.getY();

		float targetPoint = float(ycoord)/float(getHeight());

		if (targetPoint < scrollBarTop && targetPoint < scrollBarTop)
		{

			scrollPix = int(float(ycoord)/float(getHeight())*float(getTotalHeight()));

		} else if (targetPoint > scrollBarBottom && targetPoint > scrollBarBottom) {
			
			scrollPix = int(float(ycoord)/float(getHeight())*float(getTotalHeight())) -
						(scrollBarBottom-scrollBarTop)*float(getTotalHeight());

		}
		
		showScrollTrack = true;
		showScrollBars();
	}
	}
}
Esempio n. 18
0
void GuitarNeckComponent::mouseUp (const MouseEvent& e)
{
    mouseDragging = false;
    updateNoteUnderMouse (e.getPosition());

    stopTimer();
}
void MidiKeyboardComponent::mouseDown (const MouseEvent& e)
{
    float mousePositionVelocity;
    const int newNote = xyToNote (e.getPosition(), mousePositionVelocity);
    mouseDragging = false;

    if (newNote >= 0 && mouseDownOnKey (newNote, e))
    {
        repaintNote (noteUnderMouse);
        noteUnderMouse = -1;
        mouseDragging = true;

        updateNoteUnderMouse (e.getPosition());
        startTimer (500);
    }
}
// Sets the height of the steps based on mouse positions.
// If the mouse skipped over some steps between last mouseDrag event, we'll interpolate
// and set all the steps inbetween to appropriate values.
void GraphicalStepSequencer::changeStep(const MouseEvent& e) {
  Point<int> mouse_position = e.getPosition();
  int from_step = getHoveredStep(last_edit_position_);
  int selected_step = getHoveredStep(mouse_position);

  float x = mouse_position.x;
  float y = mouse_position.y;
  float x_delta = last_edit_position_.x - x;
  float y_delta = last_edit_position_.y - y;
  float slope = y_delta == 0 ? 0 : y_delta / x_delta;
  float next_x = getWidth() * (1.0f * selected_step) / num_steps_;
  int direction = -1;

  if (selected_step < from_step) {
    direction = 1;
    next_x += getWidth() * 1.0f / num_steps_;
  }
  float inc_x = next_x - x;

  for (int step = selected_step; step != from_step + direction; step += direction) {
    if (step >= 0 && step < num_steps_) {
      float new_value = -2.0f * y / getHeight() + 1.0f;
      sequence_[step]->setValue(std::max(std::min(new_value, 1.0f), -1.0f));
    }
    y += inc_x * slope;
    inc_x = direction * getWidth() * 1.0f / num_steps_;
  }
  resetBackground();
}
Esempio n. 21
0
void MenuBarComponent::mouseDrag (const MouseEvent& e)
{
    const MouseEvent e2 (e.getEventRelativeTo (this));
    const int item = getItemAt (e2.getPosition());

    if (item >= 0)
        showMenu (item);
}
Esempio n. 22
0
void HoaplugAudioProcessorEditor::mouseDown (const MouseEvent &event)
{
    Point<int> mouse = event.getPosition();
    Rectangle<int> clickable(70, 40, 20, 20);
    if (clickable.contains(mouse)) {
        URL("http://www.mshparisnord.fr/hoalibrary/").launchInDefaultBrowser();
    }
}
Esempio n. 23
0
void TrackBox::mouseDown (const MouseEvent& e)
{
    //[UserCode_mouseDown] -- Add your code here...
    DragAndDropContainer* dragContainer = DragAndDropContainer::findParentDragContainerFor(this);
    startingDragPositionRelativeToSelf = e.getPosition();
    dragContainer->startDragging ("TrackBox", this);
    //[/UserCode_mouseDown]
}
void
GraphicsPanel::mouseDrag(const MouseEvent & ee)
{
    ODL_OBJENTER(); //####
    ODL_P1("ee = ", &ee); //####
    _draggableOrientation.mouseDrag(ee.getPosition());
    ODL_OBJEXIT(); //####
} // GraphicsPanel::mouseDrag
void CabbageTableManager::mouseDrag(const MouseEvent& e)
{
//if in toggle mode, draw on mouse move
    if(e.mods.isLeftButtonDown())
        for(int i=0; i<tables.size(); i++)
        {
            if(tables[i]->toggleMaxMin)
            {
                if(tables[i]->getBounds().contains(Point<int>(e.getPosition().getX(), e.getPosition().getY())))
                {
                    tables[i]->toggleMinMaxAmp(e.getPosition().getX());
                    tables[i]->changeMessage = "updateFunctionTable";
                    tables[i]->sendChangeMessage();
                }
            }
        }
}
void CtrlrPanelCanvas::handleRightClickOnCanvas(const MouseEvent &e)
{
	const bool em = getOwner().getProperty(Ids::uiPanelEditMode);

	if (!em)
	{
		PopupMenu m = getRightClickComponentMenu(e);
		handleComponentPopupMenu(e, m.show());
		return;
	}

	PopupMenu m;

	if (em)
	{
		m = CtrlrComponentTypeManager::getComponentMenu(em);
		getEditMenu(m);
	}
	else
	{
		m = getRightClickComponentMenu(e);
	}

	const int ret = m.show();

	if (ret >= 4096)
	{
		handleComponentPopupMenu(e, ret);
	}
	else if (ret == 1024)
	{
		getOwner().setProperty (Ids::uiPanelEditMode, !em);
		getOwner().editModeChanged();
	}
	else if (ret < 1024 && ret > 10)
	{
		PopupMenu::MenuItemIterator iterator((const PopupMenu &)m);
		while (iterator.next())
		{
			if (iterator.getItem().subMenu)
			{
				PopupMenu::MenuItemIterator iterator2(*iterator.getItem().subMenu);
					while (iterator2.next())
				{
					if (iterator2.getItem().itemID == ret)
					{
						addNewComponent (iterator2.getItem().text, e.getPosition(), e.eventComponent);
					}
				}
			}
		}
	}
	else if (ret >= 2048 && ret < 4096)
	{
		handleEditMenu (ret, e);
	}
}
Esempio n. 27
0
void imaphone_component::mouseDown (const MouseEvent& e)
{
    //[UserCode_mouseDown] -- Add your code here...
	if (color_preview->getBounds().contains(e.getPosition())) {
		image->set_color_full_preview(true);
		color_preview->setToggleState(true, NotificationType::dontSendNotification);
	}
    //[/UserCode_mouseDown]
}
Esempio n. 28
0
void GuitarNeckComponent::mouseDown (const MouseEvent& e)
{
    float mousePositionVelocity;
    const FrettedNote newNote = xyToNote (e.getPosition(), mousePositionVelocity);
    mouseDragging = false;

	if (newNote.isValid() && mouseDownOnKey (newNote.fret,newNote.string, e))
    {
		//repaintNote (noteUnderMouse.fret);
		noteUnderMouse.invalidate();
        mouseDragging = true;

		currentlyFrettedFret[newNote.string]=newNote.fret;
        updateNoteUnderMouse (e.getPosition());
        startTimer (500);
		repaint();
    }
}
Esempio n. 29
0
void Label::mouseUp (const MouseEvent& e)
{
    if (editSingleClick
         && e.mouseWasClicked()
         && contains (e.getPosition())
         && ! e.mods.isPopupMenu())
    {
        showEditor();
    }
}
void ResizableBorderComponent::updateMouseZone (const MouseEvent& e)
{
    Zone newZone (Zone::fromPositionOnBorder (getLocalBounds(), borderSize, e.getPosition()));

    if (mouseZone != newZone)
    {
        mouseZone = newZone;
        setMouseCursor (newZone.getMouseCursor());
    }
}