Browse Source

Add NanoVG::globalTint, some code comments

pull/341/head
falkTX 3 years ago
parent
commit
7611f937ee
5 changed files with 64 additions and 9 deletions
  1. +1
    -1
      dgl/ImageBase.hpp
  2. +48
    -3
      dgl/ImageBaseWidgets.hpp
  3. +5
    -1
      dgl/NanoVG.hpp
  4. +4
    -4
      dgl/src/ImageBaseWidgets.cpp
  5. +6
    -0
      dgl/src/NanoVG.cpp

+ 1
- 1
dgl/ImageBase.hpp View File

@@ -39,7 +39,7 @@ enum ImageFormat {
It is an abstract class that provides the common methods to build on top.
Cairo and OpenGL Image classes are based upon this one.

@see Image
@see CairoImage, OpenGLImage
*/
class ImageBase
{


+ 48
- 3
dgl/ImageBaseWidgets.hpp View File

@@ -25,13 +25,36 @@ START_NAMESPACE_DGL

// --------------------------------------------------------------------------------------------------------------------

/**
DGL Image About Window class.

This is a Window attached (transient) to another Window that simply shows an Image as its content.
It is typically used for "about this project" style pop-up Windows.

Pressing 'Esc' or clicking anywhere on the window will automatically close it.

@see CairoImageAboutWindow, OpenGLImageAboutWindow, Window::runAsModal(bool)
*/
template <class ImageType>
class ImageBaseAboutWindow : public StandaloneWindow
{
public:
explicit ImageBaseAboutWindow(Window& parentWindow, const ImageType& image = ImageType());
explicit ImageBaseAboutWindow(TopLevelWidget* parentTopLevelWidget, const ImageType& image = ImageType());

/**
Constructor taking an existing Window as the parent transient window and an optional image.
If @a image is valid, the about window size will match the image size.
*/
explicit ImageBaseAboutWindow(Window& transientParentWindow, const ImageType& image = ImageType());

/**
Constructor taking a top-level-widget's Window as the parent transient window and an optional image.
If @a image is valid, the about window size will match the image size.
*/
explicit ImageBaseAboutWindow(TopLevelWidget* topLevelWidget, const ImageType& image = ImageType());

/**
Set a new image to use as background for this window.
Window size will adjust to match the image size.
*/
void setImage(const ImageType& image);

protected:
@@ -47,6 +70,16 @@ private:

// --------------------------------------------------------------------------------------------------------------------

/**
DGL Image Button class.

This is a typical button, where the drawing comes from a pregenerated set of images.
The button can be under "normal", "hover" and "down" states, with one separate image possible for each.

The event logic for this button comes from the ButtonEventHandler class.

@see CairoImageButton, OpenGLImageButton
*/
template <class ImageType>
class ImageBaseButton : public SubWidget,
public ButtonEventHandler
@@ -81,6 +114,18 @@ private:

// --------------------------------------------------------------------------------------------------------------------

/**
DGL Image Knob class.

This is a typical knob/dial, where the drawing comes from a pregenerated image "filmstrip".
The knob's "filmstrip" image can be either horizontal or vertical,
with the number of steps automatically based on the largest value (ie, horizontal if width>height, vertical if height>width).
There are no different images for "hover" or "down" states.

The event logic for this knob comes from the KnobEventHandler class.

@see CairoImageKnob, OpenGLImageKnob
*/
template <class ImageType>
class ImageBaseKnob : public SubWidget,
public KnobEventHandler


+ 5
- 1
dgl/NanoVG.hpp View File

@@ -444,6 +444,11 @@ public:
*/
void globalAlpha(float alpha);

/**
Sets the color tint applied to all rendered shapes.
*/
void globalTint(Color tint);

/* --------------------------------------------------------------------
* Transforms */

@@ -943,7 +948,6 @@ private:
inline void onDisplay() override
{
// NOTE maybe should use BaseWidget::getWindow().getScaleFactor() as 3rd arg ?
NanoVG::reset();
NanoVG::beginFrame(BaseWidget::getWidth(), BaseWidget::getHeight());
onNanoDisplay();
NanoVG::endFrame();


+ 4
- 4
dgl/src/ImageBaseWidgets.cpp View File

@@ -22,8 +22,8 @@ START_NAMESPACE_DGL
// --------------------------------------------------------------------------------------------------------------------

template <class ImageType>
ImageBaseAboutWindow<ImageType>::ImageBaseAboutWindow(Window& parentWindow, const ImageType& image)
: StandaloneWindow(parentWindow.getApp(), parentWindow),
ImageBaseAboutWindow<ImageType>::ImageBaseAboutWindow(Window& transientParentWindow, const ImageType& image)
: StandaloneWindow(transientParentWindow.getApp(), transientParentWindow),
img(image)
{
setResizable(false);
@@ -39,8 +39,8 @@ ImageBaseAboutWindow<ImageType>::ImageBaseAboutWindow(Window& parentWindow, cons
}

template <class ImageType>
ImageBaseAboutWindow<ImageType>::ImageBaseAboutWindow(TopLevelWidget* const parentTopLevelWidget, const ImageType& image)
: StandaloneWindow(parentTopLevelWidget->getApp(), parentTopLevelWidget->getWindow()),
ImageBaseAboutWindow<ImageType>::ImageBaseAboutWindow(TopLevelWidget* const topLevelWidget, const ImageType& image)
: StandaloneWindow(topLevelWidget->getApp(), topLevelWidget->getWindow()),
img(image)
{
setResizable(false);


+ 6
- 0
dgl/src/NanoVG.cpp View File

@@ -513,6 +513,12 @@ void NanoVG::globalAlpha(float alpha)
nvgGlobalAlpha(fContext, alpha);
}

void NanoVG::globalTint(Color tint)
{
if (fContext != nullptr)
nvgGlobalTint(fContext, tint);
}

// -----------------------------------------------------------------------
// Transforms



Loading…
Cancel
Save