Add Inter Fonts

This commit is contained in:
2024-06-12 13:27:38 +02:00
parent b0ef96e390
commit 51f6fa6014
631 changed files with 117874 additions and 2514 deletions

View File

@ -0,0 +1,127 @@
/******************************************************************************
* Copyright (c) 2018(-2023) STMicroelectronics.
* All rights reserved.
*
* This file is part of the TouchGFX 4.22.0 distribution.
*
* This software is licensed under terms that can be found in the LICENSE file in
* the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
*******************************************************************************/
/**
* @file touchgfx/transitions/BlockTransition.hpp
*
* Declares the touchgfx::BlockTransition class.
*/
#ifndef TOUCHGFX_BLOCKTRANSITION_HPP
#define TOUCHGFX_BLOCKTRANSITION_HPP
#include <touchgfx/containers/Container.hpp>
#include <touchgfx/hal/HAL.hpp>
#include <touchgfx/hal/Types.hpp>
#include <touchgfx/transitions/Transition.hpp>
namespace touchgfx
{
/**
* A Transition that draws two small blocks in every frame. It is
* therefore very useful on MCUs with limited performance.
*/
class BlockTransition : public Transition
{
public:
/**
* Initializes a new instance of the BlockTransition class.
*/
BlockTransition()
: Transition(),
animationCounter(0)
{
// 8x6 blocks, with 8 blocks on the longest edge
if (HAL::DISPLAY_WIDTH > HAL::DISPLAY_HEIGHT)
{
blockWidth = (HAL::DISPLAY_WIDTH + 7) / 8;
blockHeight = (HAL::DISPLAY_HEIGHT + 5) / 6;
blocksHorizontal = 8;
}
else
{
blockWidth = (HAL::DISPLAY_WIDTH + 5) / 6;
blockHeight = (HAL::DISPLAY_HEIGHT + 7) / 8;
blocksHorizontal = 6;
}
}
/**
* Handles the tick event when transitioning. It uncovers and
* invalidates two blocks in every frame, for a total of 24
* frames.
*/
virtual void handleTickEvent()
{
const int animationSteps = 48;
// "Random" sequence of blocks to invalidate
const int indeces[animationSteps] = { 20, 11, 47, 14, 10, 0, 18, 28, 13, 6, 2, 41,
44, 5, 3, 17, 36, 46, 26, 15, 29, 39, 25, 12,
19, 24, 7, 38, 37, 30, 9, 43, 4, 31, 22, 23,
35, 16, 32, 42, 8, 1, 40, 33, 21, 27, 34, 45 };
Transition::handleTickEvent();
if (animationCounter >= animationSteps)
{
// Final step: stop the animation
done = true;
return;
}
if (animationCounter == 0 && HAL::USE_DOUBLE_BUFFERING)
{
// Synchronize framebuffers
Application::getInstance()->copyInvalidatedAreasFromTFTToClientBuffer();
}
int blocks_per_tick = 2;
while (blocks_per_tick-- > 0 && animationCounter <= animationSteps)
{
// Invalidate next block in sequence
const int index = indeces[animationCounter];
const int16_t x = (index % blocksHorizontal) * blockWidth;
const int16_t y = (index / blocksHorizontal) * blockHeight;
Rect invRect(x, y, blockWidth, blockHeight);
screenContainer->invalidateRect(invRect);
animationCounter++;
}
}
virtual void tearDown()
{
}
virtual void init()
{
Transition::init();
}
/**
* Block transition does not require an invalidation. Invalidation
* is handled by the class. Do no invalidation initially.
*/
virtual void invalidate()
{
}
private:
uint16_t blockWidth;
uint16_t blockHeight;
uint16_t blocksHorizontal;
uint8_t animationCounter; ///< Current step in the transition animation.
};
} // namespace touchgfx
#endif // TOUCHGFX_BLOCKTRANSITION_HPP

View File

@ -0,0 +1,208 @@
/******************************************************************************
* Copyright (c) 2018(-2023) STMicroelectronics.
* All rights reserved.
*
* This file is part of the TouchGFX 4.22.0 distribution.
*
* This software is licensed under terms that can be found in the LICENSE file in
* the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
*******************************************************************************/
/**
* @file touchgfx/transitions/CoverTransition.hpp
*
* Declares the touchgfx::CoverTransition class.
*/
#ifndef TOUCHGFX_COVERTRANSITION_HPP
#define TOUCHGFX_COVERTRANSITION_HPP
#include <touchgfx/Callback.hpp>
#include <touchgfx/Drawable.hpp>
#include <touchgfx/EasingEquations.hpp>
#include <touchgfx/containers/Container.hpp>
#include <touchgfx/hal/HAL.hpp>
#include <touchgfx/hal/Types.hpp>
#include <touchgfx/lcd/LCD.hpp>
#include <touchgfx/transitions/Transition.hpp>
namespace touchgfx
{
/**
* A Transition that slides the new screen over the previous \e from the given direction.
*/
template <Direction templateDirection>
class CoverTransition : public Transition
{
public:
/**
* Initializes a new instance of the CoverTransition class.
*
* @param transitionSteps (Optional) Number of steps in the transition animation.
*/
CoverTransition(const uint8_t transitionSteps = 20)
: Transition(),
animationSteps(transitionSteps),
animationCounter(0),
calculatedValue(0),
solid()
{
switch (templateDirection)
{
case EAST:
targetValue = -HAL::DISPLAY_WIDTH;
break;
case WEST:
targetValue = HAL::DISPLAY_WIDTH;
break;
case NORTH:
targetValue = HAL::DISPLAY_HEIGHT;
break;
case SOUTH:
targetValue = -HAL::DISPLAY_HEIGHT;
break;
default:
done = true;
// Nothing to do here
break;
}
// Ensure that the solid area covers the entire screen
solid.setPosition(0, 0, HAL::DISPLAY_WIDTH, HAL::DISPLAY_HEIGHT);
}
/**
* Handles the tick event when transitioning. It moves the contents of the Screen's
* container. The direction of the transition determines the direction the contents of
* the container moves.
*/
virtual void handleTickEvent()
{
Transition::handleTickEvent();
// Calculate new position or stop animation
animationCounter++;
if (animationCounter > animationSteps)
{
// Final step: stop the animation
done = true;
animationCounter = 0;
return;
}
const int16_t oldValue = calculatedValue;
// Calculate value in [0;targetValue]
calculatedValue = EasingEquations::cubicEaseOut(animationCounter, 0, targetValue, animationSteps);
// Note: Result of "calculatedValue & 1" is compiler dependent for negative values of calculatedValue
if ((calculatedValue % 2) != 0)
{
// Optimization: calculatedValue is odd, add 1/-1 to move drawables modulo 32 bits in framebuffer
calculatedValue += (calculatedValue > 0 ? 1 : -1);
}
// Convert the calculated value to delta value relative to current moved-to position
const int16_t relativeValue = calculatedValue - oldValue;
// The Cover Transition only draws to parts of the non-TFT framebuffer. To avoid glitches
// In Double buffering mode both framebuffers must be identical.
if (animationCounter == 1 && HAL::USE_DOUBLE_BUFFERING)
{
// Synchronize framebuffers
Application::getInstance()->copyInvalidatedAreasFromTFTToClientBuffer();
}
Rect rect;
switch (templateDirection)
{
case EAST:
rect.x = HAL::DISPLAY_WIDTH + calculatedValue;
rect.y = 0;
rect.width = -calculatedValue;
rect.height = HAL::DISPLAY_HEIGHT;
break;
case WEST:
rect.x = 0;
rect.y = 0;
rect.width = calculatedValue;
rect.height = HAL::DISPLAY_HEIGHT;
break;
case NORTH:
rect.x = 0;
rect.y = 0;
rect.width = HAL::DISPLAY_WIDTH;
rect.height = calculatedValue;
break;
case SOUTH:
rect.x = 0;
rect.y = HAL::DISPLAY_HEIGHT + calculatedValue;
rect.width = HAL::DISPLAY_WIDTH;
rect.height = -calculatedValue;
break;
}
Application::getInstance()->invalidateArea(rect);
// Move children with delta value for X or Y
Drawable* d = screenContainer->getFirstChild();
while (d)
{
switch (templateDirection)
{
case EAST:
case WEST:
d->setX(d->getX() + relativeValue);
break;
case NORTH:
case SOUTH:
d->setY(d->getY() + relativeValue);
break;
}
d = d->getNextSibling();
}
}
virtual void tearDown()
{
screenContainer->remove(solid);
}
virtual void init()
{
Transition::init();
// Move snapshot and its children with delta value for X or Y
Drawable* d = screenContainer->getFirstChild();
while (d)
{
switch (templateDirection)
{
case EAST:
case WEST:
d->setX(d->getX() - targetValue);
break;
case NORTH:
case SOUTH:
d->setY(d->getY() - targetValue);
break;
}
d = d->getNextSibling();
}
screenContainer->add(solid);
}
private:
const uint8_t animationSteps; ///< Number of steps the transition should move per complete animation.
uint8_t animationCounter; ///< Current step in the transition animation.
int16_t targetValue; ///< The target value for the transition animation.
int16_t calculatedValue; ///< The current X or Y value
FullSolidRect solid; ///< A solid rect that covers the entire screen to avoid copying elements outside
};
} // namespace touchgfx
#endif // TOUCHGFX_COVERTRANSITION_HPP

View File

@ -0,0 +1,43 @@
/******************************************************************************
* Copyright (c) 2018(-2023) STMicroelectronics.
* All rights reserved.
*
* This file is part of the TouchGFX 4.22.0 distribution.
*
* This software is licensed under terms that can be found in the LICENSE file in
* the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
*******************************************************************************/
/**
* @file touchgfx/transitions/NoTransition.hpp
*
* Declares the touchgfx::NoTransition class.
*/
#ifndef TOUCHGFX_NOTRANSITION_HPP
#define TOUCHGFX_NOTRANSITION_HPP
#include <touchgfx/transitions/Transition.hpp>
namespace touchgfx
{
/**
* The most simple Transition without any visual effects. THe screen transition is done by
* immediately replace the current Screen with a new Screen.
*
* @see Transition
*/
class NoTransition : public Transition
{
public:
/** Indicates that the transition is done after the first tick. */
virtual void handleTickEvent()
{
done = true;
}
};
} // namespace touchgfx
#endif // TOUCHGFX_NOTRANSITION_HPP

View File

@ -0,0 +1,197 @@
/******************************************************************************
* Copyright (c) 2018(-2023) STMicroelectronics.
* All rights reserved.
*
* This file is part of the TouchGFX 4.22.0 distribution.
*
* This software is licensed under terms that can be found in the LICENSE file in
* the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
*******************************************************************************/
/**
* @file touchgfx/transitions/SlideTransition.hpp
*
* Declares the touchgfx::SlideTransition class.
*/
#ifndef TOUCHGFX_SLIDETRANSITION_HPP
#define TOUCHGFX_SLIDETRANSITION_HPP
#include <touchgfx/Drawable.hpp>
#include <touchgfx/EasingEquations.hpp>
#include <touchgfx/containers/Container.hpp>
#include <touchgfx/hal/HAL.hpp>
#include <touchgfx/hal/Types.hpp>
#include <touchgfx/transitions/Transition.hpp>
#include <touchgfx/widgets/SnapshotWidget.hpp>
namespace touchgfx
{
/**
* A Transition that slides from one screen to the next. It does so by moving a SnapShotWidget
* with a snapshot of the Screen transitioning away from, and by moving the contents of
* Screen transitioning to.
*
* @see Transition
*/
template <Direction templateDirection>
class SlideTransition : public Transition
{
public:
/**
* Initializes a new instance of the SlideTransition class.
*
* @param transitionSteps (Optional) Number of steps (ticks) in the transition animation, default is 20.
*/
SlideTransition(const uint8_t transitionSteps = 20)
: Transition(),
snapshot(),
animationSteps(transitionSteps),
animationCounter(0),
relativeValue(0)
{
if (!HAL::USE_ANIMATION_STORAGE)
{
// No animation storage, don't slide
done = true;
return;
}
snapshot.setPosition(0, 0, HAL::DISPLAY_WIDTH, HAL::DISPLAY_HEIGHT);
snapshot.makeSnapshot();
switch (templateDirection)
{
case EAST:
targetValue = -HAL::DISPLAY_WIDTH;
break;
case WEST:
targetValue = HAL::DISPLAY_WIDTH;
break;
case NORTH:
targetValue = HAL::DISPLAY_HEIGHT;
break;
case SOUTH:
targetValue = -HAL::DISPLAY_HEIGHT;
break;
}
}
/**
* Handles the tick event when transitioning. It moves the contents of the Screen's
* container and a SnapshotWidget with a snapshot of the previous Screen. The direction
* of the transition determines the direction the contents of the container and the
* SnapshotWidget moves.
*/
virtual void handleTickEvent()
{
Transition::handleTickEvent();
// Calculate new position or stop animation
animationCounter++;
if (animationCounter > animationSteps)
{
// Final step: stop the animation
done = true;
animationCounter = 0;
return;
}
// Calculate value in [0;targetValue]
int16_t calculatedValue = EasingEquations::cubicEaseOut(animationCounter, 0, targetValue, animationSteps);
// Note: Result of "calculatedValue & 1" is compiler dependent for negative values of calculatedValue
if ((calculatedValue % 2) != 0)
{
// Optimization: calculatedValue is odd, add 1/-1 to move drawables modulo 32 bits in framebuffer
calculatedValue += (calculatedValue > 0 ? 1 : -1);
}
// Move snapshot
switch (templateDirection)
{
case EAST:
case WEST:
relativeValue = calculatedValue - snapshot.getX();
break;
case NORTH:
case SOUTH:
relativeValue = calculatedValue - snapshot.getY();
break;
}
// Move snapshot and its children with delta value for X or Y
Drawable* d = screenContainer->getFirstChild();
while (d)
{
switch (templateDirection)
{
case EAST:
case WEST:
d->setX(d->getX() + relativeValue);
break;
case NORTH:
case SOUTH:
d->setY(d->getY() + relativeValue);
break;
}
d = d->getNextSibling();
}
// Entire screen has changed, redraw
screenContainer->invalidate();
}
virtual void tearDown()
{
if (HAL::USE_ANIMATION_STORAGE && screenContainer)
{
screenContainer->remove(snapshot);
}
}
virtual void init()
{
Transition::init();
if (done)
{
return;
}
// Move snapshot and its children with delta value for X or Y
Drawable* d = screenContainer->getFirstChild();
while (d)
{
switch (templateDirection)
{
case EAST:
case WEST:
d->setX(d->getX() - targetValue);
break;
case NORTH:
case SOUTH:
d->setY(d->getY() - targetValue);
break;
}
d = d->getNextSibling();
}
screenContainer->add(snapshot);
}
protected:
SnapshotWidget snapshot; ///< The SnapshotWidget that is moved when transitioning.
private:
const uint8_t animationSteps; ///< Number of steps the transition should move per complete animation.
uint8_t animationCounter; ///< Current step in the transition animation.
int16_t targetValue; ///< The target value for the transition animation.
int16_t relativeValue; ///< The relative X or Y value for the snapshot and the children.
};
} // namespace touchgfx
#endif // TOUCHGFX_SLIDETRANSITION_HPP

View File

@ -0,0 +1,128 @@
/******************************************************************************
* Copyright (c) 2018(-2023) STMicroelectronics.
* All rights reserved.
*
* This file is part of the TouchGFX 4.22.0 distribution.
*
* This software is licensed under terms that can be found in the LICENSE file in
* the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
*******************************************************************************/
/**
* @file touchgfx/transitions/Transition.hpp
*
* Declares the touchgfx::Transition class.
*/
#ifndef TOUCHGFX_TRANSITION_HPP
#define TOUCHGFX_TRANSITION_HPP
#include <touchgfx/Application.hpp>
#include <touchgfx/containers/Container.hpp>
#include <touchgfx/hal/Types.hpp>
#include <touchgfx/widgets/Widget.hpp>
namespace touchgfx
{
/**
* The Transition class is the base class for Transitions. Implementations of Transition defines
* what happens when transitioning between Screens, which typically involves visual
* effects. An example of a transition implementation can be seen in example
* custom_transition_example. The most basic transition is the NoTransition class that
* does a transition without any visual effects.
*
* @see NoTransition, SlideTransition
*/
class Transition
{
public:
/** Initializes a new instance of the Transition class. */
Transition()
: screenContainer(0), done(false)
{
}
/** Finalizes an instance of the Transition class. */
virtual ~Transition()
{
}
/** Called for every tick when transitioning. */
virtual void handleTickEvent()
{
}
/**
* Query if the transition is done transitioning. It is the responsibility of the
* inheriting class to set the underlying done flag once the transition has been
* completed.
*
* @return True if the transition is done, false otherwise.
*/
bool isDone() const
{
return done;
}
/**
* Tears down the Animation. Called before the destructor is called, when the
* application changes the transition.
*/
virtual void tearDown()
{
}
/**
* Initializes the transition. Called after the constructor is called, when the
* application changes the transition.
*/
virtual void init()
{
}
/**
* Invalidates the screen when starting the Transition. Default is
* to invalidate the whole screen. Subclasses can do partial
* invalidation.
*/
virtual void invalidate()
{
Application::getInstance()->invalidate();
}
/**
* Sets the Screen Container. Is used by Screen to enable the transition to access the
* Container.
*
* @param [in] cont The Container the transition should have access to.
*/
virtual void setScreenContainer(Container& cont)
{
screenContainer = &cont;
}
protected:
/**
* A Widget that reports solid and but does not draw anything.
*/
class FullSolidRect : public Widget
{
public:
virtual Rect getSolidRect() const
{
return Rect(0, 0, rect.width, rect.height);
}
virtual void draw(const Rect& area) const
{
}
};
Container* screenContainer; ///< The screen Container of the Screen transitioning to.
bool done; ///< Flag that indicates when the transition is done. This should be set by implementing classes.
};
} // namespace touchgfx
#endif // TOUCHGFX_TRANSITION_HPP

View File

@ -0,0 +1,192 @@
/******************************************************************************
* Copyright (c) 2018(-2023) STMicroelectronics.
* All rights reserved.
*
* This file is part of the TouchGFX 4.22.0 distribution.
*
* This software is licensed under terms that can be found in the LICENSE file in
* the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
*******************************************************************************/
/**
* @file touchgfx/transitions/WipeTransition.hpp
*
* Declares the touchgfx::WipeTransition class.
*/
#ifndef TOUCHGFX_WIPETRANSITION_HPP
#define TOUCHGFX_WIPETRANSITION_HPP
#include <touchgfx/EasingEquations.hpp>
#include <touchgfx/containers/Container.hpp>
#include <touchgfx/hal/HAL.hpp>
#include <touchgfx/hal/Types.hpp>
#include <touchgfx/lcd/LCD.hpp>
#include <touchgfx/transitions/Transition.hpp>
namespace touchgfx
{
/**
* A Transition that expands the new screen over the previous from
* the given direction. This transition only draws the pixels in the
* framebuffer once, and never moves any pixels. It is therefore very
* useful on MCUs with limited performance.
*/
template <Direction templateDirection>
class WipeTransition : public Transition
{
public:
/**
* Initializes a new instance of the WipeTransition class.
*
* @param transitionSteps (Optional) Number of steps in the transition animation.
*/
WipeTransition(const uint8_t transitionSteps = 20)
: Transition(),
animationSteps(transitionSteps),
animationCounter(0),
calculatedValue(0),
solid()
{
switch (templateDirection)
{
case EAST:
case WEST:
targetValue = HAL::DISPLAY_WIDTH;
break;
case NORTH:
case SOUTH:
targetValue = HAL::DISPLAY_HEIGHT;
break;
}
// Ensure that the solid area covers the entire screen
solid.setPosition(0, 0, HAL::DISPLAY_WIDTH, HAL::DISPLAY_HEIGHT);
}
/**
* Handles the tick event when transitioning. It uncovers and
* invalidates increasing parts of the new screen elements.
*/
virtual void handleTickEvent()
{
Transition::handleTickEvent();
animationCounter++;
// Calculate new position or stop animation
if (animationCounter > animationSteps)
{
// Final step: stop the animation
done = true;
animationCounter = 0;
return;
}
// Calculate value in [0;targetValue]
calculatedValue = EasingEquations::cubicEaseOut(animationCounter, 0, targetValue, animationSteps);
// Note: Result of "calculatedValue & 1" is compiler dependent for negative values of calculatedValue
if ((calculatedValue % 2) != 0)
{
// Optimization: calculatedValue is odd, add 1/-1 to move drawables modulo 32 bits in framebuffer
calculatedValue += (calculatedValue > 0 ? 1 : -1);
}
// calculatedValue is the width/height of the visible area
switch (templateDirection)
{
case EAST:
{
// Cover must have width of remaining part
const uint16_t prevSolidWidth = solid.getWidth();
solid.setWidth(HAL::DISPLAY_WIDTH - calculatedValue);
// Invalidate the uncovered part
const uint16_t delta = prevSolidWidth - solid.getWidth();
Rect r(solid.getWidth(), 0, delta, HAL::DISPLAY_HEIGHT);
screenContainer->invalidateRect(r);
break;
}
case WEST:
{
// Cover must have width of remaining part and start after uncovered
const uint16_t prevSolidPos = solid.getX();
solid.setWidth(HAL::DISPLAY_WIDTH - calculatedValue);
solid.setX(calculatedValue);
// Invalidate the uncovered part
const uint16_t delta = calculatedValue - prevSolidPos;
Rect r(prevSolidPos, 0, delta, HAL::DISPLAY_HEIGHT);
screenContainer->invalidateRect(r);
break;
}
case NORTH:
{
// Cover must have height of remaining part and start after uncovered
const uint16_t prevSolidPos = solid.getY();
solid.setHeight(HAL::DISPLAY_HEIGHT - calculatedValue);
solid.setY(calculatedValue);
// Invalidate the uncovered part
const uint16_t delta = calculatedValue - prevSolidPos;
Rect r(0, prevSolidPos, HAL::DISPLAY_WIDTH, delta);
screenContainer->invalidateRect(r);
break;
}
case SOUTH:
{
// Cover must have height of remaining part
const uint16_t prevSolidHeight = solid.getHeight();
solid.setHeight(HAL::DISPLAY_HEIGHT - calculatedValue);
// Invalidate the uncovered part
const uint16_t delta = prevSolidHeight - solid.getHeight();
Rect r(0, solid.getHeight(), HAL::DISPLAY_WIDTH, delta);
screenContainer->invalidateRect(r);
break;
}
}
// The WipeTransition only draws to parts of the non-TFT
// framebuffer. To avoid glitches in Double buffering mode
// both framebuffers must be made identical.
if (animationCounter == 1 && HAL::USE_DOUBLE_BUFFERING)
{
// Synchronize framebuffers
Application::getInstance()->copyInvalidatedAreasFromTFTToClientBuffer();
}
}
virtual void tearDown()
{
screenContainer->remove(solid);
}
virtual void init()
{
Transition::init();
// Add the solid (and not-drawing-anything) widget on top to cover the other widgets
screenContainer->add(solid);
}
/**
* Wipe transition does not require an invalidation. Invalidation
* is handled by the class. Do no invalidation initially.
*/
virtual void invalidate()
{
}
private:
const uint8_t animationSteps; ///< Number of steps the transition should move per complete animation.
uint8_t animationCounter; ///< Current step in the transition animation.
int16_t targetValue; ///< The target value for the transition animation.
int16_t calculatedValue; ///< The calculated X or Y value to move the snapshot and the children.
FullSolidRect solid; ///< A solid rect that covers the entire screen to avoid copying elements outside
};
} // namespace touchgfx
#endif // TOUCHGFX_WIPETRANSITION_HPP