Пример #1
0
fCoord ViewBody::globalPos() const
{
	fCoord ret = geometry().pos();
	for (View p = parent(); p; p = p->parent())
		ret += p->geometry().pos();
	return ret;
}
Пример #2
0
	void PositionedLayout::layout_subviews(Canvas &canvas, View *view)
	{
		for (const std::shared_ptr<View> &subview : view->subviews())
		{
			if (subview->hidden())
			{
				continue;
			}
			else if (subview->style_cascade().computed_value("position").is_keyword("absolute"))
			{
				// To do: decide how we determine the containing box used for absolute positioning. For now, use the parent content box.
				layout_from_containing_box(canvas, subview.get(), view->geometry().content_box());
			}
			else if (subview->style_cascade().computed_value("position").is_keyword("fixed"))
			{
				Rectf offset_initial_containing_box;
				View *current = view->superview();
				if (current)
				{
					Pointf offset(view->geometry().content_x, view->geometry().content_y);
					while (true)
					{
						offset = offset + Pointf(current->geometry().content_x, current->geometry().content_y);
						View *superview = current->superview();
						if (!superview)
						{
							offset_initial_containing_box = current->geometry().content_box();
							offset_initial_containing_box.set_top_left(offset_initial_containing_box.get_top_left() - offset);
							break;
						}
					}
				}
				else
				{
					offset_initial_containing_box = view->geometry().content_box();
				}

				layout_from_containing_box(canvas, subview.get(), offset_initial_containing_box);
			}

			layout_subviews(canvas, subview.get());
		}
	}
Пример #3
0
std::string lb::toString(View const& _v, std::string const& _insert)
{
	std::stringstream out;
	out << (_v->m_isEnabled ? "EN" : "--") << " "
		<< (_v->m_isShown ? "VIS" : "hid") << " "
		<< (_v->m_graphicsInitialized ? "GFX " : "___ ")
		<< "*" << _v->m_layers.size() << " [";
	for (auto const& i: _v->m_layers)
		out << (i.isDirty() ? i.isShown() ? "!" : "_" : i.isShown() ? "*" : "+");
	out	<< (_v->m_visibleLayoutChanged ? " LAY" : " lay") << "] "
		<< _insert
		<< _v->name() << ": "
//		<< _v->minimumSize() << " -> "
//		<< _v->maximumSize() << "  "
		<< _v->geometry() << " (" << _v->m_children.size() << " children)";
	out << (void*)_v.get();
	for (auto const& i: _v->m_misc)
	{
		try	{ int x = boost::any_cast<int>(i.second); out << " " << i.first << "=" << x; } catch (...) {}	// i.first (string) BAD!!!
		try	{ string x = boost::any_cast<string>(i.second); out << " " << i.first << "=" << x; } catch (...) {}
	}
	return out.str();
}