add new platform_abstraction

add support of loading ttf file
This commit is contained in:
Jinhao
2017-04-26 08:04:25 +08:00
parent 4aba8e8c7f
commit 2ff8a1c729
42 changed files with 876 additions and 398 deletions

View File

@@ -10,7 +10,7 @@
* @file: nana/gui/detail/bedrock_pi.cpp
*/
#include <nana/detail/platform_spec_selector.hpp>
#include "../../detail/platform_spec_selector.hpp"
#include <nana/gui/detail/bedrock_pi_data.hpp>
#include <nana/gui/detail/event_code.hpp>
#include <nana/system/platform.hpp>

View File

@@ -10,7 +10,7 @@
* @file: nana/gui/detail/linux_X11/bedrock.cpp
*/
#include <nana/detail/platform_spec_selector.hpp>
#include "../../detail/platform_spec_selector.hpp"
#if defined(NANA_POSIX) && defined(NANA_X11)
#include <nana/gui/detail/bedrock_pi_data.hpp>
#include <nana/gui/detail/event_code.hpp>

View File

@@ -12,7 +12,7 @@
* @contributors: Ariel Vina-Rodriguez
*/
#include <nana/detail/platform_spec_selector.hpp>
#include "../../detail/platform_spec_selector.hpp"
#if defined(NANA_WINDOWS)
#include <nana/gui/detail/bedrock.hpp>
#include <nana/gui/detail/bedrock_pi_data.hpp>

View File

@@ -18,7 +18,7 @@
#include "dynamic_drawing_object.hpp"
#if defined(NANA_X11)
#include <nana/detail/linux_X11/platform_spec.hpp>
#include "../../detail/posix/platform_spec.hpp"
#endif
namespace nana

View File

@@ -10,7 +10,7 @@
* @file: nana/gui/detail/native_window_interface.cpp
*/
#include <nana/detail/platform_spec_selector.hpp>
#include "../../detail/platform_spec_selector.hpp"
#include <nana/gui/detail/native_window_interface.hpp>
#include <nana/gui/screen.hpp>
#include <nana/gui/detail/bedrock.hpp>

View File

@@ -1397,13 +1397,13 @@ namespace detail
{
auto & tabs = wd->root_widget->other.attribute.root->tabstop;
auto end = tabs.cend();
if (forward)
{
if (detail::tab_type::none == wd->flags.tab)
return (tabs.front());
else if (detail::tab_type::tabstop & wd->flags.tab)
{
auto end = tabs.cend();
auto i = std::find(tabs.cbegin(), end, wd);
if (i != end)
{
@@ -1417,8 +1417,8 @@ namespace detail
}
else if (tabs.size() > 1) //at least 2 elments in tabs are required when moving backward.
{
auto i = std::find(tabs.cbegin(), tabs.cend(), wd);
if (i != tabs.cend())
auto i = std::find(tabs.cbegin(), end, wd);
if (i != end)
return (tabs.cbegin() == i ? tabs.back() : *(i - 1));
}
return nullptr;
@@ -1729,7 +1729,7 @@ namespace detail
if (established)
{
utl::erase(pa_children, wd);
utl::erase(wd->parent->children, wd);
if (for_new->children.empty())
wd->index = 0;
else
@@ -1892,15 +1892,20 @@ namespace detail
if(!wd->visible)
return nullptr;
for(auto i = wd->children.rbegin(); i != wd->children.rend(); ++i)
if (!wd->children.empty())
{
core_window_t* child = *i;
if((child->other.category != category::flags::root) && _m_effective(child, pos))
auto index = wd->children.size();
do
{
child = _m_find(child, pos);
if(child)
return child;
}
auto child = wd->children[--index];
if ((child->other.category != category::flags::root) && _m_effective(child, pos))
{
child = _m_find(child, pos);
if (child)
return child;
}
} while (0 != index);
}
return wd;
}

View File

@@ -133,9 +133,10 @@ namespace nana
if (base_.erase(wd))
{
wdcache_.insert(wd, false);
trash_.push_back(wd);
if (category::flags::root == wd->other.category)
{
trash_.push_back(wd);
auto i = std::find(queue_.begin(), queue_.end(), wd);
if (i != queue_.end())
queue_.erase(i);

View File

@@ -26,7 +26,7 @@
#include <mutex>
#endif
#include <nana/detail/platform_spec_selector.hpp>
#include "../detail/platform_spec_selector.hpp"
#if defined(NANA_LINUX) || defined(NANA_MACOS)
#include <nana/system/platform.hpp>

View File

@@ -28,7 +28,7 @@
#if defined(NANA_WINDOWS)
#include <windows.h>
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
#include <nana/detail/platform_spec_selector.hpp>
#include "../detail/platform_spec_selector.hpp"
#include <nana/system/platform.hpp>
#endif

View File

@@ -117,10 +117,10 @@ namespace nana
if((tv != align_v::top) && extent_v_pixels < graph.height())
{
rs.pos.y = static_cast<int>(graph.height() - extent_v_pixels);
if(align_v::center == tv)
rs.pos.y = static_cast<int>(graph.height() - extent_v_pixels) >> 1;
else if(align_v::bottom == tv)
rs.pos.y = static_cast<int>(graph.height() - extent_v_pixels);
rs.pos.y >>= 1;
}
else
rs.pos.y = 0;
@@ -203,7 +203,7 @@ namespace nana
}
private:
//Manage the fblock for a specified rectangle if it is a traceable fblock.
void _m_inser_if_traceable(int x, int y, const nana::size& sz, widgets::skeletons::fblock* fbp)
void _m_insert_if_traceable(int x, int y, const nana::size& sz, widgets::skeletons::fblock* fbp)
{
if(fbp->target.size() || fbp->url.size())
{
@@ -236,9 +236,9 @@ namespace nana
return fp->fgcolor;
}
std::size_t _m_font_size(nana::widgets::skeletons::fblock* fp) noexcept
double _m_font_size(nana::widgets::skeletons::fblock* fp) noexcept
{
while(fp->font_size == 0xFFFFFFFF)
while(fp->font_size == -1)
{
fp = fp->parent;
if(nullptr == fp)
@@ -274,12 +274,14 @@ namespace nana
if(fp != fblock_)
{
auto& name = _m_fontname(fp);
auto fontsize = static_cast<unsigned>(_m_font_size(fp));
auto fontsize = _m_font_size(fp);
bool bold = _m_bold(fp);
if((fontsize != font_.size()) || bold != font_.bold() || name != font_.name())
{
font_.make(name, fontsize, bold);
paint::font::font_style fs;
fs.weight = (bold ? 800 : 400);
font_ = paint::font{ name, fontsize, fs };
graph.typeface(font_);
}
fblock_ = fp;
@@ -345,7 +347,7 @@ namespace nana
std::vector<iterator> line_values;
for(auto i = line.begin(), end = line.end(); i != end; ++i)
for(auto i = line.begin(); i != line.end(); ++i)
{
data * data_ptr = i->data_ptr;
nana::size sz = data_ptr->size();
@@ -378,12 +380,11 @@ namespace nana
}
else
{
pixel_tag px;
_m_align_x_base(rs, px, (w ? w : sz.width));
if(w)
{
pixel_tag px;
_m_align_x_base(rs, px, w);
if(max_ascent + max_descent > max_px)
max_px = max_descent + max_ascent;
else
@@ -393,8 +394,6 @@ namespace nana
px.baseline = max_ascent;
px.values.swap(line_values);
rs.pixels.emplace_back(px);
w = sz.width;
max_px = sz.height;
max_ascent = as;
@@ -403,18 +402,16 @@ namespace nana
}
else
{
pixel_tag px;
_m_align_x_base(rs, px, sz.width);
px.pixels = sz.height;
px.baseline = as;
px.values.emplace_back(i);
rs.pixels.emplace_back(px);
max_px = 0;
max_ascent = max_descent = 0;
}
rs.pixels.emplace_back(px);
}
}
@@ -444,49 +441,48 @@ namespace nana
const int lastpos = static_cast<int>(graph.height()) - 1;
for(auto i = rs.pixels.begin(), end = rs.pixels.end(); i != end; ++i)
for(auto & px : rs.pixels)
{
for (auto & render_iterator : i->values)
for(auto & render_iterator: px.values)
{
auto & value = *render_iterator;
if(false == value.data_ptr->is_text())
{
if(text.size())
{
_m_draw_block(graph, text, block_start, rs);
if(lastpos <= rs.pos.y)
return false;
text.clear();
}
nana::size sz = value.data_ptr->size();
pixel_tag px = rs.pixels[rs.index];
if ((rs.allowed_width < rs.pos.x + sz.width) && (rs.pos.x != px.x_base))
{
//Change a line.
rs.pos.y += static_cast<int>(px.pixels);
px = rs.pixels[++rs.index];
rs.pos.x = px.x_base;
}
int y = rs.pos.y + _m_text_top(px, value.fblock_ptr, value.data_ptr);
value.data_ptr->nontext_render(graph, rs.pos.x, y);
_m_inser_if_traceable(rs.pos.x, y, sz, value.fblock_ptr);
rs.pos.x += static_cast<int>(sz.width);
if(lastpos < y)
return false;
}
else
if (value.data_ptr->is_text())
{
//hold the block while the text is empty,
//it stands for the first block
if(text.empty())
if (text.empty())
block_start = render_iterator;
text += value.data_ptr->text();
continue;
}
if(text.size())
{
_m_draw_block(graph, text, block_start, rs);
if(lastpos <= rs.pos.y)
return false;
text.clear();
}
nana::size sz = value.data_ptr->size();
pixel_tag px = rs.pixels[rs.index];
if ((rs.allowed_width < rs.pos.x + sz.width) && (rs.pos.x != px.x_base))
{
//Change a line.
rs.pos.y += static_cast<int>(px.pixels);
px = rs.pixels[++rs.index];
rs.pos.x = px.x_base;
}
int y = rs.pos.y + _m_text_top(px, value.fblock_ptr, value.data_ptr);
value.data_ptr->nontext_render(graph, rs.pos.x, y);
_m_insert_if_traceable(rs.pos.x, y, sz, value.fblock_ptr);
rs.pos.x += static_cast<int>(sz.width);
if(lastpos < y)
return false;
}
if(text.size())
@@ -575,7 +571,7 @@ namespace nana
}
_m_inser_if_traceable(rs.pos.x, y, sz, fblock_ptr);
_m_insert_if_traceable(rs.pos.x, y, sz, fblock_ptr);
rs.pos.x += static_cast<int>(sz.width);
if(text_range.second < len)
@@ -604,13 +600,13 @@ namespace nana
dstream dstream_;
bool format_enabled_ = false;
::nana::widgets::skeletons::fblock * fblock_ = nullptr;
std::deque<traceable> traceable_;
::std::deque<traceable> traceable_;
::nana::paint::font font_;
struct def_font_tag
{
::std::string font_name;
std::size_t font_size;
double font_size;
bool font_bold;
::nana::color fgcolor;
}def_;

View File

@@ -1953,7 +1953,6 @@ namespace nana
index_pairs already_selected;
index_pairs selections;
//nana::timer timer;
bool scroll_direction;
unsigned scroll_step{ 1 };
unsigned mouse_move_timestamp{ 0 };
@@ -4134,6 +4133,7 @@ namespace nana
}
else if (ptr_where.first == parts::list_blank) //not selected
{
//Start box selection if mulit-selection is enabled
if (arg.is_left_button() && (!lister.single_status(true)))
essence_->start_mouse_selection(arg.pos);