AnKor
Topic Author
Posts: 29
Joined: 22 Jul 2022, 16:14

Adorner with visual child

21 Jul 2024, 19:35

Hi!

I'm trying to create an Adorner that renders a child element (e.g. a Border) instead of overriding OnRender method.
I have found WPF example here https://stackoverflow.com/questions/857 ... stackpanel which is also very similar to your EffectAdorner code, so I thought it will be simple enough, but I can't get it to work - the Border is not rendered.
Everything seems correct in the Inspector: the Border is a child of TestAdorner and has expected placement and size. It just isn't visible for some reason.
Am I doing something wrong here or is this usage unsupported?
TestAdorner::TestAdorner(UIElement* pAdornedElement) : Adorner(pAdornedElement)
{
	Ptr<Border> pBorder = MakePtr<Border>();
	pBorder->SetBackground(Brushes::Red());
	m_pChild = pBorder;
	AddVisualChild(m_pChild);
}

uint32_t TestAdorner::GetVisualChildrenCount() const
{
	return 1;
}

Visual* TestAdorner::GetVisualChild(uint32_t index) const
{
	return m_pChild;
}

Noesis::Size TestAdorner::MeasureOverride(const Noesis::Size&)
{
	Noesis::UIElement* adornedElement = GetAdornedElement();
	const Noesis::Size& adornedSize = adornedElement->GetRenderSize();
	Noesis::Size finalSize = adornedSize;
	m_pChild->Measure(finalSize);
	return finalSize;
}

Noesis::Size TestAdorner::ArrangeOverride(const Noesis::Size&)
{
	const Noesis::Size& finalSize = GetDesiredSize();
	m_pChild->Arrange(Noesis::Rect(finalSize));
	return finalSize;
}
 
User avatar
sfernandez
Site Admin
Posts: 3109
Joined: 22 Dec 2011, 19:20

Re: Adorner with visual child

24 Jul 2024, 12:48

Hi,

It seems we have something wrong in our code and the child is not properly initialized. Could you please add a ticket in our bugtracker for this issue?
In the meantime, can you try to manually initialize it:
Ptr<Border> pBorder = MakePtr<Border>();
pBorder->Init();
Please let me know if that fixes your issue.
 
AnKor
Topic Author
Posts: 29
Joined: 22 Jul 2022, 16:14

Re: Adorner with visual child

24 Jul 2024, 19:36

Created #3549

And yes, calling Init() manually fixes the issue. Thanks!
 
User avatar
jsantos
Site Admin
Posts: 4067
Joined: 20 Jan 2012, 17:18
Contact:

Re: Adorner with visual child

25 Jul 2024, 12:00

Thanks for the report!

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 1 guest