Toggle fullscreen status of inspector window with F11 (#5867)
Moreover add two null pointer checks (thanks for review @Lawrence37).
This commit is contained in:
parent
691523d8dd
commit
947f3dca00
@ -98,6 +98,7 @@ Inspector::Inspector () : currImage(nullptr), scaled(false), scale(1.0), zoomSca
|
||||
gestureZoom->signal_scale_changed().connect(sigc::mem_fun(*this, &Inspector::on_zoom_scale_changed));
|
||||
|
||||
window.add(*this);
|
||||
window.set_size_request(400, 400);
|
||||
window.show_all();
|
||||
window.set_visible(false);
|
||||
active = true; // always track inspected thumbnails
|
||||
@ -108,10 +109,14 @@ Inspector::~Inspector()
|
||||
deleteBuffers();
|
||||
}
|
||||
|
||||
void Inspector::showWindow(bool scaled)
|
||||
void Inspector::showWindow(bool scaled, bool fullscreen)
|
||||
{
|
||||
this->scaled = scaled;
|
||||
window.fullscreen();
|
||||
if (fullscreen)
|
||||
window.fullscreen();
|
||||
else
|
||||
window.unfullscreen();
|
||||
this->fullscreen = fullscreen;
|
||||
window.set_visible(true);
|
||||
pinned = false;
|
||||
|
||||
@ -139,18 +144,29 @@ bool Inspector::on_key_press(GdkEventKey *event)
|
||||
switch (event->keyval) {
|
||||
case GDK_KEY_z:
|
||||
case GDK_KEY_F:
|
||||
// show image unscaled in 100% view
|
||||
if (pinned || scaled)
|
||||
zoomScale = 1.0; // reset if not key hold
|
||||
scaled = false;
|
||||
queue_draw();
|
||||
return true;
|
||||
case GDK_KEY_f:
|
||||
// show image scaled to window size
|
||||
if (pinned || !scaled)
|
||||
zoomScale = 1.0; // reset if not key hold
|
||||
scaled = true;
|
||||
queue_draw();
|
||||
return true;
|
||||
case GDK_KEY_F11:
|
||||
// toggle fullscreen
|
||||
if (fullscreen)
|
||||
window.unfullscreen();
|
||||
else
|
||||
window.fullscreen();
|
||||
fullscreen = !fullscreen;
|
||||
return true;
|
||||
case GDK_KEY_Escape:
|
||||
// hide window
|
||||
zoomScale = 1.0;
|
||||
window.set_visible(false);
|
||||
return true;
|
||||
@ -173,6 +189,9 @@ bool Inspector::on_button_press_event(GdkEventButton *event)
|
||||
|
||||
bool Inspector::on_motion_notify_event(GdkEventMotion *event)
|
||||
{
|
||||
if (!currImage)
|
||||
return false;
|
||||
|
||||
int deviceScale = get_scale_factor();
|
||||
int delta_x = (button_pos.x - event->x)*deviceScale;
|
||||
int delta_y = (button_pos.y - event->y)*deviceScale;
|
||||
@ -273,6 +292,9 @@ void Inspector::moveCenter(int delta_x, int delta_y, int imW, int imH, int devic
|
||||
|
||||
void Inspector::beginZoom(double x, double y)
|
||||
{
|
||||
if (!currImage)
|
||||
return;
|
||||
|
||||
int deviceScale = get_scale_factor();
|
||||
int imW = currImage->imgBuffer.getWidth();
|
||||
int imH = currImage->imgBuffer.getHeight();
|
||||
|
@ -54,6 +54,7 @@ private:
|
||||
bool active;
|
||||
bool pinned;
|
||||
bool dirty;
|
||||
bool fullscreen; // window is shown in fullscreen mode
|
||||
|
||||
sigc::connection delayconn;
|
||||
Glib::ustring next_image_path;
|
||||
@ -87,7 +88,7 @@ public:
|
||||
/** @brief Show or hide window
|
||||
* @param scaled fit image into window
|
||||
*/
|
||||
void showWindow(bool scaled);
|
||||
void showWindow(bool scaled, bool fullscreen = true);
|
||||
|
||||
/** @brief Mouse movement to a new position
|
||||
* @param pos Location of the mouse, in percentage (i.e. [0;1] range) relative to the full size image ; -1,-1 == out of the image
|
||||
|
Loading…
x
Reference in New Issue
Block a user