From ecc658703c19dee057e2b00482ee73258c058015 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Sun, 8 Sep 2019 10:37:33 +0300 Subject: [PATCH] Fixed: Table cell background should be on top-left with no overflow. --HG-- branch : html-improvements --- code/nel/include/nel/gui/group_table.h | 9 ++++ code/nel/src/gui/group_table.cpp | 64 +++++++++++++++++--------- 2 files changed, 50 insertions(+), 23 deletions(-) diff --git a/code/nel/include/nel/gui/group_table.h b/code/nel/include/nel/gui/group_table.h index 2be9ef98c..20900228b 100644 --- a/code/nel/include/nel/gui/group_table.h +++ b/code/nel/include/nel/gui/group_table.h @@ -96,6 +96,11 @@ namespace NLGUI bool _UserTexture; bool _TextureTiled; bool _TextureScaled; + // cached absolute coords for background texture + sint32 _TextureXReal; + sint32 _TextureYReal; + sint32 _TextureWReal; + sint32 _TextureHReal; // Alignment TAlign Align; @@ -112,10 +117,14 @@ namespace NLGUI void setTextureTile(bool tiled); void setTextureScale(bool scaled); + virtual void updateCoords(); + static void setDebugUICell( bool d ){ DebugUICell = d; } static bool getDebugUICell(){ return DebugUICell; } private: + void updateTextureCoords(); + void setEnclosedGroupDefaultParams(); static bool DebugUICell; }; diff --git a/code/nel/src/gui/group_table.cpp b/code/nel/src/gui/group_table.cpp index 45c3b7e1e..d703f941a 100644 --- a/code/nel/src/gui/group_table.cpp +++ b/code/nel/src/gui/group_table.cpp @@ -62,6 +62,10 @@ namespace NLGUI _UserTexture = false; _TextureTiled = false; _TextureScaled = false; + _TextureXReal = 0; + _TextureYReal = 0; + _TextureWReal = 0; + _TextureHReal = 0; setEnclosedGroupDefaultParams(); addGroup (Group); } @@ -492,36 +496,23 @@ namespace NLGUI col = CRGBA(255,255,255,255); else col = BgColor; - - + + sint32 oldSciX, oldSciY, oldSciW, oldSciH; + makeNewClip (oldSciX, oldSciY, oldSciW, oldSciH); + if (_TextureScaled && !_TextureTiled) { - rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, - _WReal, _HReal, - 0, false, - _TextureId, - col ); + rVR.drawRotFlipBitmap(_RenderLayer, _TextureXReal, _TextureYReal, _WReal, _HReal, 0, false, _TextureId, col); } else { if (!_TextureTiled) - { - rVR.draw11RotFlipBitmap (_RenderLayer, _XReal, _YReal, - 0, false, - _TextureId, - col); - } + rVR.drawRotFlipBitmap(_RenderLayer, _TextureXReal, _TextureYReal, _TextureWReal, _TextureHReal, 0, false, _TextureId, col); else - { - rVR.drawRotFlipBitmapTiled(_RenderLayer, _XReal, _YReal, - _WReal, _HReal, - 0, false, - _TextureId, - 0, - col); - } + rVR.drawRotFlipBitmapTiled(_RenderLayer, _TextureXReal, _TextureYReal, _WReal, _TextureHReal, 0, false, _TextureId, 0, col); } - + + restoreClip (oldSciX, oldSciY, oldSciW, oldSciH); } else { @@ -534,7 +525,7 @@ namespace NLGUI CGroupTable *table = static_cast (getParent ()); finalColor.A = (uint8) (((uint16) table->CurrentAlpha * (uint16) finalColor.A) >> 8); } - + //nlinfo("Blank Texture"); rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, _WReal, _HReal, 0, false, rVR.getBlankTextureId(), finalColor); } @@ -592,6 +583,8 @@ namespace NLGUI nlinfo("Set texture to cell : %s", TxName.c_str()); _UserTexture = true; _TextureId.setTexture (TxName.c_str (), 0, 0, -1, -1, false); + + updateTextureCoords(); } } @@ -611,6 +604,31 @@ namespace NLGUI _TextureScaled = scaled; } + // ---------------------------------------------------------------------------- + void CGroupCell::updateTextureCoords() + { + if (_TextureId < 0) return; + + CViewRenderer &rVR = *CViewRenderer::getInstance(); + rVR.getTextureSizeFromId (_TextureId, _TextureWReal, _TextureHReal); + + _TextureXReal = _XReal; + _TextureYReal = _YReal + _HReal - _TextureHReal; + if (_TextureTiled && _TextureHReal > 0) + { + sint diff = (_HReal / _TextureHReal) * _TextureHReal; + _TextureYReal -= diff; + _TextureHReal += diff; + } + } + + // ---------------------------------------------------------------------------- + void CGroupCell::updateCoords() + { + CInterfaceGroup::updateCoords(); + + updateTextureCoords(); + } // ---------------------------------------------------------------------------- NLMISC_REGISTER_OBJECT(CViewBase, CGroupTable, std::string, "table");