Skip to content

Commit

Permalink
Add files to be used for demo test
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <[email protected]>
  • Loading branch information
falkTX committed May 6, 2021
1 parent 9c5c792 commit eadd3f9
Show file tree
Hide file tree
Showing 18 changed files with 8,492 additions and 0 deletions.
569 changes: 569 additions & 0 deletions tests/demo_res/DemoArtwork.cpp

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions tests/demo_res/DemoArtwork.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* (Auto-generated binary data file). */

#ifndef BINARY_DEMOARTWORK_HPP
#define BINARY_DEMOARTWORK_HPP

namespace DemoArtwork
{
extern const char* ico1Data;
const unsigned int ico1DataSize = 6912;
const unsigned int ico1Width = 48;
const unsigned int ico1Height = 48;

extern const char* ico2Data;
const unsigned int ico2DataSize = 6912;
const unsigned int ico2Width = 48;
const unsigned int ico2Height = 48;

extern const char* ico3Data;
const unsigned int ico3DataSize = 6912;
const unsigned int ico3Width = 48;
const unsigned int ico3Height = 48;

extern const char* ico4Data;
const unsigned int ico4DataSize = 6912;
const unsigned int ico4Width = 48;
const unsigned int ico4Height = 48;

extern const char* ico5Data;
const unsigned int ico5DataSize = 6912;
const unsigned int ico5Width = 48;
const unsigned int ico5Height = 48;
}

#endif // BINARY_DEMOARTWORK_HPP

Binary file added tests/demo_res/ico1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/demo_res/ico2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/demo_res/ico3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/demo_res/ico4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/demo_res/ico5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions tests/images_res/CREDITS.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cat1.png: http://www.flickr.com/photos/tomitapio/4305303148/
cat2.png: http://www.flickr.com/photos/aigle_dore/6672148713/
cat3.png: http://www.flickr.com/photos/aigle_dore/5889008066/
7,083 changes: 7,083 additions & 0 deletions tests/images_res/CatPics.cpp

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions tests/images_res/CatPics.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* (Auto-generated binary data file). */

#ifndef BINARY_CATPICS_HPP
#define BINARY_CATPICS_HPP

namespace CatPics
{
extern const char* cat1Data;
const unsigned int cat1DataSize = 216090;
const unsigned int cat1Width = 294;
const unsigned int cat1Height = 245;

extern const char* cat2Data;
const unsigned int cat2DataSize = 117600;
const unsigned int cat2Width = 245;
const unsigned int cat2Height = 160;

extern const char* cat3Data;
const unsigned int cat3DataSize = 111600;
const unsigned int cat3Width = 248;
const unsigned int cat3Height = 150;
}

#endif // BINARY_CATPICS_HPP

Binary file added tests/images_res/cat1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/images_res/cat2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/images_res/cat3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
203 changes: 203 additions & 0 deletions tests/widgets/ExampleImagesWidget.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2015 Filipe Coelho <[email protected]>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#ifndef EXAMPLE_IMAGES_WIDGET_HPP_INCLUDED
#define EXAMPLE_IMAGES_WIDGET_HPP_INCLUDED

// ------------------------------------------------------
// DGL Stuff

#include "Image.hpp"
#include "Widget.hpp"
#include "Window.hpp"

// ------------------------------------------------------
// Images

#include "../images_res/CatPics.hpp"

// ------------------------------------------------------
// our widget

class ExampleImagesWidget : public Widget,
public IdleCallback
{
public:
static const int kImg1y = 0;
static const int kImg2y = 500/2-CatPics::cat2Height/2;
static const int kImg3x = 400/3-CatPics::cat3Width/3;

static const int kImg1max = 500-CatPics::cat1Width;
static const int kImg2max = 500-CatPics::cat2Width;
static const int kImg3max = 400-CatPics::cat3Height;

ExampleImagesWidget(Window& parent, const bool setParentSize = false)
: Widget(parent),
fImgTop1st(1),
fImgTop2nd(2),
fImgTop3rd(3),
fImg1x(0),
fImg2x(kImg2max),
fImg3y(kImg3max),
fImg1rev(false),
fImg2rev(true),
fImg3rev(true),
fImg1(CatPics::cat1Data, CatPics::cat1Width, CatPics::cat1Height, GL_BGR),
fImg2(CatPics::cat2Data, CatPics::cat2Width, CatPics::cat2Height, GL_BGR),
fImg3(CatPics::cat3Data, CatPics::cat3Width, CatPics::cat3Height, GL_BGR)
{
setSize(500, 400);

parent.addIdleCallback(this);

if (setParentSize)
{
parent.setSize(500, 400);
parent.setResizable(false);
}
}

private:
void idleCallback() noexcept override
{
if (fImg1rev)
{
fImg1x -= 2;
if (fImg1x <= -50)
{
fImg1rev = false;
setNewTopImg(1);
}
}
else
{
fImg1x += 2;
if (fImg1x >= kImg1max+50)
{
fImg1rev = true;
setNewTopImg(1);
}
}

if (fImg2rev)
{
fImg2x -= 1;
if (fImg2x <= -50)
{
fImg2rev = false;
setNewTopImg(2);
}
}
else
{
fImg2x += 4;
if (fImg2x >= kImg2max+50)
{
fImg2rev = true;
setNewTopImg(2);
}
}

if (fImg3rev)
{
fImg3y -= 3;
if (fImg3y <= -50)
{
fImg3rev = false;
setNewTopImg(3);
}
}
else
{
fImg3y += 3;
if (fImg3y >= kImg3max+50)
{
fImg3rev = true;
setNewTopImg(3);
}
}

repaint();
}

void onDisplay() override
{
switch (fImgTop3rd)
{
case 1:
fImg1.drawAt(fImg1x, kImg1y);
break;
case 2:
fImg2.drawAt(fImg2x, kImg2y);
break;
case 3:
fImg3.drawAt(kImg3x, fImg3y);
break;
};

switch (fImgTop2nd)
{
case 1:
fImg1.drawAt(fImg1x, kImg1y);
break;
case 2:
fImg2.drawAt(fImg2x, kImg2y);
break;
case 3:
fImg3.drawAt(kImg3x, fImg3y);
break;
};

switch (fImgTop1st)
{
case 1:
fImg1.drawAt(fImg1x, kImg1y);
break;
case 2:
fImg2.drawAt(fImg2x, kImg2y);
break;
case 3:
fImg3.drawAt(kImg3x, fImg3y);
break;
};
}

void setNewTopImg(const int imgId) noexcept
{
if (fImgTop1st == imgId)
return;

if (fImgTop2nd == imgId)
{
fImgTop2nd = fImgTop1st;
fImgTop1st = imgId;
return;
}

fImgTop3rd = fImgTop2nd;
fImgTop2nd = fImgTop1st;
fImgTop1st = imgId;
}

int fImgTop1st, fImgTop2nd, fImgTop3rd;
int fImg1x, fImg2x, fImg3y;
bool fImg1rev, fImg2rev, fImg3rev;
Image fImg1, fImg2, fImg3;
};

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

#endif // EXAMPLE_IMAGES_WIDGET_HPP_INCLUDED
Loading

0 comments on commit eadd3f9

Please sign in to comment.