class ffw::GuiImageViewer

Class List > ffw :: GuiImageViewer

Create an image widget with optional label. More...

Inherits the following classes: ffw::GuiWidget

Classes

Type Name
struct Style

Public Functions

Type Name
GuiImageViewer (GuiWindow * context, const GuiImage * image)
virtual ~GuiImageViewer () = default
void setImage (const GuiImage * image)
void setSubsection (int posx, int posy, int width, int height)
void setMirror (bool mirrorX, bool mirrorY)
const GuiImage * getImage () const
const Recti getSubsection () const
const Point< bool > getMirror () const
void setLabel (const std::string & label)
const std::string & getLabel () const
virtual ffw::Pointf getMinimumWrapSize () override
void setStyle (const GuiImageViewer::Style * style, bool defaults = false)

Detailed Description

auto gui = ffw::GuiWindowNanoVG(nvg); 
auto root = gui.getLayout();

// Load pixels
std::unique_ptr<unsigned char[]> pixels(new unsigned char[360 * 240 * 4]);
std::ifstream input("owl.raw", std::ios::in | std::ios::binary);
input.read((char*)pixels.get(), 360 * 240 * 4);

// Create image
// Make sure the image is alive while the window is being rendered!
// Depending on your backend implementation, you can free the pixels
// after creating the image! When using NanoVG or FineGraphics
// the pixels are copied into the GPU memory.
auto image = ffw::GuiImageNanoVG(nvg, 360, 240, 0, pixels.get());
pixels.reset();

auto viewer = new ffw::GuiImageViewer(&gui, &image);
viewer->setSize(ffw::guiPercent(50.0f), ffw::guiWrap());
viewer->setLabel("Hello World!");
viewer->setAlign(ffw::GuiAlign::TOP_LEFT);

root->addWidget(label);
// Do not free the created widgets! They will be deleted by the gui window!

while(true){
    // Render the gui
}

Public Functions Documentation

function GuiImageViewer

ffw::GuiImageViewer::GuiImageViewer (
    GuiWindow * context,
    const GuiImage * image
)

function ~GuiImageViewer

virtual ffw::GuiImageViewer::~GuiImageViewer () = default

function setImage

void ffw::GuiImageViewer::setImage (
    const GuiImage * image
)

function setSubsection

void ffw::GuiImageViewer::setSubsection (
    int posx,
    int posy,
    int width,
    int height
)

function setMirror

void ffw::GuiImageViewer::setMirror (
    bool mirrorX,
    bool mirrorY
)

function getImage

const GuiImage * ffw::GuiImageViewer::getImage () const

function getSubsection

const Recti ffw::GuiImageViewer::getSubsection () const

function getMirror

const Point< bool > ffw::GuiImageViewer::getMirror () const

function setLabel

void ffw::GuiImageViewer::setLabel (
    const std::string & label
)

function getLabel

const std::string & ffw::GuiImageViewer::getLabel () const

function getMinimumWrapSize

virtual ffw::Pointf ffw::GuiImageViewer::getMinimumWrapSize ()

Implements GuiWidget::getMinimumWrapSize

function setStyle

void ffw::GuiImageViewer::setStyle (
    const GuiImageViewer::Style * style,
    bool defaults = false
)

The documentation for this class was generated from the following file: include/ffw/gui/guiimageviewer.h