void FalagardCheckButton::drawCheck() { ColourRect colours(d_selectImage.getColours()); colours.setAlpha(getEffectiveAlpha()); d_selectImage.setColours(colours); d_selectImage.draw(d_renderCache); }
void FrameWindow::populateRenderCache() { Rect unclipped_rect = getUnclippedPixelRect(); Rect rect(Point(0.0f, 0.0f), Size(unclipped_rect.getWidth(), unclipped_rect.getHeight())); ColourRect colours(Colour(1.0f, 1.0f, 1.0f, getEffectiveAlpha())); if (d_section_images[TopLeft]) d_renderCache.cacheImage(*d_section_images[TopLeft], Rect(Point(0.0f, 0.0f), Size(d_width_left, d_height_top)), colours); if (d_section_images[TopMiddle]) d_renderCache.cacheImage(*d_section_images[TopMiddle], Rect(Point(d_width_left, 0.0f), Size(d_width_middle, d_height_top)), colours); if (d_section_images[TopRight]) d_renderCache.cacheImage(*d_section_images[TopRight], Rect(Point(d_width_left + d_width_middle, 0.0f), Size(d_width_right, d_height_top)), colours); if (d_section_images[MiddleLeft]) d_renderCache.cacheImage(*d_section_images[MiddleLeft], Rect(Point(0.0f, d_height_top), Size(d_width_left, d_height_middle)), colours); if (d_section_images[MiddleMiddle]) d_renderCache.cacheImage(*d_section_images[MiddleMiddle], Rect(Point(d_width_left, d_height_top), Size(d_width_middle, d_height_middle)), colours); if (d_section_images[MiddleRight]) d_renderCache.cacheImage(*d_section_images[MiddleRight], Rect(Point(d_width_left + d_width_middle, d_height_top), Size(d_width_right, d_height_middle)), colours); if (d_section_images[BottomLeft]) d_renderCache.cacheImage(*d_section_images[BottomLeft], Rect(Point(0.0f, d_height_top + d_height_middle), Size(d_width_left, d_height_bottom)), colours); if (d_section_images[BottomMiddle]) d_renderCache.cacheImage(*d_section_images[BottomMiddle], Rect(Point(d_width_left, d_height_top + d_height_middle), Size(d_width_middle, d_height_bottom)), colours); if (d_section_images[BottomRight]) d_renderCache.cacheImage(*d_section_images[BottomRight], Rect(Point(d_width_left + d_width_middle, d_height_top + d_height_middle), Size(d_width_right, d_height_bottom)), colours); }
/************************************************************************* Perform the actual rendering for this Window. *************************************************************************/ void Static::populateRenderCache() { Rect backgroundRect(Point(0,0), getAbsoluteSize()); // draw frame if (d_frameEnabled) { d_frame.draw(d_renderCache); // adjust destination area for backfrop image. backgroundRect.d_left += d_left_width; backgroundRect.d_right -= d_right_width; backgroundRect.d_top += d_top_height; backgroundRect.d_bottom -= d_bottom_height; } // draw backdrop if (d_backgroundEnabled && (d_background != NULL)) { // factor window alpha into colours to use when rendering background ColourRect colours(d_backgroundCols); colours.modulateAlpha(getEffectiveAlpha()); // cache image for drawing d_renderCache.cacheImage(*d_background, backgroundRect, 0, colours); } }
void FalagardAnimate::drawNormal(float z) { if( m_bPlay ) { ColourRect colours(d_normalImage.getColours()); colours.setAlpha(getEffectiveAlpha() * m_fAlpha ); d_normalImage.setColours(colours); d_normalImage.draw(d_renderCache); } }
/************************************************************************* Perform the actual rendering for this Window. *************************************************************************/ void Listbox::populateRenderCache() { // get the derived class to render general stuff before we handle the items cacheListboxBaseImagery(); // // Render list items // Vector3 itemPos; Size itemSize; Rect itemClipper, itemRect; float widest = getWidestItemWidth(); // calculate position of area we have to render into Rect itemsArea(getListRenderArea()); // set up some initial positional details for items itemPos.d_x = itemsArea.d_left - d_horzScrollbar->getScrollPosition(); itemPos.d_y = itemsArea.d_top - d_vertScrollbar->getScrollPosition(); itemPos.d_z = System::getSingleton().getRenderer()->getZLayer(3) - System::getSingleton().getRenderer()->getCurrentZ(); float alpha = getEffectiveAlpha(); // loop through the items size_t itemCount = getItemCount(); for (size_t i = 0; i < itemCount; ++i) { itemSize.d_height = d_listItems[i]->getPixelSize().d_height; // allow item to have full width of box if this is wider than items itemSize.d_width = ceguimax(itemsArea.getWidth(), widest); // calculate destination area for this item. itemRect.d_left = itemPos.d_x; itemRect.d_top = itemPos.d_y; itemRect.setSize(itemSize); itemClipper = itemRect.getIntersection(itemsArea); // skip this item if totally clipped if (itemClipper.getWidth() == 0) { itemPos.d_y += itemSize.d_height; continue; } // draw this item d_listItems[i]->draw(d_renderCache, itemRect, itemPos.d_z, alpha, &itemClipper); // update position ready for next item itemPos.d_y += itemSize.d_height; } }
/************************************************************************* update the internal RenderableFrame with currently set colours and alpha settings. *************************************************************************/ void Static::updateRenderableFrameColours(void) { float alpha = getEffectiveAlpha(); d_frame.setColours( calculateModulatedAlphaColour(d_frameCols.d_top_left, alpha), calculateModulatedAlphaColour(d_frameCols.d_top_right, alpha), calculateModulatedAlphaColour(d_frameCols.d_bottom_left, alpha), calculateModulatedAlphaColour(d_frameCols.d_bottom_right, alpha) ); }
/************************************************************************* Perform the actual rendering for this Window. *************************************************************************/ void Tree::populateGeometryBuffer() { // get the derived class to render general stuff before we handle the items cacheTreeBaseImagery(); // Render list items Vector2f itemPos; float widest = getWidestItemWidth(); // calculate position of area we have to render into //Rect itemsArea(getTreeRenderArea()); //Rect itemsArea(0,0,500,500); // set up some initial positional details for items itemPos.d_x = d_itemArea.left() - d_horzScrollbar->getScrollPosition(); itemPos.d_y = d_itemArea.top() - d_vertScrollbar->getScrollPosition(); drawItemList(d_listItems, d_itemArea, widest, itemPos, *d_geometry, getEffectiveAlpha()); }
void FalagardEditbox::populateRenderCache() { const StateImagery* imagery; // draw container etc // get WidgetLookFeel for the assigned look. const WidgetLookFeel& wlf = WidgetLookManager::getSingleton().getWidgetLook(d_lookName); // try and get imagery for the approprite state. imagery = &wlf.getStateImagery(isDisabled() ? "Disabled" : (isReadOnly() ? "ReadOnly" : "Enabled")); // peform the rendering operation for the container. imagery->render(*this); // get destination area for text const Rect textArea(wlf.getNamedArea("TextArea").getArea().getPixelRect(*this)); // // Required preliminary work for text rendering operations // const Font* font = getFont(); // no font == no more rendering if (!font) return; // This will point to the final string to be used for rendering. Useful because it means we // do not have to have duplicate code or be copying d_text for handling masked/unmasked text. String* editText; // Create a 'masked' version of the string if needed. String maskedText; if (isTextMasked()) { maskedText.insert(0, d_text.length(), getMaskCodePoint()); editText = &maskedText; } // text not masked to editText will be the windows d_text String. else { editText = &d_text; } // calculate best position to render text to ensure carat is always visible float textOffset; float extentToCarat = font->getTextExtent(editText->substr(0, getCaratIndex())); // get carat imagery const ImagerySection& caratImagery = wlf.getImagerySection("Carat"); // store carat width float caratWidth = caratImagery.getBoundingRect(*this, textArea).getWidth(); // if box is inactive if (!hasInputFocus()) { textOffset = d_lastTextOffset; } // if carat is to the left of the box else if ((d_lastTextOffset + extentToCarat) < 0) { textOffset = -extentToCarat; } // if carat is off to the right. else if ((d_lastTextOffset + extentToCarat) >= (textArea.getWidth() - caratWidth)) { textOffset = textArea.getWidth() - extentToCarat - caratWidth; } // else carat is already within the box else { textOffset = d_lastTextOffset; } ColourRect colours; float alpha_comp = getEffectiveAlpha(); // // Draw label text // // setup initial rect for text formatting Rect text_part_rect(textArea); // allow for scroll position text_part_rect.d_left += textOffset; // centre text vertically within the defined text area text_part_rect.d_top += (textArea.getHeight() - font->getLineSpacing()) * 0.5f; // draw pre-highlight text String sect = editText->substr(0, getSelectionStartIndex()); colours.setColours(d_normalTextColour); colours.modulateAlpha(alpha_comp); d_renderCache.cacheText(sect, font, LeftAligned, text_part_rect, 0, colours, &textArea); // adjust rect for next section text_part_rect.d_left += font->getTextExtent(sect); // draw highlight text sect = editText->substr(getSelectionStartIndex(), getSelectionLength()); colours.setColours(d_selectTextColour); colours.modulateAlpha(alpha_comp); d_renderCache.cacheText(sect, font, LeftAligned, text_part_rect, 0, colours, &textArea); // adjust rect for next section text_part_rect.d_left += font->getTextExtent(sect); // draw post-highlight text sect = editText->substr(getSelectionEndIndex()); colours.setColours(d_normalTextColour); colours.modulateAlpha(alpha_comp); d_renderCache.cacheText(sect, font, LeftAligned, text_part_rect, 0, colours, &textArea); // remember this for next time. d_lastTextOffset = textOffset; // see if the editbox is active or inactive. bool active = (!isReadOnly()) && hasInputFocus(); // // Render selection imagery. // if (getSelectionLength() != 0) { // calculate required start and end offsets of selection imagery. float selStartOffset = font->getTextExtent(editText->substr(0, getSelectionStartIndex())); float selEndOffset = font->getTextExtent(editText->substr(0, getSelectionEndIndex())); // calculate area for selection imagery. Rect hlarea(textArea); hlarea.d_left += textOffset + selStartOffset; hlarea.d_right = hlarea.d_left + (selEndOffset - selStartOffset); // render the selection imagery. wlf.getStateImagery(active ? "ActiveSelection" : "InactiveSelection").render(*this, hlarea, 0, &textArea); } // // Render carat // if (active) { Rect caratRect(textArea); caratRect.d_left += extentToCarat + textOffset; caratImagery.render(*this, caratRect, 0, 0, &textArea); } }
/************************************************************************* Render text lines. *************************************************************************/ void MultiLineEditbox::cacheTextLines(const Rect& dest_area) { // text is already formatted, we just grab the lines and render them with the required alignment. Rect drawArea(dest_area); drawArea.offset(Point(-d_horzScrollbar->getScrollPosition(), -d_vertScrollbar->getScrollPosition())); Renderer* renderer = System::getSingleton().getRenderer(); const Font* fnt = getFont(); if (fnt) { // get layers to use for rendering float textZ = renderer->getZLayer(4) - renderer->getCurrentZ(); float selZ = renderer->getZLayer(3) - renderer->getCurrentZ(); // calculate final colours to use. ColourRect colours; float alpha = getEffectiveAlpha(); colour normalTextCol = d_normalTextColour; normalTextCol.setAlpha(normalTextCol.getAlpha() * alpha); colour selectTextCol = d_selectTextColour; selectTextCol.setAlpha(selectTextCol.getAlpha() * alpha); colour selectBrushCol = hasInputFocus() ? d_selectBrushColour : d_inactiveSelectBrushColour; selectBrushCol.setAlpha(selectBrushCol.getAlpha() * alpha); // Cache font info const float fLineSpacing = fnt->getLineSpacing (); // for each formatted line. for (size_t i = 0; i < d_lines.size(); ++i) { Rect lineRect(drawArea); // Check line is within the dest_area if ( lineRect.d_top < dest_area.d_bottom && lineRect.d_top + fLineSpacing > dest_area.d_top ) { const LineInfo& currLine = d_lines[i]; String lineText(d_text.substr(currLine.d_startIdx, currLine.d_length)); // if it is a simple 'no selection area' case if ((currLine.d_startIdx >= d_selectionEnd) || ((currLine.d_startIdx + currLine.d_length) <= d_selectionStart) || (d_selectionBrush == NULL)) { colours.setColours(normalTextCol); // render the complete line. d_renderCache.cacheText(lineText, fnt, LeftAligned, lineRect, textZ, colours, &dest_area); } // we have at least some selection highlighting to do else { // Start of actual rendering section. String sect; size_t sectIdx = 0, sectLen; float selStartOffset = 0.0f, selAreaWidth = 0.0f; // render any text prior to selected region of line. if (currLine.d_startIdx < d_selectionStart) { // calculate length of text section sectLen = d_selectionStart - currLine.d_startIdx; // get text for this section sect = lineText.substr(sectIdx, sectLen); sectIdx += sectLen; // get the pixel offset to the beginning of the selection area highlight. selStartOffset = fnt->getTextExtent(sect); // draw this portion of the text colours.setColours(normalTextCol); d_renderCache.cacheText(sect, fnt, LeftAligned, lineRect, textZ, colours, &dest_area); // set position ready for next portion of text lineRect.d_left += selStartOffset; } // calculate the length of the selected section sectLen = ceguimin(d_selectionEnd - currLine.d_startIdx, currLine.d_length) - sectIdx; // get the text for this section sect = lineText.substr(sectIdx, sectLen); sectIdx += sectLen; // get the extent to use as the width of the selection area highlight selAreaWidth = fnt->getTextExtent(sect); // draw the text for this section colours.setColours(selectTextCol); d_renderCache.cacheText(sect, fnt, LeftAligned, lineRect, textZ, colours, &dest_area); // render any text beyond selected region of line if (sectIdx < currLine.d_length) { // update render position to the end of the selected area. lineRect.d_left += selAreaWidth; // calculate length of this section sectLen = currLine.d_length - sectIdx; // get the text for this section sect = lineText.substr(sectIdx, sectLen); // render the text for this section. colours.setColours(normalTextCol); d_renderCache.cacheText(sect, fnt, LeftAligned, lineRect, textZ, colours, &dest_area); } // calculate area for the selection brush on this line lineRect.d_left = drawArea.d_left + selStartOffset; lineRect.d_right = lineRect.d_left + selAreaWidth; lineRect.d_bottom = lineRect.d_top + fLineSpacing; // render the selection area brush for this line colours.setColours(selectBrushCol); d_renderCache.cacheImage(*d_selectionBrush, lineRect, selZ, colours, &dest_area); } } // update master position for next line in paragraph. drawArea.d_top += fLineSpacing; } } }