diff options
author | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
---|---|---|
committer | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
commit | 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch) | |
tree | 12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Wasabi/api/skin/widgets/stats | |
parent | 537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff) | |
download | winamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz |
Initial community commit
Diffstat (limited to 'Src/Wasabi/api/skin/widgets/stats')
-rw-r--r-- | Src/Wasabi/api/skin/widgets/stats/statswnd.cpp | 38 | ||||
-rw-r--r-- | Src/Wasabi/api/skin/widgets/stats/statswnd.h | 18 | ||||
-rw-r--r-- | Src/Wasabi/api/skin/widgets/stats/xuistats.cpp | 149 | ||||
-rw-r--r-- | Src/Wasabi/api/skin/widgets/stats/xuistats.h | 43 |
4 files changed, 248 insertions, 0 deletions
diff --git a/Src/Wasabi/api/skin/widgets/stats/statswnd.cpp b/Src/Wasabi/api/skin/widgets/stats/statswnd.cpp new file mode 100644 index 00000000..116c6c95 --- /dev/null +++ b/Src/Wasabi/api/skin/widgets/stats/statswnd.cpp @@ -0,0 +1,38 @@ +#include <precomp.h> +#include "statswnd.h" +#include <bfc/string/StringW.h> + +StatsWnd::StatsWnd() +{ + registerXml(); + WASABI_API_WNDMGR->autopopup_registerGroupId(L"statswnd.group", L"Internal Statistics"); + WASABI_API_SYSCB->syscb_registerCallback(this); +} + +StatsWnd::~StatsWnd() +{ + WASABI_API_SYSCB->syscb_deregisterCallback(this); +} + +int StatsWnd::skincb_onBeforeLoadingElements() +{ + registerXml(); + return 1; +} + +void StatsWnd::registerXml() +{ + StringW xml; + + xml = L"buf:"; + + xml += L"<?xml version=\"1.0\" encoding=\"UTF-16\" standalone=\"yes\"?>\n"; + xml += L"<WasabiXml version=\"1.0\">\n"; + xml += L"<groupdef id=\"statswnd.group\" name=\"Internal Statistics\">\n"; + xml += L" <Wasabi:Stats fitparent=\"1\" />\n"; + xml += L"</groupdef>\n"; + xml += L"</WasabiXml>\n"; + + WASABI_API_SKIN->loadSkinFile(xml); +} + diff --git a/Src/Wasabi/api/skin/widgets/stats/statswnd.h b/Src/Wasabi/api/skin/widgets/stats/statswnd.h new file mode 100644 index 00000000..8b66ad14 --- /dev/null +++ b/Src/Wasabi/api/skin/widgets/stats/statswnd.h @@ -0,0 +1,18 @@ +#ifndef __STATSWND_H +#define __STATSWND_H + +#include <api/syscb/callbacks/skincb.h> + +class StatsWnd : public SkinCallbackI { + public: + StatsWnd(); + virtual ~StatsWnd(); + + virtual int skincb_onBeforeLoadingElements(); + + private: + void registerXml(); + +}; + +#endif diff --git a/Src/Wasabi/api/skin/widgets/stats/xuistats.cpp b/Src/Wasabi/api/skin/widgets/stats/xuistats.cpp new file mode 100644 index 00000000..dd4f2927 --- /dev/null +++ b/Src/Wasabi/api/skin/widgets/stats/xuistats.cpp @@ -0,0 +1,149 @@ +#include <precomp.h> +#include "xuistats.h" +#include <tataki/canvas/ifc_canvas.h> +#include <tataki/color/skinclr.h> +#include <api.h> + +#include <api/imgldr/imgldr.h> +#include <api/skin/skinparse.h> +#include <api/skin/gammamgr.h> +#include <api/skin/skinelem.h> +#include <api/skin/regioncache.h> +#include <api/wnd/wndtrack.h> +#include <api/font/font.h> +#include <api/wnd/wndapi.h> +#include <api/skin/guitree.h> +#include <api/xml/xmlreader.h> +#include <api/skin/groupwndcreate.h> +#include <api/skin/groupmgr.h> +#include <api/script/script.h> +#include "bfc/ptrlist.h" +#include "bfc/memblock.h" + +// ----------------------------------------------------------------------- +const wchar_t XuiStatsXuiObjectStr[] = L"Wasabi:Stats"; // This is the xml tag +char XuiStatsXuiSvcName[] = "Wasabi:Stats xui object"; + + +// ----------------------------------------------------------------------- +XuiStats::XuiStats() { + hastimer = 0; + line = 0; + col = 0; + curcanvas = NULL; +} + +// ----------------------------------------------------------------------- +XuiStats::~XuiStats() { + if (hastimer) + killTimer(0x10); +} + +// ----------------------------------------------------------------------- +int XuiStats::onInit() { + XUISTATS_PARENT::onInit(); + return 1; +} + +// ----------------------------------------------------------------------- +#define MARGIN 10 +#define FONTSIZE 15 +#define LINEMUL 15 +#define COLMUL 200 +void XuiStats::doTextOut(Canvas *canvas, const wchar_t *text, int line, int col, const Wasabi::FontInfo *fontInfo) +{ + RECT r; + getClientRect(&r); + if (!canvas || !text || !*text) return; + canvas->textOutEllipsed(r.left+MARGIN+col*COLMUL, r.top+MARGIN+line*LINEMUL, COLMUL-MARGIN/2, LINEMUL, text, fontInfo); +} + +// ----------------------------------------------------------------------- +void XuiStats::addLine(const wchar_t *txt, const Wasabi::FontInfo *fontInfo) +{ + if (!curcanvas) return; + RECT r; + getClientRect(&r); + if (line * LINEMUL + MARGIN + FONTSIZE + r.top > r.bottom) + { col++; line = 0; if (*txt == 0) return; } + doTextOut(curcanvas, txt, line++, col, fontInfo); +} + +// ----------------------------------------------------------------------- +int XuiStats::onPaint(Canvas *canvas) +{ + XUISTATS_PARENT::onPaint(canvas); + curcanvas = canvas; + line = 0; + col = 0; + + Wasabi::FontInfo fontInfo; + fontInfo.face = wasabi_default_fontnameW; + fontInfo.pointSize = FONTSIZE; + fontInfo.color = SkinColor(L"wasabi.list.text"); + + addLine(L"---------------------------- System ------", &fontInfo); + //addLine( StringPrintfW(L"entries in ptrlists : %d", ptrlist_totalnitems) ); +#ifdef _DEBUG + addLine( StringPrintfW(L"total memblocks size : %d", memblocks_totalsize) , &fontInfo); +#endif + + // TODO: add to api_timer - addLine( StringPrintfW(L"timers : %d/%d", mainmultiplex->getNumTimers(), mainmultiplex->getNumTimersLP()) , &fontInfo); + + addLine(L"", &fontInfo); + addLine(L"----------------------------- Wnds -------", &fontInfo); + addLine( StringPrintfW(L"rootwnds : %d", windowTracker->getNumAllWindows()) , &fontInfo); + addLine( StringPrintfW(L"desktop rootwnds : %d", windowTracker->getNumWindows()) , &fontInfo); + + addLine(L"", &fontInfo); + addLine(L"--------------------------- ImgLdr -------", &fontInfo); + addLine( StringPrintfW(L"bytes in imgldr : %d", imageLoader::getMemUsage()) , &fontInfo); + addLine( StringPrintfW(L"cached imgldr entries : %d", imageLoader::getNumCached()) , &fontInfo); + addLine( StringPrintfW(L"region caches : %d", RegionCache::getNumCaches()) , &fontInfo); + + addLine(L"", &fontInfo); + addLine(L"----------------------------- Skin -------", &fontInfo); + addLine( StringPrintfW(L"skin bitmap elements : %d", WASABI_API_PALETTE->getNumBitmapElement()) , &fontInfo); + addLine( StringPrintfW(L"skin color elements : %d", WASABI_API_PALETTE->getNumColorElements()) , &fontInfo); + addLine( StringPrintfW(L"containers loaded : %d", SkinParser::getNumContainers()) , &fontInfo); + addLine( StringPrintfW(L"gamma sets : %d", WASABI_API_COLORTHEMES->getNumGammaSets()) , &fontInfo); + addLine( StringPrintfW(L"fonts : %d", Font::getNumFonts()) , &fontInfo); + addLine( StringPrintfW(L"base textures : %d", WndApi::getNumBaseTextures()) , &fontInfo); + addLine( StringPrintfW(L"guitree entries : %d", guiTree->getNumObject()) , &fontInfo); + addLine( StringPrintfW(L"wndtype groups : %d", GroupWndCreateSvc::num_group_list) , &fontInfo); + addLine( StringPrintfW(L"hosted groups : %d", GroupMgr::getNumGroups()) , &fontInfo); + addLine( StringPrintfW(L"scripts : %d", Script::getNumScripts()) , &fontInfo); + + addLine(L"", &fontInfo); + addLine(L"----------------------------- Misc -------", &fontInfo); + addLine( StringPrintfW(L"registered cfgitems : %d", WASABI_API_CONFIG->config_getNumCfgItems()) , &fontInfo); + + if (WASABI_API_THREADPOOL) + { + addLine(L"", &fontInfo); + addLine(L"----------------------------- ThreadPool -------", &fontInfo); + addLine( StringPrintfW(L"active threads : %d", WASABI_API_THREADPOOL->GetNumberOfActiveThreads()) , &fontInfo); + addLine( StringPrintfW(L"threads in pool : %d", WASABI_API_THREADPOOL->GetNumberOfThreads()) , &fontInfo); + } + + curcanvas = NULL; + return 1; +} + +// ----------------------------------------------------------------------- +void XuiStats::onSetVisible(int show) { + XUISTATS_PARENT::onSetVisible(show); + if (show) { + setTimer(0x10, 250); + } else { + killTimer(0x10); + } + hastimer = show; +} + +// ----------------------------------------------------------------------- +void XuiStats::timerCallback(int p1) { + if (p1 == 0x10) invalidate(); + else XUISTATS_PARENT::timerCallback(p1); +} + diff --git a/Src/Wasabi/api/skin/widgets/stats/xuistats.h b/Src/Wasabi/api/skin/widgets/stats/xuistats.h new file mode 100644 index 00000000..c6b91a6a --- /dev/null +++ b/Src/Wasabi/api/skin/widgets/stats/xuistats.h @@ -0,0 +1,43 @@ +#ifndef __XUISTATS_H +#define __XUISTATS_H + +#include <api/wnd/wndclass/guiobjwnd.h> + +#define XUISTATS_PARENT GuiObjectWnd + +// {12D9C377-A981-4b77-95E0-242AF7226960} +static const GUID COLOREDIT_PREVIEWRECT_GUID = +{ 0x12d9c377, 0xa981, 0x4b77, { 0x95, 0xe0, 0x24, 0x2a, 0xf7, 0x22, 0x69, 0x60 } }; + +class ColorEditorInstance; + +// ----------------------------------------------------------------------- +class XuiStats : public XUISTATS_PARENT { + + public: + + XuiStats(); + virtual ~XuiStats(); + + virtual int onInit(); + virtual int onPaint(Canvas *c); + virtual void onSetVisible(int show); + virtual void timerCallback(int p1); + + virtual void addLine(const wchar_t *txt, const Wasabi::FontInfo *fontInfo); + + private: + void doTextOut(Canvas *canvas, const wchar_t *text, int line, int col, const Wasabi::FontInfo *fontInfo); + int hastimer; + + int line ; + int col; + Canvas *curcanvas; +}; + +// ----------------------------------------------------------------------- +extern const wchar_t XuiStatsXuiObjectStr[]; +extern char XuiStatsXuiSvcName[]; +class XuiStatsXuiSvc : public XuiObjectSvc<XuiStats, XuiStatsXuiObjectStr, XuiStatsXuiSvcName> {}; + +#endif |