unsigned DOMSelection::baseOffset() const
{
    if (!m_frame)
        return 0;

    return shadowAdjustedOffset(basePosition(visibleSelection()));
}
Node* DOMSelection::baseNode() const
{
    if (!m_frame)
        return 0;

    return shadowAdjustedNode(basePosition(visibleSelection()));
}
int DOMSelection::baseOffset() const
{
    if (!m_frame)
        return 0;
    if (Node* shadowAncestor = selectionShadowAncestor(m_frame))
        return shadowAncestor->nodeIndex();
    return basePosition(visibleSelection()).deprecatedEditingOffset();
}
Node* DOMSelection::baseNode() const
{
    if (!m_frame)
        return 0;
    if (Node* shadowAncestor = selectionShadowAncestor(m_frame))
        return shadowAncestor->parentNode();
    return basePosition(visibleSelection()).node();
}
int DOMSelection::baseOffset() const
{
    if (!m_frame)
        return 0;
    if (Node* shadowAncestor = selectionShadowAncestor(m_frame))
        return shadowAncestor->nodeIndex();
    return basePosition(visibleSelection()).offsetInContainerNode();
}
Node* DOMSelection::baseNode() const
{
    if (!m_frame)
        return 0;
    if (Node* shadowAncestor = selectionShadowAncestor(m_frame))
        return shadowAncestor->parentNodeGuaranteedHostFree();
    return basePosition(visibleSelection()).containerNode();
}
Example #7
0
int DOMSelection::baseOffset() const {
    if (!isAvailable())
        return 0;

    return shadowAdjustedOffset(basePosition(visibleSelection()));
}
Example #8
0
Node* DOMSelection::baseNode() const {
    if (!isAvailable())
        return 0;

    return shadowAdjustedNode(basePosition(visibleSelection()));
}
void ClangAssistProposal::makeCorrection(TextEditor::TextEditorWidget *editorWidget)
{
    editorWidget->setCursorPosition(basePosition() - 1);
    editorWidget->replace(1, QLatin1String("->"));
    moveBasePosition(1);
}
Example #10
0
void CloudsIntroSequence::drawHelperType(){

	ofPushStyle();
	glDisable(GL_DEPTH_TEST);
	ofDisableLighting();
    
	if(!helperFont.isLoaded() || currentHelperFontSize != helperFontSize){
		//helperFont.loadFont(GetCloudsDataPath() + "font/Blender-BOOK.ttf", helperFontSize);
#ifdef OCULUS_RIFT
		helperFont.loadFont(GetFontPath(), helperFontSize-2	); //hack!
#else
		helperFont.loadFont(GetFontPath(), helperFontSize	); //hack!
#endif		
		currentHelperFontSize = helperFontSize;
	}

	string helpHoverText;
	ofVec3f basePosition(0,0,0);
	float helperTextOpacity = 0.0;
	float scaleModifier = 1.0;// * ofGetMouseX() / ofGetWidth();

	
	#ifdef OCULUS_RIFT
	if(!startedOnclick){
		if(introNodeThree.hover || introNodeTwo.finished){
			helpHoverText = "< " + GetTranslationForString("LOOK CENTER");
			basePosition = introNodeTwo.worldPosition;
			helperTextOpacity = powf(ofMap(ofGetElapsedTimef(),
										   CalibrationNode::nodeActivatedTime,
										   CalibrationNode::nodeActivatedTime+.8,0.0,.8,true), 2.) * (1.0 - introNodeThree.percentComplete);
		}
		else if(introNodeTwo.hover || introNodeOne.finished){
			helpHoverText = GetTranslationForString("LOOK RIGHT") + " >";
			basePosition = introNodeOne.worldPosition;
			helperTextOpacity = powf(ofMap(ofGetElapsedTimef(),
										   CalibrationNode::nodeActivatedTime,
										   CalibrationNode::nodeActivatedTime+.8,0.0,.8,true), 2.);
		}
		else {
			helpHoverText = "< " + GetTranslationForString("LOOK LEFT");
			basePosition = introNodeThree.worldPosition;
			helperTextOpacity = (currentTitleOpacity - titleTypeOpacity) * (1.0 - introNodeOne.percentComplete);
		}
		helperFont.setLetterSpacing(helperFontTracking);
	}

	#endif
	
	if(caughtQuestion != NULL){
		basePosition = caughtQuestion->hoverPosition;
		helpHoverText = GetTranslationForString( caughtQuestion->question );
		helperTextOpacity = ofMap(caughtQuestion->hoverPercentComplete, 0.0, .05, 0.0, 1.0, true);

		scaleModifier = .5;
		helperFont.setLetterSpacing(helperFontTracking*.1);
	}

    //draw the text
	if(helpHoverText != ""){
        ofPushMatrix();
		helpHoverText = ofToUpper(helpHoverText);
		
		float hoverTextWidth = helperFont.stringWidth(helpHoverText);
		float hoverTextWidth2,questionTextHeight2;
		string secondLine;
		bool twoLines = hoverTextWidth > 500;
		if(helpHoverText.find("\n") != string::npos){
			twoLines = true;
			vector<string> split = ofSplitString(helpHoverText, "\n", true,true);
			helpHoverText = split[0];
			secondLine = split[1];
			hoverTextWidth = helperFont.stringWidth(helpHoverText);
			hoverTextWidth2 = helperFont.stringWidth(secondLine);
            
//            cout << "QUESTION " << helpHoverText << " " << secondLine << endl;
		}
		else if(twoLines){
			vector<string> pieces = ofSplitString(helpHoverText, " ", true,true);
			vector<string> firstHalf;
			vector<string> secondHalf;
			int halfsize = pieces.size() / 2;
			firstHalf.insert(firstHalf.begin(), pieces.begin(), pieces.begin() + halfsize);
			secondHalf.insert(secondHalf.begin(), pieces.begin() + halfsize, pieces.end());
			helpHoverText = ofJoinString(firstHalf, " ");
			secondLine = ofJoinString(secondHalf, " ");
			hoverTextWidth  = helperFont.stringWidth(helpHoverText);
			hoverTextWidth2 = helperFont.stringWidth(secondLine);
		}
		float hoverTextHeight = helperFont.stringHeight(helpHoverText);
		
        //basePosition = ofVec3f(0,0,warpCamera.getPosition().z + questionZStopRange.max);

		#ifdef OCULUS_RIFT
		getOculusRift().multBillboardMatrix( basePosition );
		#else
		ofTranslate(basePosition);
		#endif
		ofRotate(180, 0, 0, 1); //flip around
		ofScale(scaleModifier*helperFontScale,
				scaleModifier*helperFontScale,
				scaleModifier*helperFontScale);
		
		ofSetColor(255,255*helperTextOpacity);
		
        bool showAbove = !bUseOculusRift && caughtQuestion != NULL && caughtQuestion->tunnelQuadrantIndex == 2;
		int yOffsetMult = (showAbove) ? -1 : 1;
		//helperFont.drawString(helpHoverText, -hoverTextWidth/2, yOffsetMult * (helperFontY - hoverTextHeight/2) );
        
//        cout << "helper text opacity " << helperTextOpacity << endl;
//        cout << "helper font y " << helperFontY << endl;
		if(twoLines){
            if(showAbove){
//                cout << "drawing " << helpHoverText << " w " << hoverTextWidth << " h " <<  helperFontY + hoverTextHeight*1.5 << endl;
//                cout << "drawing " << secondLine << " w " << hoverTextWidth << " h " << hoverTextHeight << endl;
                helperFont.drawString(helpHoverText, -hoverTextWidth*.5, yOffsetMult * (helperFontY + hoverTextHeight*1.5) );
                helperFont.drawString(secondLine, -hoverTextWidth2*.5, yOffsetMult * (helperFontY - hoverTextHeight*.5));
            }
            else{
//                cout << "drawing " << secondLine << " w " << hoverTextWidth << " h " <<  hoverTextHeight << endl;
//                cout << "drawing " << helpHoverText << " w " << hoverTextWidth << " h " << hoverTextHeight << endl;
                helperFont.drawString(secondLine, -hoverTextWidth2*.5, yOffsetMult * (helperFontY + hoverTextHeight*1.5) );
                helperFont.drawString(helpHoverText, -hoverTextWidth*.5, yOffsetMult * (helperFontY - hoverTextHeight*.5));
            }
		}
        else{
            helperFont.drawString(helpHoverText, -hoverTextWidth*.5, yOffsetMult * (helperFontY - hoverTextHeight*.5));
        }
		ofPopMatrix();
	}
    
    if(firstQuestionStopped){
        ofPushMatrix();
        
        float questionhintAlpha = ofMap(ofGetElapsedTimef(),
                                        firstQuestionStoppedTime, firstQuestionStoppedTime+2,
                                        0.0, .2, true) * (1.0-helperTextOpacity);
        
        float hintTextWidth  = helperFont.stringWidth(GetTranslationForString("SELECT A QUESTION"));
		float hintTextHeight = helperFont.stringHeight(GetTranslationForString("SELECT A QUESTION"));
		basePosition = ofVec3f(0,0,warpCamera.getPosition().z + questionZStopRange.max);
#ifdef OCULUS_RIFT
		getOculusRift().multBillboardMatrix( basePosition );
#else
		ofTranslate(basePosition);
#endif
		ofRotate(180, 0, 0, 1); //flip around
		ofScale(helperFontScale*.8,
				helperFontScale*.8,
				helperFontScale*.8);
        
        ofSetColor(255, 255*questionhintAlpha);
		helperFont.drawString(GetTranslationForString("SELECT A QUESTION"), -hintTextWidth*.5, hintTextHeight*.5 );

        if(caughtQuestion != NULL){
            float questionHoldAlpha = ofMap(caughtQuestion->hoverPercentComplete, .2, .3, 0.0, .2, true);
            ofSetColor(255, 255*questionHoldAlpha);
#ifdef MOUSE_INPUT
//			string textPrompt = GetTranslationForString("CLICK TO SELECT");
            string textPrompt = GetTranslationForString("");
#else
			string textPrompt = GetTranslationForString("HOLD TO SELECT");
#endif
            hintTextWidth = helperFont.stringWidth(textPrompt);
            hintTextHeight = helperFont.stringWidth(textPrompt);
            helperFont.drawString(textPrompt, -hintTextWidth*.5, hintTextHeight*.5 );
        }
        
        ofPopMatrix();
    }

    ofEnableLighting();
	glEnable(GL_DEPTH_TEST);
	ofPopStyle();

}