1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Remove 'visible' property from images, replaced with enable/disabled

call
This commit is contained in:
Ivan Savenko 2023-11-23 17:19:09 +02:00
parent 6dadcc2ca5
commit 0fd966818f
5 changed files with 18 additions and 17 deletions

View File

@ -310,8 +310,6 @@ std::shared_ptr<CPicture> InterfaceObjectConfigurable::buildPicture(const JsonNo
auto image = ImagePath::fromJson(config["image"]);
auto position = readPosition(config["position"]);
auto pic = std::make_shared<CPicture>(image, position.x, position.y);
if(!config["visible"].isNull())
pic->visible = config["visible"].Bool();
if ( config["playerColored"].Bool() && LOCPLINT)
pic->colorize(LOCPLINT->playerID);

View File

@ -22,10 +22,11 @@ ComboBox::DropDown::Item::Item(const JsonNode & config, ComboBox::DropDown & _dr
{
build(config);
if(auto w = widget<CPicture>("hoverImage"))
if(auto w = widget<CIntObject>("hoverImage"))
{
pos.w = w->pos.w;
pos.h = w->pos.h;
w->disable();
}
setRedrawParent(true);
}
@ -42,14 +43,14 @@ void ComboBox::DropDown::Item::updateItem(int idx, const void * _item)
void ComboBox::DropDown::Item::hover(bool on)
{
auto h = widget<CPicture>("hoverImage");
auto h = widget<CIntObject>("hoverImage");
auto w = widget<CLabel>("labelName");
if(h && w)
{
if(w->getText().empty())
h->visible = false;
if(w->getText().empty() || on == false)
h->disable();
else
h->visible = on;
h->enable();
}
redraw();
}

View File

@ -35,7 +35,6 @@
CPicture::CPicture(std::shared_ptr<IImage> image, const Point & position)
: bg(image)
, visible(true)
, needRefresh(false)
{
pos += position;
@ -53,7 +52,6 @@ CPicture::CPicture( const ImagePath & bmpname )
CPicture::CPicture( const ImagePath & bmpname, const Point & position )
: bg(GH.renderHandler().loadImage(bmpname))
, visible(true)
, needRefresh(false)
{
pos.x += position.x;
@ -81,13 +79,13 @@ CPicture::CPicture(std::shared_ptr<IImage> image, const Rect &SrcRect, int x, in
void CPicture::show(Canvas & to)
{
if (visible && needRefresh)
if (needRefresh)
showAll(to);
}
void CPicture::showAll(Canvas & to)
{
if(bg && visible)
if(bg)
{
if (srcRect.has_value())
to.draw(bg, pos.topLeft(), *srcRect);

View File

@ -34,10 +34,6 @@ public:
/// If set to true, iamge will be redrawn on each frame
bool needRefresh;
/// If set to false, image will not be rendered
/// Deprecated, use CIntObject::disable()/enable() instead
bool visible;
std::shared_ptr<IImage> getSurface()
{
return bg;

View File

@ -449,8 +449,16 @@ void CSpellWindow::setCurrentPage(int value)
schoolPicture->visible = selectedTab!=4 && currentPage == 0;
if(selectedTab != 4)
schoolPicture->setFrame(selectedTab, 0);
leftCorner->visible = currentPage != 0;
rightCorner->visible = (currentPage+1) < pagesWithinCurrentTab();
if (currentPage != 0)
leftCorner->enable();
else
leftCorner->disable();
if (currentPage + 1 < pagesWithinCurrentTab())
rightCorner->enable();
else
rightCorner->disable();
mana->setText(std::to_string(myHero->mana));//just in case, it will be possible to cast spell without closing book
}