void MGuiSlide::draw(void) { MRenderingContext * render = MGui::getInstance()->getRenderingContext(); if(! isVisible()) return; if(! isPressed()) updateFromVariable(); if(isPressed()) // pressed { render->setColor4(getPressedColor()); if(hasPressedTexture()) { render->enableTexture(); m_button.drawTexturedQuad(getPressedTexture()); } else { render->disableTexture(); m_button.drawQuad(); } } else if(isHighLight()) // highLight { render->setColor4(getHighLightColor()); if(hasHighLightTexture()){ render->enableTexture(); m_button.drawTexturedQuad(getHighLightTexture()); } else { render->disableTexture(); m_button.drawQuad(); } } else // normal { render->setColor4(getNormalColor()); if(hasNormalTexture()) { render->enableTexture(); m_button.drawTexturedQuad(getNormalTexture()); } else { render->disableTexture(); m_button.drawQuad(); } } MGuiEvent guiEvent; guiEvent.type = MGUI_EVENT_DRAW; if(m_pointerEvent) m_pointerEvent(this, &guiEvent); }
// Play the color and sound for a pressed button until the button is released void playPressedButtonColorAndSound() { // Grab first color pressed by the user int pressedColor = getPressedColor(); // Light corresponding light lightUpColor(pressedColor); // Loop until the user releases that button while (isPressed(pressedColor)) { playSoundForColor(pressedColor); updateButtonStates(); } noTone(SPEAKER_PIN); clearLights(); }
void MGuiEditText::draw(void) { MRenderingContext * render = MGui::getInstance()->getRenderingContext(); if(! isVisible()) return; if(! isPressed()) updateFromVariable(); // draw selection if(isPressed()) { render->disableTexture(); render->setColor4(MVector4(1, 0.1f, 0.1f, 0.3f)); getFont()->drawSelection(getText(), getPosition(), getTextSize(), m_startSelectionId, m_endSelectionId); } // set text color if(isPressed()){ render->setColor4(getPressedColor()); } else if(isHighLight()){ render->setColor4(getHighLightColor()); } else{ render->setColor4(getNormalColor()); } // draw text render->enableTexture(); getFont()->draw(getText(), getPosition(), getTextSize()); if(isPressed() && (m_startSelectionId == m_endSelectionId)) // cursor { render->disableTexture(); render->setColor4(MVector4(1, 0, 0, 0.5f)); // position MVector2 position = getFont()->getCharacterPosition( getText(), getPosition(), getTextSize(), getCharId() ); // scale MVector2 scale = MVector2(getTextSize() * 0.1f, getTextSize()); float offset = (getTextSize() - (getTextSize()*getFont()->getSpace()))*0.5f; float px = (float)((int)(position.x + offset)); float py = (float)((int)position.y); // draw render->disableNormalArray(); render->disableTexCoordArray(); render->disableColorArray(); render->enableVertexArray(); MVector2 vertices[4] = { MVector2(px, py), MVector2(px, py + scale.y), MVector2(px + scale.x, py), MVector2(px + scale.x, py + scale.y) }; render->setVertexPointer(M_FLOAT, 2, vertices); render->drawArray(M_PRIMITIVE_TRIANGLE_STRIP, 0, 4); } MGuiEvent guiEvent; guiEvent.type = MGUI_EVENT_DRAW; if(m_pointerEvent) m_pointerEvent(this, &guiEvent); }
void MGui2d::draw(void) { MRenderingContext * render = MGui::getInstance()->getRenderingContext(); if(! isVisible()) return; if(isPressed()) // pressed { render->setColor4(getPressedColor()); if(hasPressedTexture()) { render->enableTexture(); drawTexturedQuad(getPressedTexture()); } else { render->disableTexture(); drawQuad(); } } else if(isHighLight()) // highLight { render->setColor4(getHighLightColor()); if(hasHighLightTexture()){ render->enableTexture(); drawTexturedQuad(getHighLightTexture()); } else { render->disableTexture(); drawQuad(); } } else // normal { render->setColor4(getNormalColor()); if(hasNormalTexture()) { render->enableTexture(); drawTexturedQuad(getNormalTexture()); } else { render->disableTexture(); drawQuad(); } } if(isDrawingText() && (getText() != NULL)) { render->enableTexture(); render->setColor4(getTextColor()); getFont()->draw(getText(), getPosition(), getTextSize()); } // draw shadows if(hasShadow()) { render->pushMatrix(); render->translate(MVector3(getPosition().x, getPosition().y, 0)); drawShadow(); render->popMatrix(); } }
QString getStyleSheetExtra() { QString output; output+="QPushButton:checked{color: "+getPressedTextColor()+";background-color: "+getPressedColor()+";"; output+="border-style: solid;border-radius: 0px;border: 2px solid "+getBackgroundColor()+";}"; return output; }
QString getStyleSheet() { QString output; output+="QPushButton{color: "+getTextColor()+";background-color: "+getFrontColor()+";"; output+="border-style: solid;border-radius: 0px;border: 2px solid "+getBackgroundColor()+";}"; output+="QPushButton:hover{color: "+getTextColor()+";background-color: "+getHoveredColor()+";"; output+="border-style: solid;border-radius: 0px;border: 2px solid "+getBackgroundColor()+";}"; output+="QPushButton:pressed{color: "+getPressedTextColor()+";background-color: "+getPressedColor()+";"; output+="border-style: solid;border-radius: 0px;border: 2px solid "+getBackgroundColor()+";}"; return output; }