floating-behavior.cpp revision 01b874138358af5896cc1bc846229b85464c945a
/** @file
* @brief Floating dialog implementation.
*/
/* Author:
* Gustav Broberg <broberg@kth.se>
*
* Copyright (C) 2007 Authors
*
* Released under GNU GPL. Read the file 'COPYING' for more information.
*/
#include "floating-behavior.h"
#include "dialog.h"
#include "inkscape.h"
#include "desktop.h"
#include "dialogs/dialog-events.h"
#include "interface.h"
#include "preferences.h"
#include "verbs.h"
namespace Inkscape {
namespace UI {
namespace Dialog {
namespace Behavior {
,_steps(0)
,_trans_focus(Inkscape::Preferences::get()->getDoubleLimited("/dialogs/transparency/on-focus", 0.95, 0.0, 1.0))
,_trans_blur(Inkscape::Preferences::get()->getDoubleLimited("/dialogs/transparency/on-blur", 0.50, 0.0, 1.0))
,_trans_time(Inkscape::Preferences::get()->getIntLimited("/dialogs/transparency/animate-time", 100, 0, 5000))
#endif
{
hide();
_d->set_has_separator(false);
signal_delete_event().connect(sigc::mem_fun(_dialog, &Inkscape::UI::Dialog::Dialog::_onDeleteEvent));
_dialog.retransientize_suppress = false;
_focus_event();
#endif
}
/** \brief A function called when the window gets focus
This function gets called on a focus event. It figures out how much
time is required for a transition, and the number of steps that'll take,
and sets up the _trans_timer function to do the work. If the transition
time is set to 0 ms it just calls _trans_timer once with _steps equal to
zero so that the transition happens instantaneously. This occurs on
windows as opacity changes cause flicker there.
*/
void FloatingBehavior::_focus_event (void)
{
_steps = 0;
if (_trans_time != 0) {
while (diff > 0.05) {
_steps++;
}
if (_steps != 0) {
Glib::signal_timeout().connect(sigc::mem_fun(this, &FloatingBehavior::_trans_timer), _trans_time / _steps);
}
}
_trans_timer();
return;
}
/** \brief Move the opacity of a window towards our goal
This is a timer function that is set up by _focus_event to slightly
move the opacity of the window along in an animated fashion. It moves
the opacity half way to the goal until it runs out of steps, and then
it just forces the goal.
*/
bool FloatingBehavior::_trans_timer (void) {
// printf("Go go gadget timer: %d\n", _steps);
if (_steps == 0) {
if (_dialog_active.get_value()) {
} else {
}
return false;
}
if (_dialog_active.get_value()) {
goal = _trans_focus;
} else {
goal = _trans_blur;
}
_steps--;
return true;
}
#endif
{
delete _d;
_d = 0;
}
Behavior *
{
return new FloatingBehavior(dialog);
}
inline void FloatingBehavior::set_position(Gtk::WindowPosition position) { _d->set_position(position); }
inline void FloatingBehavior::set_size_request(int width, int height) { _d->set_size_request(width, height); }
inline void FloatingBehavior::size_request(Gtk::Requisition &requisition) { _d->size_request(requisition); }
Glib::SignalProxy1<bool, GdkEventAny *> FloatingBehavior::signal_delete_event () { return _d->signal_delete_event(); }
void
{
hide();
}
void
{
show();
}
void
FloatingBehavior::onShutdown() {}
void
{
#ifdef WIN32 // Win32 special code to enable transient dialogs
transient_policy = 2;
#endif
if (!transient_policy)
return;
if (_dialog.retransientize_suppress) {
/* if retransientizing of this dialog is still forbidden after
* previous call warning turned off because it was confusingly fired
* when loading many files from command line
*/
// g_warning("Retranzientize aborted! You're switching windows too fast!");
return;
}
if (dialog_win)
{
/*
* This enables "aggressive" transientization,
* i.e. dialogs always emerging on top when you switch documents. Note
* however that this breaks "click to raise" policy of a window
* manager because the switched-to document will be raised at once
* (so that its transients also could raise)
*/
// without this, a transient window not always emerges on top
}
}
// we're done, allow next retransientizing not sooner than after 120 msec
}
} // namespace Behavior
} // namespace Dialog
} // namespace UI
} // namespace Inkscape
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :