Commit fe06374a authored by sm's avatar sm

New verion 0.9

* Improve drawing API and performance
* Eliminate commands, add message to event action
* CircularBuffer: noexcept and test
* IntSet: improve API, noexcept and test
* HighscoresDialog: fix selection bug and set focus
* Create NewRows and simplify RandomTiles
* Move ScrollerEvent from Swapper project
* ScrollerEvent uses NewRows class
* Fix LevelShowWidget interactive bug
* Fix StaticGridAnimation defaults bug
* Move some files to util folder
* Increase minor version
parent 22c0d51b
stmm-games (0.9) unstable; urgency=low
* Improve drawing API and performance
* Eliminate commands, add message to event action
* CircularBuffer: noexcept and test
* IntSet: improve API, noexcept and test
* HighscoresDialog: fix selection bug and set focus
* Create NewRows and simplify RandomTiles
* Move ScrollerEvent from Swapper project
* ScrollerEvent uses NewRows class
* Fix LevelShowWidget interactive bug
* Fix StaticGridAnimation defaults bug
* Move some files to util folder
* Increase minor version
-- Stefano Marsili <efanomars@gmx.ch> Sun, 02 Jun 2019 19:29:39 +0100
stmm-games (0.8) unstable; urgency=low
* Fix theme
......
......@@ -20,12 +20,12 @@
# MINOR is REVISION (implementation of interface)
# AGE is always 0
set(STMM_GAMES_FAKE_MAJOR_VERSION 0)
set(STMM_GAMES_FAKE_MINOR_VERSION 8)
set(STMM_GAMES_FAKE_MINOR_VERSION 9)
set(STMM_GAMES_FAKE_VERSION "${STMM_GAMES_FAKE_MAJOR_VERSION}.${STMM_GAMES_FAKE_MINOR_VERSION}.0")
# required stmm-games version
set(STMM_GAMES_FAKE_REQ_STMM_GAMES_MAJOR_VERSION 0)
set(STMM_GAMES_FAKE_REQ_STMM_GAMES_MINOR_VERSION 8)
set(STMM_GAMES_FAKE_REQ_STMM_GAMES_MINOR_VERSION 9)
set(STMM_GAMES_FAKE_REQ_STMM_GAMES_VERSION "${STMM_GAMES_FAKE_REQ_STMM_GAMES_MAJOR_VERSION}.${STMM_GAMES_FAKE_REQ_STMM_GAMES_MINOR_VERSION}")
include("${PROJECT_SOURCE_DIR}/../libstmm-games/stmm-games-defs.cmake")
......
......@@ -62,6 +62,24 @@ set(STMMI_HEADERS_MODIFIERS
"${STMMI_HEADERS_DIR}/modifiers/tileanimodifier.h"
)
#
set(STMMI_HEADERS_UTIL
"${STMMI_HEADERS_DIR}/util/cachedsurfaces.h"
"${STMMI_HEADERS_DIR}/util/ccsave.h"
"${STMMI_HEADERS_DIR}/util/dynanimation.h"
"${STMMI_HEADERS_DIR}/util/file.h"
"${STMMI_HEADERS_DIR}/util/frame.h"
"${STMMI_HEADERS_DIR}/util/image.h"
"${STMMI_HEADERS_DIR}/util/segmentedfunction.h"
"${STMMI_HEADERS_DIR}/util/tileani.h"
"${STMMI_HEADERS_DIR}/util/tilesizing.h"
)
#
set(STMMI_HEADERS_WIDGET_IMPL
"${STMMI_HEADERS_DIR}/widgetimpl/immutablethwidgetimpl.h"
"${STMMI_HEADERS_DIR}/widgetimpl/mutablethwidgetimpl.h"
"${STMMI_HEADERS_DIR}/widgetimpl/relsizedthwidgetimpl.h"
)
#
set(STMMI_HEADERS_WIDGETS
"${STMMI_HEADERS_DIR}/widgets/actionsboxthwidgetfactory.h"
"${STMMI_HEADERS_DIR}/widgets/actionthwidgetfactory.h"
......@@ -73,26 +91,21 @@ set(STMMI_HEADERS_WIDGETS
"${STMMI_HEADERS_DIR}/widgets/progressthwidgetfactory.h"
"${STMMI_HEADERS_DIR}/widgets/transparentthwidgetfactory.h"
"${STMMI_HEADERS_DIR}/widgets/varthwidgetfactory.h"
"${STMMI_HEADERS_DIR}/widgets/volatilethwidgetfactory.h"
)
#
set(STMMI_HEADERS
"${STMMI_HEADERS_DIR}/allpreferences.h"
"${STMMI_HEADERS_DIR}/allpreferencesloader.h"
"${STMMI_HEADERS_DIR}/boxthemewidgetfactory.h"
"${STMMI_HEADERS_DIR}/cachedsurfaces.h"
"${STMMI_HEADERS_DIR}/commontheme.h"
"${STMMI_HEADERS_DIR}/containermodifier.h"
"${STMMI_HEADERS_DIR}/dynanimation.h"
"${STMMI_HEADERS_DIR}/file.h"
"${STMMI_HEADERS_DIR}/frame.h"
"${STMMI_HEADERS_DIR}/gameconstraints.h"
"${STMMI_HEADERS_DIR}/gameloader.h"
"${STMMI_HEADERS_DIR}/highscoresloader.h"
"${STMMI_HEADERS_DIR}/image.h"
"${STMMI_HEADERS_DIR}/levelshowthemewidget.h"
"${STMMI_HEADERS_DIR}/stmm-games-gtk-config.h"
"${STMMI_HEADERS_DIR}/mainwindow.h"
"${STMMI_HEADERS_DIR}/segmentedfunction.h"
"${STMMI_HEADERS_DIR}/stdtheme.h"
"${STMMI_HEADERS_DIR}/stdthemeanimationfactory.h"
"${STMMI_HEADERS_DIR}/stdthemeanimationfactories.h"
......@@ -103,12 +116,11 @@ set(STMMI_HEADERS
"${STMMI_HEADERS_DIR}/stdthemewidgetfactories.h"
"${STMMI_HEADERS_DIR}/theme.h"
"${STMMI_HEADERS_DIR}/themeanimation.h"
"${STMMI_HEADERS_DIR}/themecontainerwidget.h"
"${STMMI_HEADERS_DIR}/themelayout.h"
"${STMMI_HEADERS_DIR}/themeloader.h"
"${STMMI_HEADERS_DIR}/themewidget.h"
"${STMMI_HEADERS_DIR}/themewidgetinteractive.h"
"${STMMI_HEADERS_DIR}/tileani.h"
"${STMMI_HEADERS_DIR}/tilesizing.h"
)
#
# Sources dir
......@@ -117,11 +129,8 @@ set(STMMI_SOURCES_DIR "${PROJECT_SOURCE_DIR}/src")
set(STMMI_SOURCES
"${STMMI_SOURCES_DIR}/stdtheme.cc"
"${STMMI_SOURCES_DIR}/cachedsurfaces.cc"
"${STMMI_SOURCES_DIR}/commontheme.cc"
"${STMMI_SOURCES_DIR}/containermodifier.cc"
"${STMMI_SOURCES_DIR}/dynanimation.cc"
"${STMMI_SOURCES_DIR}/frame.cc"
"${STMMI_SOURCES_DIR}/gameconstraints.cc"
"${STMMI_SOURCES_DIR}/gamedialog.h"
"${STMMI_SOURCES_DIR}/gamedialog.cc"
......@@ -131,13 +140,12 @@ set(STMMI_SOURCES
"${STMMI_SOURCES_DIR}/gamewindow.cc"
"${STMMI_SOURCES_DIR}/highscoredialog.h"
"${STMMI_SOURCES_DIR}/highscoredialog.cc"
"${STMMI_SOURCES_DIR}/image.cc"
"${STMMI_SOURCES_DIR}/inputstrings.h"
"${STMMI_SOURCES_DIR}/inputstrings.cc"
"${STMMI_SOURCES_DIR}/levelshowthemewidget.cc"
"${STMMI_SOURCES_DIR}/mainwindow.cc"
"${STMMI_SOURCES_DIR}/playersdialog.h"
"${STMMI_SOURCES_DIR}/playersdialog.cc"
"${STMMI_SOURCES_DIR}/segmentedfunction.cc"
"${STMMI_SOURCES_DIR}/stdlevelview.h"
"${STMMI_SOURCES_DIR}/stdlevelview.cc"
"${STMMI_SOURCES_DIR}/stdtheme.cc"
......@@ -149,12 +157,11 @@ set(STMMI_SOURCES
"${STMMI_SOURCES_DIR}/stdview.cc"
"${STMMI_SOURCES_DIR}/stdviewlayout.h"
"${STMMI_SOURCES_DIR}/stdviewlayout.cc"
"${STMMI_SOURCES_DIR}/themecontainerwidget.cc"
"${STMMI_SOURCES_DIR}/themedialog.h"
"${STMMI_SOURCES_DIR}/themedialog.cc"
"${STMMI_SOURCES_DIR}/themelayout.cc"
"${STMMI_SOURCES_DIR}/themewidget.cc"
"${STMMI_SOURCES_DIR}/tileani.cc"
"${STMMI_SOURCES_DIR}/tilesizing.cc"
#
"${STMMI_SOURCES_DIR}/animations/backgroundthanifactory.cc"
"${STMMI_SOURCES_DIR}/animations/explosionthanifactory.cc"
......@@ -179,6 +186,16 @@ set(STMMI_SOURCES
"${STMMI_SOURCES_DIR}/modifiers/textmodifier.cc"
"${STMMI_SOURCES_DIR}/modifiers/tileanimodifier.cc"
#
"${STMMI_SOURCES_DIR}/util/ccsave.cc"
"${STMMI_SOURCES_DIR}/util/cachedsurfaces.cc"
"${STMMI_SOURCES_DIR}/util/dynanimation.cc"
"${STMMI_SOURCES_DIR}/util/file.cc"
"${STMMI_SOURCES_DIR}/util/frame.cc"
"${STMMI_SOURCES_DIR}/util/image.cc"
"${STMMI_SOURCES_DIR}/util/segmentedfunction.cc"
"${STMMI_SOURCES_DIR}/util/tileani.cc"
"${STMMI_SOURCES_DIR}/util/tilesizing.cc"
#
"${STMMI_SOURCES_DIR}/widgets/actionsboxthwidgetfactory.cc"
"${STMMI_SOURCES_DIR}/widgets/actionthwidgetfactory.cc"
"${STMMI_SOURCES_DIR}/widgets/backgroundthwidgetfactory.cc"
......@@ -189,6 +206,7 @@ set(STMMI_SOURCES
"${STMMI_SOURCES_DIR}/widgets/progressthwidgetfactory.cc"
"${STMMI_SOURCES_DIR}/widgets/transparentthwidgetfactory.cc"
"${STMMI_SOURCES_DIR}/widgets/varthwidgetfactory.cc"
"${STMMI_SOURCES_DIR}/widgets/volatilethwidgetfactory.cc"
)
# Define library
......@@ -257,9 +275,11 @@ add_subdirectory(test)
install(TARGETS stmm-games-gtk LIBRARY DESTINATION "lib" ARCHIVE DESTINATION "lib")
install(FILES ${STMMI_HEADERS} DESTINATION "include/stmm-games-gtk")
install(FILES ${STMMI_HEADERS_ANIMATIONS} DESTINATION "include/stmm-games-gtk/animations")
install(FILES ${STMMI_HEADERS_MODIFIERS} DESTINATION "include/stmm-games-gtk/modifiers")
install(FILES ${STMMI_HEADERS_WIDGETS} DESTINATION "include/stmm-games-gtk/widgets")
install(FILES ${STMMI_HEADERS} DESTINATION "include/stmm-games-gtk")
install(FILES ${STMMI_HEADERS_ANIMATIONS} DESTINATION "include/stmm-games-gtk/animations")
install(FILES ${STMMI_HEADERS_MODIFIERS} DESTINATION "include/stmm-games-gtk/modifiers")
install(FILES ${STMMI_HEADERS_UTIL} DESTINATION "include/stmm-games-gtk/util")
install(FILES ${STMMI_HEADERS_WIDGET_IMPL} DESTINATION "include/stmm-games-gtk/widgetimpl")
install(FILES ${STMMI_HEADERS_WIDGETS} DESTINATION "include/stmm-games-gtk/widgets")
install(FILES "${PROJECT_BINARY_DIR}/stmm-games-gtk.pc" DESTINATION "lib/pkgconfig")
......@@ -23,7 +23,7 @@
#include "stdthemeanimationfactory.h"
#include "theme.h"
#include "image.h"
#include "util/image.h"
#include <stmm-games/animations/backgroundanimation.h>
......
......@@ -23,7 +23,7 @@
#include "stdthemeanimationfactory.h"
#include "theme.h"
#include "dynanimation.h"
#include "util/dynanimation.h"
#include <stmm-games/animations/imagesequenceanimation.h>
......
......@@ -45,35 +45,41 @@ private:
{
friend class PlainTextThAniFactory;
public:
PlainTextThAni() = default;
void reInit() {}
PlainTextThAni();
void reInit();
int32_t getZ(int32_t nViewTick, int32_t nTotViewTicks) override;
bool isStarted(int32_t nViewTick, int32_t nTotViewTicks) override;
bool isDone(int32_t nViewTick, int32_t nTotViewTicks) override;
void draw(int32_t nViewTick, int32_t nTotViewTicks, const Cairo::RefPtr<Cairo::Context>& refCc) override;
void onRemoved() override;
private:
void reInitCommon();
void getRectAndScale(FRect& oRect, double& fScale, double& fPixHLine);
protected:
private:
double m_fWidest;
double m_fHighest;
std::vector<NSize> m_aTextSize;
double m_fFadeIn; // in millisec
double m_fFadeOut; // in millisec
double m_fLastAlpha1Drawn;
shared_ptr<TextAnimation> m_refModel;
int32_t m_nZ;
shared_ptr<StdThemeContext> m_refThemeContext;
Glib::RefPtr<Pango::Layout> m_refFontLayout;
PlainTextThAniFactory* m_p1Owner;
};
unique_ptr<Pango::FontDescription> m_refFont;
double m_fR1;
double m_fG1;
double m_fB1;
double m_fA1;
bool m_bCenter;
TileColor m_oColor;
TileAlpha m_oAlpha;
TileFont m_oFont;
// TileColor m_oColor;
// TileAlpha m_oAlpha;
// TileFont m_oFont;
bool m_bFadeInIsFactor;
double m_fFadeIn;
bool m_bFadeOutIsFactor;
......
......@@ -22,6 +22,7 @@
#include "stdthemewidgetfactory.h"
#include "stdtheme.h"
#include "themecontainerwidget.h"
#include <stmm-games/widgets/boxwidget.h>
......@@ -65,7 +66,7 @@ public:
protected:
void onAssignedToLayout() override;
void onRecalcSizeFunctions(ThemeWidget* p0ReferenceThemeWidget) override;
void sizeAndConfig(int32_t nTileSize, int32_t nLayoutConfig) override;
void sizeAndConfig(int32_t nTileW, int32_t nLayoutConfig) override;
/** The pointer to the model.
* @return The model. Is not null.
*/
......@@ -86,7 +87,7 @@ private:
int32_t m_nPixW;
int32_t m_nPixH;
std::array< std::pair<SegmentedFunction, SegmentedFunction>, s_nTotLayoutConfigs> m_aSizeFunctions;
bool m_bParentCanChange;
// bool m_bParentCanChange;
};
template<class TOwnerFactory, class TBoxThemeWidget, class TBoxWidget>
......@@ -104,7 +105,6 @@ BoxThemeWidget<TOwnerFactory, TBoxThemeWidget, TBoxWidget>
, m_nPixY(0)
, m_nPixW(0)
, m_nPixH(0)
, m_bParentCanChange(false)
{
setChildren(aChildTW);
}
......@@ -125,7 +125,6 @@ void BoxThemeWidget<TOwnerFactory, TBoxThemeWidget, TBoxWidget>
m_nPixY = 0;
m_nPixW = 0;
m_nPixH = 0;
m_bParentCanChange = false;
setChildren(aChildTW);
}
template<class TOwnerFactory, class TBoxThemeWidget, class TBoxWidget>
......@@ -156,9 +155,9 @@ const std::pair<SegmentedFunction, SegmentedFunction>& BoxThemeWidget<TOwnerFact
return m_aSizeFunctions[nLayoutConfig];
}
template<class TOwnerFactory, class TBoxThemeWidget, class TBoxWidget>
void BoxThemeWidget<TOwnerFactory, TBoxThemeWidget, TBoxWidget>::sizeAndConfig(int32_t nTileSize, int32_t nLayoutConfig)
void BoxThemeWidget<TOwnerFactory, TBoxThemeWidget, TBoxWidget>::sizeAndConfig(int32_t nTileW, int32_t nLayoutConfig)
{
m_nTileW = nTileSize;
m_nTileW = nTileW;
m_nLayoutConfig = nLayoutConfig;
const auto& oPair = getSizeFunctions(nLayoutConfig);
const SegmentedFunction& oWFun = oPair.first;
......@@ -255,7 +254,6 @@ void BoxThemeWidget<TOwnerFactory, TBoxThemeWidget, TBoxWidget>
int32_t nCurPosY = oWidgetRect.m_nY;
nIdx = (bInvertChildren ? nTotChildren - 1 : 0);
for (; (nIdx >= 0) && (nIdx < nTotChildren); nIdx += nIdxInc) {
//for (auto& refChildTW : aChildren) {
auto& refChildTW = aChildren[nIdx];
//std::cout << "BoxThemeWidget<>::placeAndMaybeResizeIn CHILD adr=" << reinterpret_cast<int64_t>(refChildTW.get()) << '\n';
//std::cout << " nIdx=" << nIdx << " nCurPosX=" << nCurPosX << " nCurPosY=" << nCurPosY << '\n';
......@@ -297,12 +295,6 @@ void BoxThemeWidget<TOwnerFactory, TBoxThemeWidget, TBoxWidget>
template<class TOwnerFactory, class TBoxThemeWidget, class TBoxWidget>
void BoxThemeWidget<TOwnerFactory, TBoxThemeWidget, TBoxWidget>::onAssignedToLayout()
{
ThemeContainerWidget* p0Container = getParent();
if (p0Container != nullptr) {
m_bParentCanChange = p0Container->canChange();
} else {
m_bParentCanChange = false;
}
}
template<class TOwnerFactory, class TBoxThemeWidget, class TBoxWidget>
std::pair<SegmentedFunction, SegmentedFunction> BoxThemeWidget<TOwnerFactory, TBoxThemeWidget, TBoxWidget>
......@@ -338,7 +330,7 @@ void BoxThemeWidget<TOwnerFactory, TBoxThemeWidget, TBoxWidget>::onRecalcSizeFun
template<class TOwnerFactory, class TBoxThemeWidget, class TBoxWidget>
bool BoxThemeWidget<TOwnerFactory, TBoxThemeWidget, TBoxWidget>::canChange() const
{
return m_bParentCanChange;
return false;
}
template<class TOwnerFactory, class TBoxThemeWidget, class TBoxWidget>
NSize BoxThemeWidget<TOwnerFactory, TBoxThemeWidget, TBoxWidget>::getSize() const
......@@ -357,48 +349,14 @@ void BoxThemeWidget<TOwnerFactory, TBoxThemeWidget, TBoxWidget>::setPos(int32_t
m_nPixY = nPixY;
}
template<class TOwnerFactory, class TBoxThemeWidget, class TBoxWidget>
bool BoxThemeWidget<TOwnerFactory, TBoxThemeWidget, TBoxWidget>::drawIfChanged(const Cairo::RefPtr<Cairo::Context>& refCc)
bool BoxThemeWidget<TOwnerFactory, TBoxThemeWidget, TBoxWidget>::drawIfChanged(const Cairo::RefPtr<Cairo::Context>& /*refCc*/)
{
if (!m_bParentCanChange) {
return false; //--------------------------------------------------------
}
//TODO if the box was newly places within its parent or has been resized
// a draw() instead of a drawIfChanged() must be forced
ThemeContainerWidget* p0Container = getParent();
const bool bHasContainer = (p0Container != nullptr);
if (!bHasContainer) {
return false; //--------------------------------------------------------
}
refCc->save();
refCc->rectangle(m_nPixX, m_nPixY, m_nPixW, m_nPixH);
refCc->clip();
const bool bContainerChanged = p0Container->drawIfChanged(refCc);
//#ifndef NDEBUG
//refCc->set_line_width(1.5);
//refCc->rectangle(m_nPixX + 1, m_nPixY + 1, m_nPixW - 2, m_nPixH - 2);
//refCc->stroke();
//#endif //NDEBUG
refCc->restore();
return bContainerChanged;
return false;
}
template<class TOwnerFactory, class TBoxThemeWidget, class TBoxWidget>
void BoxThemeWidget<TOwnerFactory, TBoxThemeWidget, TBoxWidget>::draw(const Cairo::RefPtr<Cairo::Context>& refCc)
void BoxThemeWidget<TOwnerFactory, TBoxThemeWidget, TBoxWidget>::draw(const Cairo::RefPtr<Cairo::Context>& /*refCc*/)
{
ThemeContainerWidget* p0Container = getParent();
const bool bHasContainer = (p0Container != nullptr);
if (!bHasContainer) {
return; //--------------------------------------------------------------
}
refCc->save();
refCc->rectangle(m_nPixX, m_nPixY, m_nPixW, m_nPixH);
refCc->clip();
p0Container->draw(refCc);
//#ifndef NDEBUG
//refCc->set_line_width(1.5);
//refCc->rectangle(m_nPixX + 1, m_nPixY + 1, m_nPixW - 2, m_nPixH - 2);
//refCc->stroke();
//#endif //NDEBUG
refCc->restore();
//std::cout << "BoxThemeWidget<>::draw m_nPixX=" << m_nPixX << " m_nPixY=" << m_nPixY << " m_nPixW=" << m_nPixW << " m_nPixH=" << m_nPixH << '\n';
}
////////////////////////////////////////////////////////////////////////////////
......@@ -408,7 +366,7 @@ class BoxThemeWidgetFactory : public StdThemeWidgetFactory
public:
BoxThemeWidgetFactory(StdTheme* p1Owner);
shared_ptr<ThemeWidget> create(const shared_ptr<GameWidget>& refGameWidget
, double fTileWHRatio, const Glib::RefPtr<Pango::Layout>& refFontLayout) override;
, double fTileWHRatio, const Glib::RefPtr<Pango::Context>& refFontContext) override;
private:
Recycler<TBoxThemeWidget> m_oBoxThemeWidgets;
};
......@@ -426,12 +384,12 @@ template<class TOwnerFactory, class TBoxThemeWidget, class TBoxWidget>
shared_ptr<ThemeWidget> BoxThemeWidgetFactory<TOwnerFactory, TBoxThemeWidget, TBoxWidget>::create(
const shared_ptr<GameWidget>& refGameWidget
, double fTileWHRatio
, const Glib::RefPtr<Pango::Layout>& refFontLayout)
, const Glib::RefPtr<Pango::Context>& refFontContext)
{
//std::cout << "BoxThWidgetFactory::create FACTORY:" << reinterpret_cast<int64_t>(this) << '\n';
assert(refGameWidget);
assert(fTileWHRatio > 0);
assert(refFontLayout);
assert(refFontContext);
StdTheme* p0StdTheme = owner();
if (p0StdTheme == nullptr) {
return shared_ptr<ThemeWidget>{}; //------------------------------------
......@@ -445,7 +403,7 @@ shared_ptr<ThemeWidget> BoxThemeWidgetFactory<TOwnerFactory, TBoxThemeWidget, TB
std::vector< shared_ptr<ThemeWidget> > aChildTW;
auto& aChildWidget = p0BoxWidget->getChildren();
for (auto& refChildGW : aChildWidget) {
auto refChildTW = p0StdTheme->createWidget(refChildGW, fTileWHRatio, refFontLayout);
auto refChildTW = p0StdTheme->createWidget(refChildGW, fTileWHRatio, refFontContext);
if (refChildTW) {
aChildTW.push_back(refChildTW);
}
......
......@@ -37,33 +37,6 @@ using std::shared_ptr;
namespace CommonTheme
{
/** Set text of a Pango layout.
* @param refLayout The layout. Cannot be null.
* @param sFont The font name.
* @param nFontSize The font size.
* @param sText The text.
* @param nTextW [output] The width of the text.
* @param nTextH [output] The height of the text.
*/
void textToLayout(const Glib::RefPtr<Pango::Layout>& refLayout
, const std::string& sFont, int32_t nFontSize, const std::string& sText
, int32_t& nTextW, int32_t& nTextH);
/** Set text of a Pango layout.
* @param refLayout The layout. Cannot be null.
* @param sFont The font name.
* @param nFontSize The font size.
* @param bSetWeight Whether to set the weight of the font.
* @param eWight The weight of the font (only if bSetWeight is true).
* @param bSetStyle Whether to set the style of the font.
* @param eStyle The style of the font (only if bSetStyle is true).
* @param sText The text.
* @param nTextW [output] The width of the text.
* @param nTextH [output] The height of the text.
*/
void textToLayout(const Glib::RefPtr<Pango::Layout>& refLayout, const std::string& sFont, int32_t nFontSize
, bool bSetWeight, Pango::Weight eWight, bool bSetStyle, Pango::Style eStyle
, const std::string& sText
, int32_t& nTextW, int32_t& nTextH);
struct NamedRgbColor
{
......
......@@ -20,7 +20,7 @@
#ifndef STMG_GAME_LOADER_H
#define STMG_GAME_LOADER_H
#include "file.h"
#include "util/file.h"
#include "gameconstraints.h"
#include <stmm-games/highscoresdefinition.h>
......
......@@ -55,32 +55,10 @@ public:
{
return m_p0LevelShowWidget;
}
void dump(int32_t
#ifndef NDEBUG
nIndentSpaces
#endif //NDEBUG
, bool /*bHeader*/) const override
{
#ifndef NDEBUG
ThemeWidget::dump(nIndentSpaces, false);
#endif //NDEBUG
}
void dump(int32_t nIndentSpaces, bool bHeader) const override;
protected:
LevelShowThemeWidget(const shared_ptr<GameWidget>& refModel)
: ThemeWidget(refModel)
, ThemeWidgetInteractive(this, (assert(dynamic_cast<LevelShowWidget*>(refModel.get()) != nullptr)
, static_cast<LevelShowWidget*>(refModel.get())->isInteractive()))
, m_p0LevelShowWidget(static_cast<LevelShowWidget*>(refModel.get()))
{
}
void reInit(const shared_ptr<GameWidget>& refModel)
{
ThemeWidget::reInit(refModel);
auto p0Model = refModel.get();
assert(dynamic_cast<LevelShowWidget*>(p0Model) != nullptr);
m_p0LevelShowWidget = static_cast<LevelShowWidget*>(p0Model);
ThemeWidgetInteractive::reInit(this, m_p0LevelShowWidget->isInteractive());
}
LevelShowThemeWidget(const shared_ptr<GameWidget>& refModel);
void reInit(const shared_ptr<GameWidget>& refModel);
private:
LevelShowWidget* m_p0LevelShowWidget;
};
......
......@@ -24,7 +24,7 @@
#include "themeloader.h"
#include "highscoresloader.h"
#include "allpreferencesloader.h"
#include "file.h"
#include "util/file.h"
#include <stmm-games/stdconfig.h>
......@@ -56,7 +56,7 @@ struct MainWindowData
NSize m_oInitialSize = NSize{400, 600}; /**< The initial window size. Default: 400x600 pixel. */
};
/** Creates the game window
/** Creates the game window.
* @param oMainWindowData The initialization data.
* @return The window or null and the error string if an error occurred.
*/
......
......@@ -25,10 +25,13 @@
#include "commontheme.h"
#include <string>
#include <memory>
namespace stmg
{
using std::unique_ptr;
class StdTheme;
class TextModifier : public StdThemeModifier
......@@ -41,6 +44,9 @@ public:
FLOW_CONTROL drawTile(const Cairo::RefPtr<Cairo::Context>& refCc, StdThemeDrawingContext& oDc
, const Tile& oTile, int32_t nPlayer, const std::vector<double>& aAniElapsed) override;
private:
Pango::Context* m_p0CacheContext;
Glib::RefPtr<Pango::Layout> m_refFontLayout;
unique_ptr<Pango::FontDescription> m_refFont;
const std::string m_sText;
bool m_bUseTileColor;
bool m_bCalcColor;
......
......@@ -22,7 +22,7 @@
#include "stdthememodifier.h"
#include "tileani.h"
#include "util/tileani.h"
#include <memory>
......
......@@ -23,13 +23,14 @@
#include "theme.h"
#include "stdthemecontext.h"
#include "stdthemeanimationfactory.h"
#include "file.h"
#include "stdthememodifier.h"
#include "stdthemewidgetfactory.h"
#include "modifiers/nextthememodifier.h"
#include "modifiers/stopmodifier.h"
#include "tileani.h"
#include "tilesizing.h"
#include "util/file.h"
#include "util/tileani.h"
#include "util/tilesizing.h"
#include <stmm-games/tile.h>
#include <stmm-games/traitset.h>
......@@ -85,9 +86,9 @@ public:
void registerTileSize(int32_t nW, int32_t nH) override;
void unregisterTileSize(int32_t nW, int32_t nH) override;
shared_ptr<ThemeContext> createContext(int32_t nTileW, int32_t nTileH, const Glib::RefPtr<Pango::Layout>& refFontLayout) override;
shared_ptr<ThemeContext> createContext(int32_t nTileW, int32_t nTileH, const Glib::RefPtr<Pango::Context>& refFontContext) override;
shared_ptr<ThemeWidget> createWidget(const shared_ptr<GameWidget>& refGameWidget, double fTileWHRatio
, const Glib::RefPtr<Pango::Layout>& refFontLayout) override;
, const Glib::RefPtr<Pango::Context>& refFontContext) override;
//
const Named& getNamed() const override { return m_oNamed; }
/** The named values.
......@@ -187,11 +188,14 @@ public:
* @return Whether the font name was defined.
*/
bool getNamedFont(int32_t nFontIdx, std::string& sFontDesc);
/** Whether the default font was set.
* @return Whether set.
*/
bool isDefaultFontDefined() const;
/** Get default font description.
* @param sFontDesc [output] The font description (see Pango::FontDescription).
* @return Whether the default font was defined.
* @return The default font description (see Pango::FontDescription).
*/
bool getDefaultFont(std::string& sFontDesc);
const std::string& getDefaultFont() const;</