gladish: canvas zoom functionality. Fixes #66
This commit is contained in:
parent
482265c5c7
commit
181585203e
21
gui/action.c
21
gui/action.c
|
@ -28,8 +28,13 @@
|
||||||
#include "action.h"
|
#include "action.h"
|
||||||
#include "gtk_builder.h"
|
#include "gtk_builder.h"
|
||||||
#include "jack.h"
|
#include "jack.h"
|
||||||
|
#include "zoom.h"
|
||||||
|
|
||||||
GtkAction * g_clear_xruns_and_max_dsp_action;
|
GtkAction * g_clear_xruns_and_max_dsp_action;
|
||||||
|
GtkAction * g_zoom_100_action;
|
||||||
|
GtkAction * g_zoom_fit_action;
|
||||||
|
GtkAction * g_zoom_in_action;
|
||||||
|
GtkAction * g_zoom_out_action;
|
||||||
|
|
||||||
void init_actions_and_accelerators(void)
|
void init_actions_and_accelerators(void)
|
||||||
{
|
{
|
||||||
|
@ -39,6 +44,18 @@ void init_actions_and_accelerators(void)
|
||||||
g_clear_xruns_and_max_dsp_action = GTK_ACTION(get_gtk_builder_object("clear_xruns_and_max_dsp_load_action"));
|
g_clear_xruns_and_max_dsp_action = GTK_ACTION(get_gtk_builder_object("clear_xruns_and_max_dsp_load_action"));
|
||||||
g_signal_connect(G_OBJECT(g_clear_xruns_and_max_dsp_action), "activate", G_CALLBACK(clear_xruns_and_max_dsp), NULL);
|
g_signal_connect(G_OBJECT(g_clear_xruns_and_max_dsp_action), "activate", G_CALLBACK(clear_xruns_and_max_dsp), NULL);
|
||||||
|
|
||||||
|
g_zoom_100_action = GTK_ACTION(get_gtk_builder_object("zoom_100_action"));
|
||||||
|
g_signal_connect(G_OBJECT(g_zoom_100_action), "activate", G_CALLBACK(zoom_100), NULL);
|
||||||
|
|
||||||
|
g_zoom_fit_action = GTK_ACTION(get_gtk_builder_object("zoom_fit_action"));
|
||||||
|
g_signal_connect(G_OBJECT(g_zoom_fit_action), "activate", G_CALLBACK(zoom_fit), NULL);
|
||||||
|
|
||||||
|
g_zoom_in_action = GTK_ACTION(get_gtk_builder_object("zoom_in_action"));
|
||||||
|
g_signal_connect(G_OBJECT(g_zoom_in_action), "activate", G_CALLBACK(zoom_in), NULL);
|
||||||
|
|
||||||
|
g_zoom_out_action = GTK_ACTION(get_gtk_builder_object("zoom_out_action"));
|
||||||
|
g_signal_connect(G_OBJECT(g_zoom_out_action), "activate", G_CALLBACK(zoom_out), NULL);
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
GtkAction * action_ptr;
|
GtkAction * action_ptr;
|
||||||
|
@ -46,6 +63,10 @@ void init_actions_and_accelerators(void)
|
||||||
} * descriptor_ptr, descriptors [] =
|
} * descriptor_ptr, descriptors [] =
|
||||||
{
|
{
|
||||||
{g_clear_xruns_and_max_dsp_action, "c"},
|
{g_clear_xruns_and_max_dsp_action, "c"},
|
||||||
|
{g_zoom_in_action, "<Control>plus"},
|
||||||
|
{g_zoom_out_action, "<Control>minus"},
|
||||||
|
{g_zoom_100_action, "<Control>0"},
|
||||||
|
{g_zoom_fit_action, "<Control>equal"},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -249,6 +249,13 @@ canvas_scroll_to_center(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
canvas_get_zoom(
|
||||||
|
canvas_handle canvas)
|
||||||
|
{
|
||||||
|
return canvas_ptr->get()->get_zoom();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
canvas_set_zoom(
|
canvas_set_zoom(
|
||||||
canvas_handle canvas,
|
canvas_handle canvas,
|
||||||
|
@ -257,6 +264,13 @@ canvas_set_zoom(
|
||||||
canvas_ptr->get()->set_zoom(pix_per_unit);
|
canvas_ptr->get()->set_zoom(pix_per_unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
canvas_set_zoom_fit(
|
||||||
|
canvas_handle canvas)
|
||||||
|
{
|
||||||
|
canvas_ptr->get()->zoom_full();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
canvas_arrange(
|
canvas_arrange(
|
||||||
canvas_handle canvas)
|
canvas_handle canvas)
|
||||||
|
|
|
@ -78,11 +78,19 @@ void
|
||||||
canvas_scroll_to_center(
|
canvas_scroll_to_center(
|
||||||
canvas_handle canvas);
|
canvas_handle canvas);
|
||||||
|
|
||||||
|
double
|
||||||
|
canvas_get_zoom(
|
||||||
|
canvas_handle canvas);
|
||||||
|
|
||||||
void
|
void
|
||||||
canvas_set_zoom(
|
canvas_set_zoom(
|
||||||
canvas_handle canvas,
|
canvas_handle canvas,
|
||||||
double pix_per_unit);
|
double pix_per_unit);
|
||||||
|
|
||||||
|
void
|
||||||
|
canvas_set_zoom_fit(
|
||||||
|
canvas_handle canvas);
|
||||||
|
|
||||||
void
|
void
|
||||||
canvas_arrange(
|
canvas_arrange(
|
||||||
canvas_handle canvas);
|
canvas_handle canvas);
|
||||||
|
|
|
@ -283,6 +283,38 @@
|
||||||
<signal name="activate" handler="on_menu_view_toolbar_activate"/>
|
<signal name="activate" handler="on_menu_view_toolbar_activate"/>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImageMenuItem" id="menu_item_zoom_in">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="related_action">zoom_in_action</property>
|
||||||
|
<property name="use_action_appearance">True</property>
|
||||||
|
<property name="use_stock">True</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImageMenuItem" id="menu_item_zoom_out">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="related_action">zoom_out_action</property>
|
||||||
|
<property name="use_action_appearance">True</property>
|
||||||
|
<property name="use_stock">True</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImageMenuItem" id="menu_item_zoom_100">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="related_action">zoom_100_action</property>
|
||||||
|
<property name="use_action_appearance">True</property>
|
||||||
|
<property name="use_stock">True</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImageMenuItem" id="menu_item_zoom_fit">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="related_action">zoom_fit_action</property>
|
||||||
|
<property name="use_action_appearance">True</property>
|
||||||
|
<property name="use_stock">True</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCheckMenuItem" id="menu_item_view_raw_jack">
|
<object class="GtkCheckMenuItem" id="menu_item_view_raw_jack">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -486,10 +518,9 @@
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkToolButton" id="zoom_normal_but">
|
<object class="GtkToolButton" id="zoom_in_button">
|
||||||
<property name="visible">True</property>
|
<property name="related_action">zoom_in_action</property>
|
||||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
<property name="use_action_appearance">True</property>
|
||||||
<property name="stock_id">gtk-zoom-100</property>
|
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
|
@ -497,10 +528,30 @@
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkToolButton" id="zoom_full_but">
|
<object class="GtkToolButton" id="zoom_out_button">
|
||||||
|
<property name="related_action">zoom_out_action</property>
|
||||||
|
<property name="use_action_appearance">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="homogeneous">True</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkToolButton" id="zoom_100_button">
|
||||||
|
<property name="related_action">zoom_100_action</property>
|
||||||
|
<property name="use_action_appearance">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="homogeneous">True</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkToolButton" id="zoom_fit_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
<property name="related_action">zoom_fit_action</property>
|
||||||
<property name="stock_id">gtk-zoom-fit</property>
|
<property name="use_action_appearance">True</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
|
@ -1315,6 +1366,30 @@ along with LADI Session Handler; if not, write to the Free Software Foundation,
|
||||||
<property name="stock_id">gtk-clear</property>
|
<property name="stock_id">gtk-clear</property>
|
||||||
<property name="is_important">True</property>
|
<property name="is_important">True</property>
|
||||||
</object>
|
</object>
|
||||||
|
<object class="GtkAction" id="zoom_100_action">
|
||||||
|
<property name="label">Zoom 100%</property>
|
||||||
|
<property name="short_label">zoom_100</property>
|
||||||
|
<property name="stock_id">gtk-zoom-100</property>
|
||||||
|
<property name="is_important">True</property>
|
||||||
|
</object>
|
||||||
|
<object class="GtkAction" id="zoom_fit_action">
|
||||||
|
<property name="label">Zoom to fit</property>
|
||||||
|
<property name="short_label">zoom_fit</property>
|
||||||
|
<property name="stock_id">gtk-zoom-fit</property>
|
||||||
|
<property name="is_important">True</property>
|
||||||
|
</object>
|
||||||
|
<object class="GtkAction" id="zoom_in_action">
|
||||||
|
<property name="label">Zoom in</property>
|
||||||
|
<property name="short_label">zoom_in</property>
|
||||||
|
<property name="stock_id">gtk-zoom-in</property>
|
||||||
|
<property name="is_important">True</property>
|
||||||
|
</object>
|
||||||
|
<object class="GtkAction" id="zoom_out_action">
|
||||||
|
<property name="label">Zoom out</property>
|
||||||
|
<property name="short_label">zoom_out</property>
|
||||||
|
<property name="stock_id">gtk-zoom-out</property>
|
||||||
|
<property name="is_important">True</property>
|
||||||
|
</object>
|
||||||
<object class="GtkImage" id="image_configure_jack">
|
<object class="GtkImage" id="image_configure_jack">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="stock">gtk-preferences</property>
|
<property name="stock">gtk-preferences</property>
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
/* -*- Mode: C ; c-basic-offset: 2 -*- */
|
||||||
|
/*
|
||||||
|
* LADI Session Handler (ladish)
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Nedko Arnaudov <nedko@arnaudov.name>
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
* This file contains the canvas zoom related code
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* LADI Session Handler is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* LADI Session Handler is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
* or write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "zoom.h"
|
||||||
|
#include "canvas.h"
|
||||||
|
#include "graph_view.h"
|
||||||
|
|
||||||
|
#define ZOOM_CHANGE 1.1
|
||||||
|
|
||||||
|
void zoom_100(void)
|
||||||
|
{
|
||||||
|
canvas_handle canvas;
|
||||||
|
|
||||||
|
log_info("zoom 100%% request");
|
||||||
|
|
||||||
|
canvas = get_current_canvas();
|
||||||
|
if (canvas != NULL)
|
||||||
|
{
|
||||||
|
canvas_set_zoom(canvas, 1.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void zoom_fit(void)
|
||||||
|
{
|
||||||
|
canvas_handle canvas;
|
||||||
|
|
||||||
|
log_info("zoom fit request");
|
||||||
|
|
||||||
|
canvas = get_current_canvas();
|
||||||
|
if (canvas != NULL)
|
||||||
|
{
|
||||||
|
canvas_set_zoom_fit(canvas);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void zoom_in(void)
|
||||||
|
{
|
||||||
|
canvas_handle canvas;
|
||||||
|
|
||||||
|
log_info("zoom in request");
|
||||||
|
|
||||||
|
canvas = get_current_canvas();
|
||||||
|
if (canvas != NULL)
|
||||||
|
{
|
||||||
|
canvas_set_zoom(canvas, canvas_get_zoom(canvas) * ZOOM_CHANGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void zoom_out(void)
|
||||||
|
{
|
||||||
|
canvas_handle canvas;
|
||||||
|
|
||||||
|
log_info("zoom out request");
|
||||||
|
|
||||||
|
canvas = get_current_canvas();
|
||||||
|
if (canvas != NULL)
|
||||||
|
{
|
||||||
|
canvas_set_zoom(canvas, canvas_get_zoom(canvas) / ZOOM_CHANGE);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
/* -*- Mode: C ; c-basic-offset: 2 -*- */
|
||||||
|
/*
|
||||||
|
* LADI Session Handler (ladish)
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Nedko Arnaudov <nedko@arnaudov.name>
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
* This file contains interface to the canvas zoom related code
|
||||||
|
**************************************************************************
|
||||||
|
*
|
||||||
|
* LADI Session Handler is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* LADI Session Handler is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
* or write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ZOOM_H__3D2297C9_5286_47AF_A7A3_0C15FDA40F93__INCLUDED
|
||||||
|
#define ZOOM_H__3D2297C9_5286_47AF_A7A3_0C15FDA40F93__INCLUDED
|
||||||
|
|
||||||
|
void zoom_100(void);
|
||||||
|
void zoom_fit(void);
|
||||||
|
void zoom_in(void);
|
||||||
|
void zoom_out(void);
|
||||||
|
|
||||||
|
#endif /* #ifndef ZOOM_H__3D2297C9_5286_47AF_A7A3_0C15FDA40F93__INCLUDED */
|
Loading…
Reference in New Issue