finish basic work of fit-content
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Nana GUI Programming Interface Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -1439,5 +1439,29 @@ namespace API
|
||||
{
|
||||
restrict::wd_manager().set_safe_place(reinterpret_cast<basic_window*>(wd), std::move(fn));
|
||||
}
|
||||
|
||||
optional<std::pair<size, size>> content_extent(window wd, unsigned limited_px, bool limit_width)
|
||||
{
|
||||
auto iwd = reinterpret_cast<basic_window*>(wd);
|
||||
internal_scope_guard lock;
|
||||
|
||||
if (restrict::wd_manager().available(iwd) && iwd->annex.content_measurer)
|
||||
{
|
||||
paint::graphics* graph = &iwd->drawer.graphics;
|
||||
paint::graphics temp_graph;
|
||||
if (graph->empty())
|
||||
{
|
||||
temp_graph.make({ 1, 1 });
|
||||
temp_graph.typeface(graph->typeface());
|
||||
graph = &temp_graph;
|
||||
}
|
||||
|
||||
auto extent = iwd->annex.content_measurer->measure(*graph, limited_px, limit_width);
|
||||
if (extent)
|
||||
return std::make_pair(extent.value(), extent.value() + iwd->annex.content_measurer->extension());
|
||||
}
|
||||
|
||||
return{};
|
||||
}
|
||||
}//end namespace API
|
||||
}//end namespace nana
|
||||
|
||||
Reference in New Issue
Block a user