Пример #1
0
unsigned DOMSelection::anchorOffset() const
{
    if (!m_frame)
        return 0;

    return shadowAdjustedOffset(anchorPosition(visibleSelection()));
}
Пример #2
0
Node* DOMSelection::anchorNode() const
{
    if (!m_frame)
        return 0;

    return shadowAdjustedNode(anchorPosition(visibleSelection()));
}
Пример #3
0
Range* DOMSelection::getRangeAt(int index, ExceptionState& exceptionState) {
    if (!isAvailable())
        return nullptr;

    if (index < 0 || index >= rangeCount()) {
        exceptionState.throwDOMException(
            IndexSizeError, String::number(index) + " is not a valid index.");
        return nullptr;
    }

    // If you're hitting this, you've added broken multi-range selection support
    DCHECK_EQ(rangeCount(), 1);

    Position anchor = anchorPosition(visibleSelection());
    if (!anchor.anchorNode()->isInShadowTree())
        return frame()->selection().firstRange();

    Node* node = shadowAdjustedNode(anchor);
    if (!node)  // crbug.com/595100
        return nullptr;
    if (!visibleSelection().isBaseFirst())
        return Range::create(*anchor.document(), focusNode(), focusOffset(), node,
                             anchorOffset());
    return Range::create(*anchor.document(), node, anchorOffset(), focusNode(),
                         focusOffset());
}
Node* DOMSelection::anchorNode() const
{
    if (!m_frame)
        return 0;
    if (Node* shadowAncestor = selectionShadowAncestor(m_frame))
        return shadowAncestor->parentNodeGuaranteedHostFree();
    return anchorPosition(visibleSelection()).containerNode();
}
int DOMSelection::anchorOffset() const
{
    if (!m_frame)
        return 0;
    if (Node* shadowAncestor = selectionShadowAncestor(m_frame))
        return shadowAncestor->nodeIndex();
    return anchorPosition(visibleSelection()).offsetInContainerNode();
}
Пример #6
0
int DOMSelection::anchorOffset() const
{
    if (!m_frame)
        return 0;
    if (Node* shadowAncestor = selectionShadowAncestor(m_frame))
        return shadowAncestor->nodeIndex();
    return anchorPosition(visibleSelection()).deprecatedEditingOffset();
}
Пример #7
0
void PlayerInventoryHud::CalculateInventoryCoordinates() {
	
	
	Vec2f anchorPos = anchorPosition();
	
	m_arrowsAnchor.x = anchorPos.x + (m_bagBackgroundSize.x * m_scale) - ((32 + 3)  * m_scale) ;
	m_arrowsAnchor.y = anchorPos.y + ((-3 + 25) * m_scale);
}
Пример #8
0
Node* DOMSelection::anchorNode() const
{
    if (!m_frame)
        return 0;
    if (Node* shadowAncestor = selectionShadowAncestor(m_frame))
        return shadowAncestor->parentNode();
    return anchorPosition(visibleSelection()).node();
}
Пример #9
0
Entity * PlayerInventoryHud::getObj(const Vec2s & pos) {
	
	Vec2f anchorPos = anchorPosition();
	
	Vec2i iPos = Vec2i(anchorPos);
	
	if(player.Interface & INTER_INVENTORY) {
		long tx = pos.x - iPos.x; //-4
		long ty = pos.y - iPos.y; //-2

		if(tx >= 0 && ty >= 0) {
			tx = checked_range_cast<long>(tx / (32 * m_scale));
			ty = checked_range_cast<long>(ty / (32 * m_scale));

			if((tx >= 0) && ((size_t)tx < INVENTORY_X) && (ty >= 0) && ((size_t)ty < INVENTORY_Y)) {
				Entity *result = inventory[g_currentInventoryBag][tx][ty].io;

				if(result && (result->gameFlags & GFLAG_INTERACTIVITY)) {
					HERO_OR_SECONDARY = 1;
					return result;
				}
			}

			return NULL;
		}
	} else if(player.Interface & INTER_INVENTORYALL) {

		float fBag	= (player.bag - 1) * (-121 * m_scale);

		int iY = checked_range_cast<int>(fBag);

		for(size_t bag = 0; bag < size_t(player.bag); bag++) {
			long tx = pos.x - iPos.x;
			long ty = pos.y - iPos.y - iY;

			tx = checked_range_cast<long>(tx / (32 * m_scale));
			ty = checked_range_cast<long>(ty / (32 * m_scale));

			if(tx >= 0 && (size_t)tx < INVENTORY_X && ty >= 0 && (size_t)ty < INVENTORY_Y) {
				Entity *result = inventory[bag][tx][ty].io;

				if(result && (result->gameFlags & GFLAG_INTERACTIVITY)) {
					HERO_OR_SECONDARY = 1;
					return result;
				}

				return NULL;
			}

			iY += checked_range_cast<int>((121 * m_scale));
		}
	}

	return NULL;
}
void MInputContextConnection::sendCommitString(const QString &string, int replaceStart,
                                          int replaceLength, int cursorPos) {

    const int cursorPosition(widgetState[CursorPositionAttribute].toInt());
    bool validAnchor(false);

    preedit.clear();

    if (replaceLength == 0  // we don't support replacement
        // we don't support selections
        && anchorPosition(validAnchor) == cursorPosition
        && validAnchor) {
        const int insertPosition(cursorPosition + replaceStart);
        if (insertPosition >= 0) {
            widgetState[SurroundingTextAttribute]
                = widgetState[SurroundingTextAttribute].toString().insert(insertPosition, string);
            widgetState[CursorPositionAttribute] = cursorPos < 0 ? (insertPosition + string.length()) : cursorPos;
            widgetState[AnchorPositionAttribute] = widgetState[CursorPositionAttribute];
        }
    }
}
Пример #11
0
PassRefPtrWillBeRawPtr<Range> DOMSelection::getRangeAt(int index, ExceptionState& exceptionState)
{
    if (!m_frame)
        return nullptr;

    if (index < 0 || index >= rangeCount()) {
        exceptionState.throwDOMException(IndexSizeError, String::number(index) + " is not a valid index.");
        return nullptr;
    }

    // If you're hitting this, you've added broken multi-range selection support
    ASSERT(rangeCount() == 1);

    Position anchor = anchorPosition(visibleSelection());
    if (!anchor.anchorNode()->isInShadowTree())
        return m_frame->selection().firstRange();

    if (!visibleSelection().isBaseFirst())
        return Range::create(*anchor.document(), focusNode(), focusOffset(), shadowAdjustedNode(anchor), anchorOffset());
    return Range::create(*anchor.document(), shadowAdjustedNode(anchor), anchorOffset(), focusNode(), focusOffset());
}
void MInputContextConnection::sendKeyEvent(const QKeyEvent &keyEvent,
                                           Maliit::EventRequestType requestType)
{
    if (requestType != Maliit::EventRequestSignalOnly
        && preedit.isEmpty()
        && keyEvent.key() == Qt::Key_Backspace
        && keyEvent.type() == QEvent::KeyPress) {
        QString surrString(widgetState[SurroundingTextAttribute].toString());
        const int cursorPosition(widgetState[CursorPositionAttribute].toInt());
        bool validAnchor(false);

        if (!surrString.isEmpty()
            && cursorPosition > 0
            // we don't support selections
            && anchorPosition(validAnchor) == cursorPosition
            && validAnchor) {
            widgetState[SurroundingTextAttribute] = surrString.remove(cursorPosition - 1, 1);
            widgetState[CursorPositionAttribute] = cursorPosition - 1;
            widgetState[AnchorPositionAttribute] = cursorPosition - 1;
        }
    }
}
Пример #13
0
bool PlayerInventoryHud::updateInput() {
	Vec2f anchorPos = anchorPosition();
	
	Vec2f pos = anchorPos + Vec2f((m_bagBackgroundSize.x * m_scale) - ((32 + 3) * m_scale), ((-3 + 25) * m_scale));
	
	bool bQuitCombine = true;
	
	if(g_currentInventoryBag > 0) {
		const Rect mouseTestRect(
		pos.x,
		pos.y,
		pos.x + (32 * m_scale),
		pos.y + (32 * m_scale)
		);
		
		if(mouseTestRect.contains(Vec2i(DANAEMouse)))
			bQuitCombine = false;
	}

	if(g_currentInventoryBag < player.bag-1) {
		float fRatio = (32 + 5) * m_scale;

		pos.y += checked_range_cast<int>(fRatio);
		
		const Rect mouseTestRect(
		pos.x,
		pos.y,
		pos.x + (32 * m_scale),
		pos.y + (32 * m_scale)
		);
		
		if(mouseTestRect.contains(Vec2i(DANAEMouse)))
			bQuitCombine = false;
	}
	
	return bQuitCombine;
}
Пример #14
0
/*!
 * \brief Returns true if xx,yy is a position in player inventory
 */
bool PlayerInventoryHud::containsPos(const Vec2s & pos) {
	Vec2f anchorPos = anchorPosition();
	
	Vec2s iPos = Vec2s(anchorPos);

	if(player.Interface & INTER_INVENTORY) {
		Vec2s t = pos - iPos;
		
		return InPlayerInventoryBag(t);
	} else if(player.Interface & INTER_INVENTORYALL) {
		float fBag = (player.bag - 1) * (-121 * m_scale);

		short iY = checked_range_cast<short>(fBag);

		if(   pos.x >= iPos.x
		   && pos.x <= iPos.x + INVENTORY_X * (32 * m_scale)
		   && pos.y >= iPos.y + iY
		   && pos.y <= g_size.height()
		) {
			return true;
		}

		for(int i = 0; i < player.bag; i++) {
			Vec2s t = pos - iPos;
			t.y -= iY;
			
			if(InPlayerInventoryBag(t))
				return true;
			
			float fRatio	= (121 * m_scale);

			iY = checked_range_cast<short>(iY + fRatio);
		}
	}

	return false;
}
Пример #15
0
int DOMSelection::anchorOffset() const {
    if (!isAvailable())
        return 0;

    return shadowAdjustedOffset(anchorPosition(visibleSelection()));
}
Пример #16
0
void PlayerInventoryHud::draw() {
	if(player.Interface & INTER_INVENTORY) {		
		if(player.bag) {
			ARX_INTERFACE_DrawInventory(g_currentInventoryBag, Vec2i_ZERO);
			
			CalculateInventoryCoordinates();
			
			if(g_currentInventoryBag > 0) {
				Rectf rect = Rectf(m_arrowsAnchor, 32.f * m_scale, 32.f * m_scale);
				
				EERIEDrawBitmap(rect, 0.001f, m_heroInventoryUp, Color::white);
				
				if(rect.contains(Vec2f(DANAEMouse))) {
					GRenderer->SetBlendFunc(Renderer::BlendOne, Renderer::BlendOne);
					GRenderer->SetRenderState(Renderer::AlphaBlending, true);
					SpecialCursor=CURSOR_INTERACTION_ON;
					
					EERIEDrawBitmap(rect, 0.001f, m_heroInventoryUp, Color::white);
					
					GRenderer->SetRenderState(Renderer::AlphaBlending, false);
					SpecialCursor=CURSOR_INTERACTION_ON;
					
					if(eeMouseDown1() || (eeMouseUp1() && DRAGINTER)) {
						previousBag();
					}
				}
			}
			
			if(g_currentInventoryBag < player.bag-1) {
				Rectf rect = Rectf(m_arrowsAnchor + Vec2f(0.f, 32.f + 5.f) * m_scale, 32.f * m_scale, 32.f * m_scale);
				
				EERIEDrawBitmap(rect, 0.001f, m_heroInventoryDown, Color::white);
				
				if(rect.contains(Vec2f(DANAEMouse))) {
					GRenderer->SetBlendFunc(Renderer::BlendOne, Renderer::BlendOne);
					GRenderer->SetRenderState(Renderer::AlphaBlending, true);
					
					EERIEDrawBitmap(rect, 0.001f, m_heroInventoryDown, Color::white);
					
					GRenderer->SetRenderState(Renderer::AlphaBlending, false);
					SpecialCursor=CURSOR_INTERACTION_ON;
					
					if(eeMouseDown1() || (eeMouseUp1() && DRAGINTER)) {
						nextBag();
					}
				}
			}
		}
	} else if((player.Interface & INTER_INVENTORYALL) || bInventoryClosing) {				
		
		Vec2f anchorPos = anchorPosition();
		
		//TODO see about these coords, might be calculated once only
		const float fBag = (player.bag-1) * (-121 * m_scale);
		const float fOffsetY = (121 * m_scale);
		
		int iOffsetY = checked_range_cast<int>(fBag + fOffsetY);
		int posx = checked_range_cast<int>(anchorPos.x);
		int posy = checked_range_cast<int>(anchorPos.y + ((-3.f + 25 - 32) * m_scale));
		
		for(int i = 0; i < player.bag; i++) {
			Vec2f pos1 = Vec2f(posx + (45 * m_scale), static_cast<float>(posy + iOffsetY));
			Vec2f pos2 = Vec2f(posx + (m_bagBackgroundSize.x * m_scale)*0.5f + (-16 * m_scale), posy+iOffsetY + (-5 * m_scale));
			Vec2f pos3 = Vec2f(posx + (m_bagBackgroundSize.x * m_scale) + ((-45-32) * m_scale), posy+iOffsetY + (-15 * m_scale));
			
			TextureContainer * tex = m_heroInventoryLink;
			
			EERIEDrawBitmap(Rectf(pos1, tex->m_size.x, tex->m_size.y), 0.001f, tex, Color::white);
			EERIEDrawBitmap(Rectf(pos2, tex->m_size.x, tex->m_size.y), 0.001f, tex, Color::white);
			EERIEDrawBitmap(Rectf(pos3, tex->m_size.x, tex->m_size.y), 0.001f, tex, Color::white);
			
			iOffsetY += checked_range_cast<int>(fOffsetY);
		}
		
		iOffsetY = checked_range_cast<int>(fBag);
		
		for(short i = 0; i < player.bag; i++) {
			ARX_INTERFACE_DrawInventory(i, Vec2i(0, iOffsetY));
			iOffsetY += checked_range_cast<int>(fOffsetY);
		}
	}
}
Пример #17
0
//-----------------------------------------------------------------------------
void PlayerInventoryHud::ARX_INTERFACE_DrawInventory(size_t bag, Vec2i i)
{
	fDecPulse += framedelay * 0.5f;
	
	Vec2f anchorPos = anchorPosition();
	
	const Vec2f pos = anchorPos + Vec2f(i.x, i.y);
	
	Rectf rect = Rectf(pos + Vec2f(0.f, -(5 * m_scale)), m_bagBackgroundSize.x * m_scale, m_bagBackgroundSize.y * m_scale);
	EERIEDrawBitmap(rect, 0.001f, m_heroInventory, Color::white);
	
	for(size_t y = 0; y < INVENTORY_Y; y++) {
	for(size_t x = 0; x < INVENTORY_X; x++) {
		Entity *io = inventory[bag][x][y].io;
		
		if(!io || !inventory[bag][x][y].show)
			continue;
		
		TextureContainer *tc = io->inv;
		TextureContainer *tc2 = NULL;
		
		if(NeedHalo(io))
			tc2 = io->inv->getHalo();
		
		if(!tc)
			continue;
		
		const Vec2f p = pos + Vec2f(x, y) * (m_slotSize * m_scale) + (m_slotSpacing * m_scale);
		
		Color color = (io->poisonous && io->poisonous_count != 0) ? Color::green : Color::white;
		
		Rectf rect(p, tc->m_size.x * m_scale, tc->m_size.y * m_scale);
		// TODO use alpha blending so this will be anti-aliased even w/o alpha to coverage
		EERIEDrawBitmap(rect, 0.001f, tc, color);
		
		Color overlayColor = Color::black;
		
		if(io == FlyingOverIO)
			overlayColor = Color::white;
		else if(io->ioflags & IO_CAN_COMBINE)
			overlayColor = Color3f::gray(glm::abs(glm::cos(glm::radians(fDecPulse)))).to<u8>();
		
		
		if(overlayColor != Color::black) {
			GRenderer->SetBlendFunc(Renderer::BlendSrcAlpha, Renderer::BlendOne);
			GRenderer->SetRenderState(Renderer::AlphaBlending, true);
			
			EERIEDrawBitmap(rect, 0.001f, tc, overlayColor);
			
			GRenderer->SetRenderState(Renderer::AlphaBlending, false);
		}
		
		if(tc2) {
			ARX_INTERFACE_HALO_Render(io->halo.color, io->halo.flags, tc2, p, Vec2f(m_scale));
		}
		
		if((io->ioflags & IO_ITEM) && io->_itemdata->count != 1)
			ARX_INTERFACE_DrawNumber(p, io->_itemdata->count, 3, Color::white, m_scale);
	}
	}
}