Add a tooltip mode for a dialog.
The code is still a bit experimental, but like to have it committed before the FOSDEM.
This commit is contained in:
parent
9061d8b2e0
commit
a7c1d992d8
4 changed files with 83 additions and 1 deletions
|
@ -29,6 +29,8 @@ tdialog::~tdialog()
|
|||
foreach(tfield_* field, fields_) {
|
||||
delete field;
|
||||
}
|
||||
|
||||
delete window_;
|
||||
}
|
||||
|
||||
void tdialog::show(CVideo& video, const unsigned auto_close_time)
|
||||
|
@ -71,6 +73,25 @@ void tdialog::show(CVideo& video, const unsigned auto_close_time)
|
|||
post_show(*window);
|
||||
}
|
||||
|
||||
void tdialog::show_tooltip(CVideo& video/*, const unsigned auto_close_time*/)
|
||||
{
|
||||
if(video.faked()) {
|
||||
return;
|
||||
}
|
||||
|
||||
window_ = build_window(video);
|
||||
|
||||
post_build(video, *window_);
|
||||
|
||||
window_->set_owner(this);
|
||||
|
||||
init_fields(*window_);
|
||||
|
||||
pre_show(video, *window_);
|
||||
|
||||
window_->show_tooltip(/*auto_close_time*/);
|
||||
}
|
||||
|
||||
tfield_bool* tdialog::register_bool(
|
||||
const std::string& id
|
||||
, const bool optional
|
||||
|
|
|
@ -90,7 +90,8 @@ public:
|
|||
tdialog() :
|
||||
retval_(0),
|
||||
fields_(),
|
||||
restore_(true)
|
||||
restore_(true),
|
||||
window_(NULL)
|
||||
{}
|
||||
|
||||
virtual ~tdialog();
|
||||
|
@ -108,6 +109,21 @@ public:
|
|||
*/
|
||||
void show(CVideo& video, const unsigned auto_close_time = 0);
|
||||
|
||||
/**
|
||||
* Shows the window as a tooltip.
|
||||
*
|
||||
* A tooltip can't be interacted with and is just shown.
|
||||
*
|
||||
* @todo Implement @p auto_close_time.
|
||||
*
|
||||
* @todo Look at merging @ref show and @ref show_tooltip. Maybe more types
|
||||
* are needed, have a look at it later.
|
||||
*
|
||||
* @param video The video which contains the surface to draw
|
||||
* upon.
|
||||
*/
|
||||
void show_tooltip(CVideo& video/*, const unsigned auto_close_time = 0*/);
|
||||
|
||||
/***** ***** ***** setters / getters for members ***** ****** *****/
|
||||
|
||||
int get_retval() const { return retval_; }
|
||||
|
@ -182,6 +198,9 @@ private:
|
|||
*/
|
||||
bool restore_;
|
||||
|
||||
/** The window, used in show modal. */
|
||||
twindow* window_;
|
||||
|
||||
/** The id of the window to build. */
|
||||
virtual const std::string& window_id() const = 0;
|
||||
|
||||
|
|
|
@ -378,6 +378,7 @@ void twindow::update_screen_size()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
twindow::tretval twindow::get_retval_by_id(const std::string& id)
|
||||
{
|
||||
/*WIKI
|
||||
|
@ -440,6 +441,23 @@ twindow::tretval twindow::get_retval_by_id(const std::string& id)
|
|||
}
|
||||
}
|
||||
|
||||
void twindow::show_tooltip(/*const unsigned auto_close_timeout*/)
|
||||
{
|
||||
log_scope2(log_gui_draw, "Window: show as tooltip.");
|
||||
|
||||
generate_dot_file("show", SHOW);
|
||||
|
||||
assert(status_ == NEW);
|
||||
|
||||
/*
|
||||
* Before show has been called, some functions might have done some testing
|
||||
* on the window and called layout, which can give glitches. So
|
||||
* reinvalidate the window to avoid those glitches.
|
||||
*/
|
||||
invalidate_layout();
|
||||
suspend_drawing_ = false;
|
||||
}
|
||||
|
||||
int twindow::show(const bool restore, const unsigned auto_close_timeout)
|
||||
{
|
||||
/**
|
||||
|
@ -508,6 +526,15 @@ int twindow::show(const bool restore, const unsigned auto_close_timeout)
|
|||
|
||||
delay_event(event, auto_close_timeout);
|
||||
}
|
||||
|
||||
/** @todo Evaluate whether capturing can be done cleaner. */
|
||||
/*
|
||||
* Capture the input. This way a tooltip shown doesn't grab the focus if
|
||||
* drawn above us. This also means the window shown is always modal.
|
||||
*/
|
||||
capture_keyboard(dynamic_cast<gui2::event::tdispatcher*>(this));
|
||||
event::capture_mouse(dynamic_cast<gui2::event::tdispatcher*>(this));
|
||||
|
||||
try {
|
||||
// Start our loop drawing will happen here as well.
|
||||
for(status_ = SHOWING; status_ != REQUEST_CLOSE; ) {
|
||||
|
|
|
@ -142,6 +142,21 @@ public:
|
|||
int show(const bool restore = true,
|
||||
const unsigned auto_close_timeout = 0);
|
||||
|
||||
/**
|
||||
* Shows the window as a tooltip.
|
||||
*
|
||||
* A tooltip can't be interacted with and is just shown.
|
||||
*
|
||||
* @todo implement @p auto_close_timeout.
|
||||
*
|
||||
* @param auto_close_timeout The time in ms after which the window will
|
||||
* automatically close, if 0 it doesn't close.
|
||||
* @note the timeout is a minimum time and
|
||||
* there's no quarantee about how fast it closes
|
||||
* after the minimum.
|
||||
*/
|
||||
void show_tooltip(/*const unsigned auto_close_timeout = 0*/);
|
||||
|
||||
/**
|
||||
* Draws the window.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue