コード例 #1
0
void VoxelBufferFilter::update()
{
	if (numCaptureFrames != volumeSize[2] && !isMouseDown()) {
		resizeVolume(videoSize.x, videoSize.y, numCaptureFrames);
		captureProgressSlider->max = numCaptureFrames;

		capturedFrames = 0;
		frameOffsetBytes = 0;
	}

	if (settings.do_capture)
	{
		if (capturedFrames < numCaptureFrames)
	{
			char* latestFrame = input.getCvImage()->imageData;

			frameOffsetBytes = volumeSize[0]*volumeSize[1]*capturedFrames;

			// We add our frame to the accumulator
			memcpy(h_volume+(frameOffsetBytes), latestFrame, videoSize.x*videoSize.y);
			// and increment the pointer offset by 1 frame size
//			frameOffsetBytes += videoSize.x*videoSize.y;
			capturedFrames++;
		}
		if (capturedFrames >= numCaptureFrames)
	{
			settings.do_capture = false;
			// Update the GPU's copy
			rayTracer->updateVolume(clScheduler->context, h_volume, volumeSize[0], volumeSize[1], volumeSize[2]);

			// Reset the pointer offset
			frameOffsetBytes = 0;
		}
	}
}
コード例 #2
0
ファイル: main.cpp プロジェクト: jhk2/glsandbox
void onMouseMove(int nx, int ny)
{
	int dx = nx - g_mouse_x;
	int dy = ny - g_mouse_y;
	
	// for now, only if right click is down
	if (isMouseDown(2)) {
		printf("old x is %i, old y is %i\n", g_mouse_x, g_mouse_y);
		printf("new x is %i, new y is %i\n", nx, ny);
		printf("dx is %i, dy is %i\n", dx, dy);
		g_cam_rot.y += MOUSESCALE * dx;
		g_cam_rot.x += MOUSESCALE * dy;
		// limit up/down rotation to -90 to +90 degrees
		g_cam_rot.x = min(90, max(-90, g_cam_rot.x));
		// limit left/right rotation to 0 -360 to 360 to prevent overflow
		if (g_cam_rot.y > 360) {
			g_cam_rot.y = 360 - g_cam_rot.y;
		} else if (g_cam_rot.y < -360) {
			g_cam_rot.y = 360 + g_cam_rot.y;
		}
	}	
	
	g_mouse_x = nx;
	g_mouse_y = ny;
}
コード例 #3
0
ファイル: main.cpp プロジェクト: jhk2/glsandbox
void handleMouse(float dt)
{
	// hide cursor if rmb is down
	if (isMousePress(2)) {
		ShowCursor(false);
	} else if (isMouseRelease(2)) {
		ShowCursor(true);
	}
	POINT pt;
	GetCursorPos(&pt);
	ScreenToClient(g_hwnd, &pt);
	onMouseMove(pt.x, pt.y);
	if (isMouseDown(2)) {
		if (isMousePress(2)) {
			g_hold_x = pt.x;
			g_hold_y = pt.y;
		}
		// recenter the cursor
		POINT pt;
		pt.x = g_hold_x;
		pt.y = g_hold_y;
		ClientToScreen(g_hwnd, &pt);
		SetCursorPos(pt.x, pt.y);
		g_mouse_x = g_hold_x;
		g_mouse_y = g_hold_y;
	}
}
コード例 #4
0
void PopUpDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) {
	if (keycode == 27) {	// escape
		close();
		return;
	}

	if (isMouseDown())
		return;

	switch (keycode) {
	case '\n':		// enter/return
	case '\r':
		setResult(_selection);
		close();
		break;
	case 256+17:	// up arrow
		moveUp();
		break;
	case 256+18:	// down arrow
		moveDown();
		break;
	case 256+22:	// home
		setSelection(0);
		break;
	case 256+23:	// end
		setSelection(_popUpBoss->_entries.size()-1);
		break;
	}
}
コード例 #5
0
ofxSimpleGuiControl &ofxSimpleGuiControl::setContent2DSliderBGColor(bool clickable) {
    ofEnableAlphaBlending();
	if(isMouseDown() || isMouseOver() || clickable) {
        int r = (config->fullActiveColor >> 16) & 0xff;
        int g = (config->fullActiveColor >> 8) & 0xff;
        int b = (config->fullActiveColor >> 0) & 0xff;
        ofSetColor(r,g,b, config->monitorSlider2dAlpha);
    }
コード例 #6
0
void PopUpDialog::handleMouseMoved(int x, int y, int button) {
	// Compute over which item the mouse is...
	int item = findItem(x, y);

	if (item >= 0 && _popUpBoss->_entries[item].name.size() == 0)
		item = -1;

	if (item == -1 && !isMouseDown())
		return;

	// ...and update the selection accordingly
	setSelection(item);
}
コード例 #7
0
	//-------------------------------------------------------------------------
	bool DefaultInputSystem::isKeyDown(const KeyComb& _keyComb) const
	{
		for(size_t m = 0; m != _keyComb.getNumMouseButtons(); ++m)
		{
			if(!isMouseDown(_keyComb.getMouseButton(m)))
				return false;
		}
		for(size_t k = 0; k != _keyComb.getNumKeyCodes(); ++k)
		{
			if(!isKeyDown(_keyComb.getKeyCode(k)))
				return false;
		}
		return true;
	}
コード例 #8
0
void wxAuiFloatingFrame::OnIdle(wxIdleEvent& event)
{
    if (m_moving)
    {
        if (!isMouseDown())
        {
            m_moving = false;
            OnMoveFinished();
        }
        else
        {
            event.RequestMore();
        }
    }
}
コード例 #9
0
//--------------------------------------------------------------
void ofxDraggableGui::draw()
{
	if(!enabled) return;

	ofxSimpleGuiPage::draw(x, y, false);
 
	if (!bDraggable)
		return;	
	
	int border = 4;
	// add a border if mouse is pressed or over the object
	ofSetLineWidth(border);
	ofEnableAlphaBlending();
	ofSetColor(255,255,255,127);
	if(isMouseDown())
	{
		ofFill();
		for (int i=0; i<controls.size(); i++) {
			if (controls[i]->controlType!="Title"
				&&controls[i]->isMouseDown())
			{
				ofNoFill();
				break;
			}
		}

		ofRect(x-(border/2), y-(border/2), width+border, height-config->padding.y+border);

	}
	else if(isMouseOver())
	{
		ofNoFill();
		ofRect(x-(border/2), y-(border/2), width+border, height-config->padding.y+border);
	}

	//		ofRect(x, y, width, height - config->padding.y);
	ofDisableAlphaBlending();
	ofSetLineWidth(1.0);
	
	glPopMatrix();
}
コード例 #10
0
ファイル: Menu.cpp プロジェクト: RedMser/NecroEdit
void Menu::onUpdateVertexCache()
{
	clearVertices();

	BoxStyle backgroundBox;
	backgroundBox.pressed = true;
	backgroundBox.focused = true;
	vertexAddBox(BoxTypeDark, backgroundBox);

	if (myMouseOverItem != -1 && myModel && myModel->isEnabled(myMouseOverItem) && !myModel->isSeparator(myMouseOverItem))
	{
		BoxStyle highlightBox;
		highlightBox.color = sf::Color(125, 175, 225);
		highlightBox.outlineColor = highlightBox.color * sf::Color(200,200,200);
		highlightBox.pressed = isMouseDown();
		vertexAddBox(sf::FloatRect(cvPadding, myTexts[myMouseOverItem]->getPosition().y - cvPadding, getSize().x - cvPadding * 2.f, cvItemHeight + cvPadding), BoxTypeBasic, highlightBox);
	}

	BoxStyle checkBox;
	checkBox.activated = true;

	for (std::size_t i = 0; i < myModel->getItemCount(); ++i)
	{
		if (myModel->isSeparator(i))
		{
			vertexAddRectVGradient(sf::FloatRect(cvPadding * 2.f, myTexts[i]->getPosition().y, getSize().x - cvPadding * 4.f, cvPadding), sf::Color(180,180,180), sf::Color(120,120,120));
		}
		else
		{
			if (myModel->isChecked(i))
			{
				float checkboxSize = 14.f;
				checkBox.hovered = (myMouseOverItem == (int)i);
				vertexAddBox(sf::FloatRect(3.f * cvPadding, myTexts[i]->getPosition().y + (cvItemHeight - checkboxSize - cvPadding) / 2.f, checkboxSize, checkboxSize), BoxTypeBasic, checkBox);
			}

			vertexAddTextured(myTexts[i]->getVertices());
		}
	}
}
コード例 #11
0
bool InputManager::isMouseUp(OIS::MouseButtonID button) 
{
	return !isMouseDown(button);
}
コード例 #12
0
ファイル: LevelPanel.cpp プロジェクト: Marukyu/NecroEdit
void LevelPanel::onProcessContainer(gui2::WidgetEvents& events)
{
	for (std::size_t i = 0; i < levelListEntries.size(); ++i)
	{
		auto levelEntry = levelListEntries[i];

		if (levelEntry->isMouseDown())
		{
			selectLevel(i);
		}
	}

	if (dropdownMusic->wasChanged())
	{
		try
		{
			dungeon->getLevel(getSelectedLevel()).setMusic(songIDs.at(dropdownMusic->getSelection()));
		}
		catch (...)
		{
			// No level selected or song ID somehow out of range? Ignore.
		}
	}

	if (dropdownBoss->wasChanged())
	{
		try
		{
			dungeon->getLevel(getSelectedLevel()).setBoss(bossIDs.at(dropdownBoss->getSelection()));
		}
		catch (...)
		{
			// No level selected or boss ID somehow out of range? Ignore.
		}
	}

	updateSlider();

	if (levelListSlider->isEnabled())
	{
		if ((levelListContainer->isMouseOver() || levelListSlider->isMouseOver()) && events.mouseWheelDelta != 0)
		{
			scrollVelocity -= events.mouseWheelDelta * 5;
		}

		if (std::abs(scrollVelocity) > 0.0001f)
		{
			float newSliderValue = levelListSlider->getValue() + scrollVelocity;
			if (newSliderValue > levelListSlider->getMax())
			{
				newSliderValue = levelListSlider->getMax();
				scrollVelocity = 0.f;
			}
			else if (newSliderValue < levelListSlider->getMin())
			{
				newSliderValue = levelListSlider->getMin();
				scrollVelocity = 0.f;
			}
			levelListSlider->setValue(newSliderValue);
			scrollVelocity *= 0.75f;
		}
	}

	levelListInnerContainer->setPosition(0.f, -levelListSlider->getValue());
	levelListInnerContainer->setSize(levelListContainer->getSize().x, levelListInnerContainer->getSize().y);

	if (dungeon != nullptr)
	{
		if (buttonAddLevel->isClicked())
		{
			std::size_t insertionIndex = hasSelectedLevel() ? getSelectedLevel() + 1 : dungeon->getLevelCount();
			dungeon->insertLevel(insertionIndex);

			updateDungeon();
			selectLevel(insertionIndex);
		}

		if (buttonRemoveLevel->isClicked())
		{
			if (hasSelectedLevel())
			{
				deleteConfirmMessage->show();
			}
		}

		if (deleteConfirmMessage->wasClosed() && deleteConfirmMessage->getClickedButton() == 0)
		{
			if (hasSelectedLevel())
			{
				dungeon->removeLevel(getSelectedLevel());

				updateDungeon();

				if (dungeon->getLevelCount() == 0)
				{
					deselectLevel();
				}
				else
				{
					selectLevel(selectedLevel == dungeon->getLevelCount() ? selectedLevel - 1 : selectedLevel);
				}
			}
		}

		if (buttonDuplicateLevel->isClicked())
		{
			if (hasSelectedLevel())
			{
				dungeon->insertLevel(getSelectedLevel());

				const Level & sourceLevel = dungeon->getLevel(getSelectedLevel() + 1);
				Level & destLevel = dungeon->getLevel(getSelectedLevel());
				destLevel.assign(sourceLevel);

				updateDungeon();
				selectLevel(getSelectedLevel() + 1);
			}
		}

		if (buttonMoveLevelUp->isClicked())
		{
			if (hasSelectedLevel() && getSelectedLevel() > 0)
			{
				dungeon->swapLevels(getSelectedLevel(), getSelectedLevel() - 1);

				updateDungeon();
				selectLevel(getSelectedLevel() - 1);
			}
		}

		if (buttonMoveLevelDown->isClicked())
		{
			if (hasSelectedLevel() && getSelectedLevel() < dungeon->getLevelCount() - 1)
			{
				dungeon->swapLevels(getSelectedLevel(), getSelectedLevel() + 1);

				updateDungeon();
				selectLevel(getSelectedLevel() + 1);
			}
		}
	}
}
コード例 #13
0
ofxSimpleGuiControl &ofxSimpleGuiControl::set2DSliderBGColor(bool clickable) {
	if(isMouseDown() || isMouseOver() || clickable) ofSetHexColor(config->fullActiveColor);
	else ofSetHexColor(config->emptyColor);
	return *this;
}
コード例 #14
0
void ofxSimpleGuiSliderBase<Type>::onDragOutside(int x, int y, int button) {
	if(isMouseDown() && !keyboardEdit && button == 0)
		updateSlider();
}
コード例 #15
0
ファイル: floatpane.cpp プロジェクト: chromylei/third_party
void wxAuiFloatingFrame::OnMoveEvent(wxMoveEvent& event)
{
    if (!m_solidDrag)
    {
        // systems without solid window dragging need to be
        // handled slightly differently, due to the lack of
        // the constant stream of EVT_MOVING events
        if (!isMouseDown())
            return;
        OnMoveStart();
        OnMoving(event.GetRect(), wxNORTH);
        m_moving = true;
        return;
    }


    wxRect winRect = GetRect();

    if (winRect == m_lastRect)
        return;

    // skip the first move event
    if (m_lastRect.IsEmpty())
    {
        m_lastRect = winRect;
        return;
    }

    // as on OSX moving windows are not getting all move events, only sporadically, this difference
    // is almost always big on OSX, so avoid this early exit opportunity
#ifndef __WXOSX__
    // skip if moving too fast to avoid massive redraws and
    // jumping hint windows
    if ((abs(winRect.x - m_lastRect.x) > 3) ||
        (abs(winRect.y - m_lastRect.y) > 3))
    {
        m_last3Rect = m_last2Rect;
        m_last2Rect = m_lastRect;
        m_lastRect = winRect;

        // However still update the internally stored position to avoid
        // snapping back to the old one later.
        if (m_ownerMgr)
        {
            m_ownerMgr->GetPane(m_paneWindow).
                floating_pos = winRect.GetPosition();
        }

        return;
    }
#endif

    // prevent frame redocking during resize
    if (m_lastRect.GetSize() != winRect.GetSize())
    {
        m_last3Rect = m_last2Rect;
        m_last2Rect = m_lastRect;
        m_lastRect = winRect;
        return;
    }

    wxDirection dir = wxALL;

    int horiz_dist = abs(winRect.x - m_last3Rect.x);
    int vert_dist = abs(winRect.y - m_last3Rect.y);

    if (vert_dist >= horiz_dist)
    {
        if (winRect.y < m_last3Rect.y)
            dir = wxNORTH;
        else
            dir = wxSOUTH;
    }
    else
    {
        if (winRect.x < m_last3Rect.x)
            dir = wxWEST;
        else
            dir = wxEAST;
    }

    m_last3Rect = m_last2Rect;
    m_last2Rect = m_lastRect;
    m_lastRect = winRect;

    if (!isMouseDown())
        return;

    if (!m_moving)
    {
        OnMoveStart();
        m_moving = true;
    }

    if (m_last3Rect.IsEmpty())
        return;

    if ( event.GetEventType() == wxEVT_MOVING )
        OnMoving(event.GetRect(), dir);
    else
        OnMoving(wxRect(event.GetPosition(),GetSize()), dir);
}
コード例 #16
0
ファイル: ofxSimpleGuiControl.cpp プロジェクト: amintz/M1.0
ofxSimpleGuiControl &ofxSimpleGuiControl::setFullColor(bool forceActive) {
	if(isMouseDown() || forceActive) ofSetHexColor(config->fullActiveColor);
	else if(isMouseOver()) ofSetHexColor(config->fullOverColor);
	else ofSetHexColor(config->fullColor);
	return *this;
}
コード例 #17
0
void wxAuiFloatingFrame::OnMoveEvent(wxMoveEvent& event)
{
    if (!m_solid_drag)
    {
        // systems without solid window dragging need to be
        // handled slightly differently, due to the lack of
        // the constant stream of EVT_MOVING events
        if (!isMouseDown())
            return;
        OnMoveStart();
        OnMoving(event.GetRect(), wxNORTH);
        m_moving = true;
        return;
    }


    wxRect win_rect = GetRect();

    if (win_rect == m_last_rect)
        return;

    // skip the first move event
    if (m_last_rect.IsEmpty())
    {
        m_last_rect = win_rect;
        return;
    }

    // skip if moving too fast to avoid massive redraws and
    // jumping hint windows
    if ((abs(win_rect.x - m_last_rect.x) > 3) ||
        (abs(win_rect.y - m_last_rect.y) > 3))
    {
        m_last3_rect = m_last2_rect;
        m_last2_rect = m_last_rect;
        m_last_rect = win_rect;
        return;
    }

    // prevent frame redocking during resize
    if (m_last_rect.GetSize() != win_rect.GetSize())
    {
        m_last3_rect = m_last2_rect;
        m_last2_rect = m_last_rect;
        m_last_rect = win_rect;
        return;
    }

    wxDirection dir = wxALL;

    int horiz_dist = abs(win_rect.x - m_last3_rect.x);
    int vert_dist = abs(win_rect.y - m_last3_rect.y);

    if (vert_dist >= horiz_dist)
    {
        if (win_rect.y < m_last3_rect.y)
            dir = wxNORTH;
        else
            dir = wxSOUTH;
    }
    else
    {
        if (win_rect.x < m_last3_rect.x)
            dir = wxWEST;
        else
            dir = wxEAST;
    }

    m_last3_rect = m_last2_rect;
    m_last2_rect = m_last_rect;
    m_last_rect = win_rect;

    if (!isMouseDown())
        return;

    if (!m_moving)
    {
        OnMoveStart();
        m_moving = true;
    }

    if (m_last3_rect.IsEmpty())
        return;

    OnMoving(event.GetRect(), dir);
}
コード例 #18
0
bool InputManager::isMouseLeftDown()
{
	return isMouseDown(OIS::MouseButtonID::MB_Left);
}
コード例 #19
0
bool InputManager::isMouseRightDown()
{
	return isMouseDown(OIS::MouseButtonID::MB_Right);
}
コード例 #20
0
ファイル: Strip.cpp プロジェクト: satoruhiga/ofxCvGui
			//----------
			void Strip::rebuildBorders() {
				if (this->handlesEnabled) {
					auto count = this->elements.size();
					
					for (int i = 0; i < count - 1; i++) {
						auto border = make_shared<Element>();
						auto borderWeak = weak_ptr<Element>(border);

						//generic draw
						border->onDraw += [borderWeak](DrawArguments & args) {
							auto border = borderWeak.lock();
							if (!border) {
								return;
							}

							ofPushStyle();
							{
								if (border->isMouseDown() || border->isMouseDragging()) {
									ofFill();
									ofSetLineWidth(0);
									ofSetColor(100);
									ofDrawRectangle(args.localBounds);
								} else if (border->isMouseOver()) {
									ofFill();
									ofSetLineWidth(0);
									ofSetColor(50);
									ofDrawRectangle(args.localBounds);

									ofxCvGui::Utils::drawToolTip("Resize", args.localBounds.getCenter());
								}
							}
							ofPopStyle();
						};

						//specific action (different movement)
						{
							auto action = [this, i, borderWeak](float movement, MouseArguments & mouseArgs) {
								auto border = borderWeak.lock();
								if (!border) {
									return;
								}

								mouseArgs.takeMousePress(border);

								if (mouseArgs.isDragging(border) && mouseArgs.button == 0) {
									auto prevCellHeight = this->getCellSize(i);
									auto nextCellHeight = this->getCellSize(i + 1);

									prevCellHeight += movement; //**
									nextCellHeight -= movement; //**

									bool prevIsAuto = this->programmaticCellSizes[i] == -1;
									bool nextIsAuto = this->programmaticCellSizes[i + 1] == -1;
									auto bothAreAuto = prevIsAuto && nextIsAuto;

									if (bothAreAuto || nextIsAuto) {
										this->setUserCellSize(i, prevCellHeight);
									}
									if (bothAreAuto || prevIsAuto) {
										this->setUserCellSize(i + 1, nextCellHeight);
									}
								}
							};
							if (this->direction == Direction::Horizontal) {
								border->onMouse += [action](MouseArguments & args) {
									action(args.movement.x, args);
								};
							}
							else {
								border->onMouse += [action](MouseArguments & args) {
									action(args.movement.y, args);
								};
							}
						}

						//generic action (reset)
						border->onMouseReleased += [this, borderWeak](MouseArguments & args) {
							if (args.button == 2) {
								this->resetUserCellSizes();
							}
						};
						this->borders->add(border);
					}
					this->layoutBorders();
				}
				else {
					this->borders->clear();
				}
			}
コード例 #21
0
ファイル: Widget.cpp プロジェクト: RedMser/NecroEdit
bool Widget::isMousePressing(const Input & button) const
{
	return isMouseOver() && isMouseDown(button);
}