fix mouse left button issues due to breaking changes
This commit is contained in:
parent
5dd5d110d7
commit
396163c1b7
@ -35,6 +35,7 @@
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <chrono>
|
||||
#include <cstddef>
|
||||
|
||||
#include <nana/deploy.hpp>
|
||||
|
||||
@ -160,24 +161,24 @@ namespace filesystem
|
||||
|
||||
struct directory_entry
|
||||
{
|
||||
path m_path;
|
||||
using path_type = filesystem::path;
|
||||
path_type m_path;
|
||||
|
||||
attribute attr{};
|
||||
//file_status m_status;
|
||||
attribute attr{};
|
||||
//file_status m_status;
|
||||
|
||||
directory_entry(){}
|
||||
directory_entry(const nana::string& filename_, bool is_directory, uintmax_t size)
|
||||
:m_path{filename_}, attr{size, is_directory}
|
||||
{}
|
||||
directory_entry(const path_type& p, bool is_directory, uintmax_t size)
|
||||
:m_path{p}, attr{size, is_directory}
|
||||
{}
|
||||
|
||||
void assign (const path& p){ m_path=p;}
|
||||
void replace_filename(const path& p){ m_path=p;}
|
||||
void assign (const path_type& p){ m_path=p;}
|
||||
void replace_filename(const path_type& p){ m_path=p;}
|
||||
|
||||
//file_status status() const;
|
||||
|
||||
operator const path&() const {return m_path;};
|
||||
const path& path() const {return m_path;}
|
||||
//file_status status() const;
|
||||
|
||||
operator const path_type&() const {return m_path;};
|
||||
const path_type& path() const {return m_path;}
|
||||
};
|
||||
|
||||
/// an iterator for a sequence of directory_entry elements representing the files in a directory, not an recursive_directory_iterator
|
||||
@ -186,10 +187,10 @@ namespace filesystem
|
||||
{
|
||||
public:
|
||||
using value_type = directory_entry ;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef const directory_entry* pointer;
|
||||
typedef const directory_entry& reference;
|
||||
typedef std::input_iterator_tag iterator_category;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef const directory_entry* pointer;
|
||||
typedef const directory_entry& reference;
|
||||
typedef std::input_iterator_tag iterator_category;
|
||||
|
||||
directory_iterator():end_(true), handle_(nullptr){}
|
||||
|
||||
@ -220,8 +221,8 @@ namespace filesystem
|
||||
|
||||
|
||||
// enable directory_iterator range-based for statements
|
||||
directory_iterator begin( ) { return *this; }
|
||||
directory_iterator end( ) { return {}; }
|
||||
directory_iterator begin( ) { return *this; }
|
||||
directory_iterator end( ) { return {}; }
|
||||
|
||||
private:
|
||||
template<typename Char>
|
||||
@ -285,16 +286,14 @@ namespace filesystem
|
||||
}
|
||||
|
||||
struct stat fst;
|
||||
bool is_directory = false;
|
||||
unsigned size = 0;
|
||||
if(stat((path_ + dnt->d_name).c_str(), &fst) == 0)
|
||||
{
|
||||
value_ = value_type(nana::charset(dnt->d_name), 0 != S_ISDIR(fst.st_mode), fst.st_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
value_.m_path = nana::charset(dnt->d_name);
|
||||
value_.size = 0;
|
||||
value_.directory = false;
|
||||
is_directory = (0 != S_ISDIR(fst.st_mode));
|
||||
size = fst.st_size;
|
||||
}
|
||||
value_ = value_type(static_cast<nana::string>(nana::charset(dnt->d_name)), is_directory, size);
|
||||
end_ = false;
|
||||
}
|
||||
}
|
||||
@ -342,7 +341,7 @@ namespace filesystem
|
||||
}
|
||||
struct stat fst;
|
||||
if(stat((path_ + "/" + dnt->d_name).c_str(), &fst) == 0)
|
||||
value_ = value_type(wfd_.cFileName,
|
||||
value_ = value_type(static_cast<nana::string>(nana::charset(wfd_.cFileName)),
|
||||
(FILE_ATTRIBUTE_DIRECTORY & wfd_.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY,
|
||||
wfd_.nFileSizeLow);
|
||||
else
|
||||
|
||||
@ -432,6 +432,12 @@ namespace nana
|
||||
bool right_button; ///< mouse right button is pressed?
|
||||
bool shift; ///< keyboard Shift is pressed?
|
||||
bool ctrl; ///< keyboard Ctrl is pressed?
|
||||
|
||||
/// Checks if left button is operated,
|
||||
bool is_left_button() const
|
||||
{
|
||||
return (event_code::mouse_move == evt_code ? left_button : (mouse::left_button == button));
|
||||
}
|
||||
};
|
||||
|
||||
/// in arg_wheel event_code is event_code::mouse_wheel
|
||||
|
||||
@ -235,9 +235,9 @@ namespace nana{ namespace widgets
|
||||
nana::upoint caret() const;
|
||||
bool scroll(bool upwards, bool vertical);
|
||||
bool mouse_enter(bool);
|
||||
bool mouse_down(bool left_button, const point& screen_pos);
|
||||
bool mouse_down(::nana::mouse, const point& screen_pos);
|
||||
bool mouse_move(bool left_button, const point& screen_pos);
|
||||
bool mouse_up(bool left_button, const point& screen_pos);
|
||||
bool mouse_up(::nana::mouse, const point& screen_pos);
|
||||
|
||||
skeletons::textbase<nana::char_t>& textbase();
|
||||
const skeletons::textbase<nana::char_t>& textbase() const;
|
||||
|
||||
@ -922,7 +922,7 @@ namespace detail
|
||||
{
|
||||
if(crt.visible && (false == caret_reinstate(crt)))
|
||||
{
|
||||
crt.rev_graph.bitblt(crt.size, crt.window, crt.pos);
|
||||
crt.rev_graph.bitblt(rectangle{crt.size}, crt.window, crt.pos);
|
||||
crt.rev.width = crt.size.width;
|
||||
crt.rev.height = crt.size.height;
|
||||
crt.rev.x = crt.pos.x;
|
||||
@ -948,7 +948,7 @@ namespace detail
|
||||
nana::paint::graphics * crt_graph;
|
||||
if(crt.rev.width && crt.rev.height)
|
||||
{
|
||||
crt.rev_graph.bitblt(crt.size, root_graph, crt.pos);
|
||||
crt.rev_graph.bitblt(rectangle{crt.size}, root_graph, crt.pos);
|
||||
crt_graph = &crt.graph;
|
||||
owns_caret = true;
|
||||
}
|
||||
@ -1132,7 +1132,7 @@ namespace detail
|
||||
{
|
||||
nana::paint::graphics & graph = iconbase_[wd];
|
||||
graph.make(img.size());
|
||||
img.paste(graph, 0, 0);
|
||||
img.paste(graph, {});
|
||||
return graph;
|
||||
}
|
||||
|
||||
|
||||
@ -580,9 +580,6 @@ namespace nana
|
||||
class element_manager
|
||||
: nana::noncopyable, nana::nonmovable
|
||||
{
|
||||
//VC2012 does not support alias declaration.
|
||||
//template<typename E> using factory_interface = element::provider::factory_interface<E>;
|
||||
|
||||
template<typename ElementInterface>
|
||||
struct item
|
||||
{
|
||||
|
||||
@ -622,7 +622,7 @@ namespace nana
|
||||
if(drawer_->widget_ptr()->enabled())
|
||||
{
|
||||
auto * editor = drawer_->editor();
|
||||
if(false == editor->mouse_down(arg.left_button, arg.pos))
|
||||
if(false == editor->mouse_down(arg.button, arg.pos))
|
||||
drawer_->open_lister_if_push_button_positioned();
|
||||
|
||||
drawer_->draw();
|
||||
@ -637,7 +637,7 @@ namespace nana
|
||||
{
|
||||
if (drawer_->widget_ptr()->enabled() && !drawer_->has_lister())
|
||||
{
|
||||
drawer_->editor()->mouse_up(arg.left_button, arg.pos);
|
||||
drawer_->editor()->mouse_up(arg.button, arg.pos);
|
||||
drawer_->set_button_state(element_state::hovered, false);
|
||||
drawer_->draw();
|
||||
API::lazy_refresh();
|
||||
|
||||
@ -34,7 +34,7 @@ namespace nana
|
||||
{
|
||||
if (state == StateHighlighted)
|
||||
{
|
||||
::nana::color clr{ 0xaf, 0xc7, 0xe3 };
|
||||
::nana::color clr(static_cast<color_rgb>(0xafc7e3));
|
||||
graph.rectangle(r, false, clr);
|
||||
|
||||
auto right = r.right() - 1;
|
||||
@ -276,7 +276,7 @@ namespace nana
|
||||
}
|
||||
}
|
||||
|
||||
bool right_area(graph_reference graph, int x, int y) const
|
||||
static bool right_area(graph_reference graph, int x, int y)
|
||||
{
|
||||
return ((1 < x && 1 < y) &&
|
||||
x < static_cast<int>(graph.width()) - 2 &&
|
||||
@ -325,7 +325,7 @@ namespace nana
|
||||
_m_open_scrollbar(*widget_, pages);
|
||||
}
|
||||
else
|
||||
graph_->string({ 4, 4 }, STR("Empty Listbox, No Module!"), {0x80, 0x80, 0x80});
|
||||
graph_->string({ 4, 4 }, STR("Empty Listbox, No Module!"), static_cast<color_rgb>(0x808080));
|
||||
|
||||
//Draw border
|
||||
graph_->rectangle(false, colors::black);
|
||||
@ -361,7 +361,7 @@ namespace nana
|
||||
|
||||
auto fn = [this](const arg_mouse& arg)
|
||||
{
|
||||
if (arg.left_button && (scrollbar_.value() != state_.offset_y))
|
||||
if (arg.is_left_button() && (scrollbar_.value() != state_.offset_y))
|
||||
{
|
||||
state_.offset_y = static_cast<unsigned>(scrollbar_.value());
|
||||
draw();
|
||||
@ -449,12 +449,16 @@ namespace nana
|
||||
|
||||
void trigger::mouse_up(graph_reference graph, const arg_mouse& arg)
|
||||
{
|
||||
if(drawer_->right_area(graph, arg.pos.x, arg.pos.y))
|
||||
bool close_wdg = false;
|
||||
if (drawer_->right_area(graph, arg.pos.x, arg.pos.y))
|
||||
{
|
||||
drawer_->set_result();
|
||||
drawer_->widget_ptr()->close();
|
||||
close_wdg = true;
|
||||
}
|
||||
else if(false == drawer_->ignore_emitting_mouseup())
|
||||
else
|
||||
close_wdg = (false == drawer_->ignore_emitting_mouseup());
|
||||
|
||||
if (close_wdg)
|
||||
drawer_->widget_ptr()->close();
|
||||
}
|
||||
//end class trigger
|
||||
|
||||
@ -754,23 +754,26 @@ namespace nana
|
||||
API::register_menu_window(this->handle(), !owner_menubar);
|
||||
}
|
||||
|
||||
events().destroy.connect_unignorable([this]{
|
||||
auto & events = this->events();
|
||||
events.destroy.connect_unignorable([this]{
|
||||
_m_destroy();
|
||||
});
|
||||
|
||||
events().key_press.connect_unignorable([this](const arg_keyboard& arg){
|
||||
events.key_press.connect_unignorable([this](const arg_keyboard& arg){
|
||||
_m_key_down(arg);
|
||||
});
|
||||
|
||||
events().mouse_down.connect_unignorable([this](const arg_mouse& arg)
|
||||
auto fn = [this](const arg_mouse& arg)
|
||||
{
|
||||
this->_m_open_sub(0); //Try to open submenu immediately
|
||||
});
|
||||
if (event_code::mouse_down == arg.evt_code)
|
||||
_m_open_sub(0); //Try to open submenu immediately
|
||||
else if (event_code::mouse_up == arg.evt_code)
|
||||
if (arg.button == ::nana::mouse::left_button)
|
||||
pick();
|
||||
};
|
||||
|
||||
events().mouse_up.connect_unignorable([this](const arg_mouse& arg){
|
||||
if (arg.left_button)
|
||||
pick();
|
||||
});
|
||||
events.mouse_down.connect_unignorable(fn);
|
||||
events.mouse_up.connect_unignorable(fn);
|
||||
|
||||
timer_.interval(100);
|
||||
timer_.elapse([this]{
|
||||
@ -782,7 +785,7 @@ namespace nana
|
||||
|
||||
if (want_focus_)
|
||||
{
|
||||
event_focus_ = events().focus.connect_unignorable([this](const arg_focus& arg)
|
||||
event_focus_ = events.focus.connect_unignorable([this](const arg_focus& arg)
|
||||
{
|
||||
//when the focus of the menu window is losing, close the menu.
|
||||
//But here is not every menu window may have focus event installed,
|
||||
|
||||
@ -1593,12 +1593,12 @@ namespace nana{ namespace widgets
|
||||
return true;
|
||||
}
|
||||
|
||||
bool text_editor::mouse_down(bool left_button, const point& scrpos)
|
||||
bool text_editor::mouse_down(::nana::mouse button, const point& scrpos)
|
||||
{
|
||||
if (!hit_text_area(scrpos))
|
||||
return false;
|
||||
|
||||
if(left_button)
|
||||
if(::nana::mouse::left_button == button)
|
||||
{
|
||||
API::capture_window(window_, true);
|
||||
text_area_.captured = true;
|
||||
@ -1646,7 +1646,7 @@ namespace nana{ namespace widgets
|
||||
return false;
|
||||
}
|
||||
|
||||
bool text_editor::mouse_up(bool left_button, const point& scrpos)
|
||||
bool text_editor::mouse_up(::nana::mouse button, const point& scrpos)
|
||||
{
|
||||
auto is_prev_no_selected = (select_.mode_selection == selection::mode_no_selected);
|
||||
|
||||
|
||||
@ -371,9 +371,9 @@ namespace nana
|
||||
|
||||
bool refreshed = false;
|
||||
if (pressed)
|
||||
refreshed = editor_->mouse_down(arg.left_button, arg.pos);
|
||||
refreshed = editor_->mouse_down(arg.button, arg.pos);
|
||||
else
|
||||
refreshed = editor_->mouse_up(arg.left_button, arg.pos);
|
||||
refreshed = editor_->mouse_up(arg.button, arg.pos);
|
||||
|
||||
if (refreshed)
|
||||
_m_draw_spins(buttons::none);
|
||||
|
||||
@ -97,7 +97,7 @@ namespace drawerbase {
|
||||
|
||||
void drawer::mouse_down(graph_reference, const arg_mouse& arg)
|
||||
{
|
||||
if(editor_->mouse_down(arg.left_button, arg.pos))
|
||||
if(editor_->mouse_down(arg.button, arg.pos))
|
||||
API::lazy_refresh();
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ namespace drawerbase {
|
||||
|
||||
void drawer::mouse_up(graph_reference graph, const arg_mouse& arg)
|
||||
{
|
||||
if(editor_->mouse_up(arg.left_button, arg.pos))
|
||||
if(editor_->mouse_up(arg.button, arg.pos))
|
||||
API::lazy_refresh();
|
||||
}
|
||||
|
||||
|
||||
@ -277,7 +277,7 @@ namespace nana
|
||||
impl_->which = which;
|
||||
if (which == npos || container.at(which)->enable)
|
||||
{
|
||||
impl_->state = (arg.left_button ? item_renderer::state_t::selected : item_renderer::state_t::highlighted);
|
||||
impl_->state = item_renderer::state_t::highlighted;
|
||||
|
||||
refresh(graph);
|
||||
API::lazy_refresh();
|
||||
|
||||
@ -583,7 +583,7 @@ namespace nana
|
||||
|
||||
void event_scrollbar(const arg_mouse& arg)
|
||||
{
|
||||
if((event_code::mouse_wheel == arg.evt_code) || arg.left_button)
|
||||
if((event_code::mouse_wheel == arg.evt_code) || arg.is_left_button())
|
||||
{
|
||||
if(shape.prev_first_value != shape.scroll.value())
|
||||
{
|
||||
@ -719,17 +719,29 @@ namespace nana
|
||||
node_state.tooltip->impl().assign(node_attr, &data.renderer, &data.comp_placer);
|
||||
node_state.tooltip->show();
|
||||
|
||||
auto & events = node_state.tooltip->events();
|
||||
events.mouse_leave.connect([this](const arg_mouse&){
|
||||
this->close_tooltip_window();
|
||||
});
|
||||
events.mouse_move.connect([this](const arg_mouse&){
|
||||
this->mouse_move_tooltip_window();
|
||||
});
|
||||
|
||||
auto fn = [this](const arg_mouse& arg){
|
||||
this->click_tooltip_window(arg);
|
||||
auto fn = [this](const arg_mouse& arg)
|
||||
{
|
||||
switch (arg.evt_code)
|
||||
{
|
||||
case event_code::mouse_leave:
|
||||
close_tooltip_window();
|
||||
break;
|
||||
case event_code::mouse_move:
|
||||
mouse_move_tooltip_window();
|
||||
break;
|
||||
case event_code::mouse_down:
|
||||
case event_code::mouse_up:
|
||||
case event_code::dbl_click:
|
||||
click_tooltip_window(arg);
|
||||
break;
|
||||
default: //ignore other events
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
auto & events = node_state.tooltip->events();
|
||||
events.mouse_leave(fn);
|
||||
events.mouse_move(fn);
|
||||
events.mouse_down.connect(fn);
|
||||
events.mouse_up.connect(fn);
|
||||
events.dbl_click.connect(fn);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user