Index: trunk/scconfig/Rev.h
===================================================================
--- trunk/scconfig/Rev.h (revision 6666)
+++ trunk/scconfig/Rev.h (revision 6667)
@@ -1 +1 @@
-static const int myrev = 6663;
+static const int myrev = 6667;
Index: trunk/scconfig/Rev.tab
===================================================================
--- trunk/scconfig/Rev.tab (revision 6666)
+++ trunk/scconfig/Rev.tab (revision 6667)
@@ -1,4 +1,4 @@
-6663 configure gtk splitup
+6667 configure gtk splitup
6392 configure draw cross section plugin (gtk and lesstif depend on it)
6365 configure gtk splitup
6111 configure layer vs. layer group code split
Index: trunk/src_plugins/hid_gtk/gtkhid-main.c
===================================================================
--- trunk/src_plugins/hid_gtk/gtkhid-main.c (revision 6666)
+++ trunk/src_plugins/hid_gtk/gtkhid-main.c (revision 6667)
@@ -133,7 +133,7 @@
ghid_draw_grid_local(x, y);
if (gport->view.crosshair_x != x || gport->view.crosshair_y != y) {
- ghid_set_cursor_position_labels();
+ ghid_set_cursor_position_labels(&ghidgui->cps, conf_hid_gtk.plugins.hid_gtk.compact_vertical);
gport->view.crosshair_x = x;
gport->view.crosshair_y = y;
Index: trunk/src_plugins/hid_gtk/gui-config.c
===================================================================
--- trunk/src_plugins/hid_gtk/gui-config.c (revision 6666)
+++ trunk/src_plugins/hid_gtk/gui-config.c (revision 6667)
@@ -1634,8 +1634,8 @@
{
char *text = pcb_strdup_printf("%s",
conf_core.editor.grid_unit->in_suffix);
- ghid_set_cursor_position_labels();
- gtk_label_set_markup(GTK_LABEL(ghidgui->grid_units_label), text);
+ ghid_set_cursor_position_labels(&ghidgui->cps, conf_hid_gtk.plugins.hid_gtk.compact_vertical);
+ gtk_label_set_markup(GTK_LABEL(ghidgui->cps.grid_units_label), text);
free(text);
if (config_sizes_vbox) {
Index: trunk/src_plugins/hid_gtk/gui-misc.c
===================================================================
--- trunk/src_plugins/hid_gtk/gui-misc.c (revision 6666)
+++ trunk/src_plugins/hid_gtk/gui-misc.c (revision 6667)
@@ -45,18 +45,6 @@
gtk_label_set_markup(GTK_LABEL(ghidgui->status_line_label), text ? text : "");
}
-void ghid_cursor_position_label_set_text(gchar * text)
-{
- if (ghidgui->cursor_position_absolute_label != NULL)
- gtk_label_set_markup(GTK_LABEL(ghidgui->cursor_position_absolute_label), text ? text : "");
-}
-
-void ghid_cursor_position_relative_label_set_text(gchar * text)
-{
- if (ghidgui->cursor_position_relative_label != NULL)
- gtk_label_set_markup(GTK_LABEL(ghidgui->cursor_position_relative_label), text ? text : "");
-}
-
/* ---------------------------------------------------------------------------
* output of status line
*/
@@ -85,34 +73,3 @@
free(text);
}
-/* ---------------------------------------------------------------------------
- * output of cursor position
- */
-void ghid_set_cursor_position_labels(void)
-{
- char *text, sep = ' ';
- if (conf_hid_gtk.plugins.hid_gtk.compact_vertical)
- sep = '\n';
-
- if (pcb_marked.status) {
- pcb_coord_t dx = pcb_crosshair.X - pcb_marked.X;
- pcb_coord_t dy = pcb_crosshair.Y - pcb_marked.Y;
- pcb_coord_t r = pcb_distance(pcb_crosshair.X, pcb_crosshair.Y, pcb_marked.X, pcb_marked.Y);
- double a = atan2(dy, dx) * PCB_RAD_TO_DEG;
-
-
- text = pcb_strdup_printf(_("%m+r %-mS;%cphi %-.1f;%c%-mS %-mS"), conf_core.editor.grid_unit->allow, r, sep, a, sep, dx, dy);
- ghid_cursor_position_relative_label_set_text(text);
- free(text);
- }
- else {
- char text[64];
- sprintf(text, _("r __.__;%cphi __._;%c__.__ __.__"), sep, sep);
- ghid_cursor_position_relative_label_set_text(text);
- }
-
-
- text = pcb_strdup_printf("%m+%-mS%c%-mS", conf_core.editor.grid_unit->allow, pcb_crosshair.X, sep, pcb_crosshair.Y);
- ghid_cursor_position_label_set_text(text);
- free(text);
-}
Index: trunk/src_plugins/hid_gtk/gui-output-events.c
===================================================================
--- trunk/src_plugins/hid_gtk/gui-output-events.c (revision 6666)
+++ trunk/src_plugins/hid_gtk/gui-output-events.c (revision 6667)
@@ -109,7 +109,7 @@
pcb_gtk_coords_event2pcb(&gport->view, event_x, event_y, &gport->view.pcb_x, &gport->view.pcb_y);
pcb_event_move_crosshair(gport->view.pcb_x, gport->view.pcb_y);
- ghid_set_cursor_position_labels();
+ ghid_set_cursor_position_labels(&ghidgui->cps, conf_hid_gtk.plugins.hid_gtk.compact_vertical);
}
static gboolean ghid_idle_cb(gpointer data)
Index: trunk/src_plugins/hid_gtk/gui-top-window.c
===================================================================
--- trunk/src_plugins/hid_gtk/gui-top-window.c (revision 6666)
+++ trunk/src_plugins/hid_gtk/gui-top-window.c (revision 6667)
@@ -97,7 +97,6 @@
#include "../src_plugins/lib_gtk_common/wt_layer_selector.h"
#include "../src_plugins/lib_gtk_common/win_place.h"
-
static pcb_bool ignore_layer_update;
static GtkWidget *ghid_load_menus(void);
@@ -566,81 +565,6 @@
g_free(filename);
}
-static void grid_units_button_cb(GtkWidget * widget, gpointer data)
-{
- /* Button only toggles between mm and mil */
- if (conf_core.editor.grid_unit == get_unit_struct("mm"))
- pcb_hid_actionl("SetUnits", "mil", NULL);
- else
- pcb_hid_actionl("SetUnits", "mm", NULL);
-}
-
-/*
- * The two following callbacks are used to keep the absolute
- * and relative cursor labels from growing and shrinking as you
- * move the cursor around.
- */
-static void absolute_label_size_req_cb(GtkWidget * widget, GtkRequisition * req, gpointer data)
-{
-
- static gint w = 0;
- if (req->width > w)
- w = req->width;
- else
- req->width = w;
-}
-
-static void relative_label_size_req_cb(GtkWidget * widget, GtkRequisition * req, gpointer data)
-{
-
- static gint w = 0;
- if (req->width > w)
- w = req->width;
- else
- req->width = w;
-}
-
-static void make_cursor_position_labels(GtkWidget * hbox, GHidPort * port)
-{
- GtkWidget *frame, *label;
-
- /* The grid units button next to the cursor position labels.
- */
- ghidgui->grid_units_button = gtk_button_new();
- label = gtk_label_new("");
- gtk_label_set_markup(GTK_LABEL(label), conf_core.editor.grid_unit->in_suffix);
- ghidgui->grid_units_label = label;
- gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
- gtk_container_add(GTK_CONTAINER(ghidgui->grid_units_button), label);
- gtk_box_pack_end(GTK_BOX(hbox), ghidgui->grid_units_button, FALSE, TRUE, 0);
- g_signal_connect(ghidgui->grid_units_button, "clicked", G_CALLBACK(grid_units_button_cb), NULL);
-
- /* The absolute cursor position label
- */
- frame = gtk_frame_new(NULL);
- gtk_box_pack_end(GTK_BOX(hbox), frame, FALSE, TRUE, 0);
- gtk_container_set_border_width(GTK_CONTAINER(frame), 0);
- gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_OUT);
-
- label = gtk_label_new("");
- gtk_container_add(GTK_CONTAINER(frame), label);
- ghidgui->cursor_position_absolute_label = label;
- g_signal_connect(G_OBJECT(label), "size-request", G_CALLBACK(absolute_label_size_req_cb), NULL);
-
-
- /* The relative cursor position label
- */
- frame = gtk_frame_new(NULL);
- gtk_box_pack_end(GTK_BOX(hbox), frame, FALSE, TRUE, 0);
- gtk_container_set_border_width(GTK_CONTAINER(frame), 0);
- gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_OUT);
- label = gtk_label_new(" __.__ __.__ ");
- gtk_container_add(GTK_CONTAINER(frame), label);
- ghidgui->cursor_position_relative_label = label;
- g_signal_connect(G_OBJECT(label), "size-request", G_CALLBACK(relative_label_size_req_cb), NULL);
-
-}
-
/* \brief Add "virtual layers" to a layer selector */
static void make_virtual_layer_buttons(GtkWidget * layer_selector)
{
@@ -1022,8 +946,8 @@
* need to grab the GtkStyle associated with an actual menu item to
* get a text color to render with.
*/
- gtk_widget_set_style(ghidgui->cursor_position_relative_label, menu_bar_style);
- gtk_widget_set_style(ghidgui->cursor_position_absolute_label, menu_bar_style);
+ gtk_widget_set_style(ghidgui->cps.cursor_position_relative_label, menu_bar_style);
+ gtk_widget_set_style(ghidgui->cps.cursor_position_absolute_label, menu_bar_style);
/* Style the units button as if it were a toolbar button - hopefully
* this isn't too ugly sitting on a background themed as a menu bar.
@@ -1030,12 +954,12 @@
* It is unlikely any theme defines colours for a GtkButton sitting on
* a menu bar.
*/
- rel_pos_frame = gtk_widget_get_parent(ghidgui->cursor_position_relative_label);
- abs_pos_frame = gtk_widget_get_parent(ghidgui->cursor_position_absolute_label);
+ rel_pos_frame = gtk_widget_get_parent(ghidgui->cps.cursor_position_relative_label);
+ abs_pos_frame = gtk_widget_get_parent(ghidgui->cps.cursor_position_absolute_label);
gtk_widget_set_style(rel_pos_frame, menu_bar_style);
gtk_widget_set_style(abs_pos_frame, menu_bar_style);
- gtk_widget_set_style(ghidgui->grid_units_button, tool_button_style);
- gtk_widget_set_style(ghidgui->grid_units_label, tool_button_label_style);
+ gtk_widget_set_style(ghidgui->cps.grid_units_button, tool_button_style);
+ gtk_widget_set_style(ghidgui->cps.grid_units_label, tool_button_label_style);
}
/* Attempt to produce a conststent style for our extra menu-bar items by
Index: trunk/src_plugins/hid_gtk/gui.h
===================================================================
--- trunk/src_plugins/hid_gtk/gui.h (revision 6666)
+++ trunk/src_plugins/hid_gtk/gui.h (revision 6667)
@@ -52,7 +52,10 @@
#include "../src_plugins/lib_gtk_common/wt_coord_entry.h"
#include "../src_plugins/lib_gtk_common/dlg_propedit.h"
+/* needed for a type in GhidGui */
+#include "../src_plugins/lib_gtk_common/bu_cursor_pos.h"
+
/* Silk and rats lines are the two additional selectable to draw on.
| gui code in gui-top-window.c and group code in misc.c must agree
| on what layer is what!
@@ -86,14 +89,13 @@
typedef struct {
GtkActionGroup *main_actions, *change_selected_actions, *displayed_name_actions;
- GtkWidget
- * status_line_label,
- *cursor_position_relative_label, *cursor_position_absolute_label, *grid_units_label, *status_line_hbox, *command_combo_box;
+ pcb_gtk_cursor_pos_t cps;
+
+ GtkWidget *status_line_label, *status_line_hbox, *command_combo_box;
GtkEntry *command_entry;
GtkWidget *top_hbox, *top_bar_background, *menu_hbox, *position_hbox, *menubar_toolbar_vbox, *mode_buttons_frame;
GtkWidget *left_toolbar;
- GtkWidget *grid_units_button;
GtkWidget *menu_bar, *layer_selector, *route_style_selector;
GtkWidget *mode_toolbar;
GtkWidget *mode_toolbar_vbox;
@@ -277,7 +279,6 @@
guint pad, gfloat value, gfloat low, gfloat high,
gfloat step0, gfloat step1, void (*cb_func) (), gpointer data);
-void ghid_set_cursor_position_labels(void);
void ghid_set_status_line_label(void);
Index: trunk/src_plugins/lib_gtk_common/Plug.tmpasm
===================================================================
--- trunk/src_plugins/lib_gtk_common/Plug.tmpasm (revision 6666)
+++ trunk/src_plugins/lib_gtk_common/Plug.tmpasm (revision 6667)
@@ -6,6 +6,7 @@
put /local/pcb/mod/OBJS_C99 [@
$(PLUGDIR)/lib_gtk_common/bu_box.o
$(PLUGDIR)/lib_gtk_common/bu_check_button.o
+ $(PLUGDIR)/lib_gtk_common/bu_cursor_pos.o
$(PLUGDIR)/lib_gtk_common/bu_entry.o
$(PLUGDIR)/lib_gtk_common/bu_notebook.o
$(PLUGDIR)/lib_gtk_common/bu_spin_button.o
Index: trunk/src_plugins/lib_gtk_common/bu_cursor_pos.c
===================================================================
--- trunk/src_plugins/lib_gtk_common/bu_cursor_pos.c (nonexistent)
+++ trunk/src_plugins/lib_gtk_common/bu_cursor_pos.c (revision 6667)
@@ -0,0 +1,147 @@
+/*
+ * COPYRIGHT
+ *
+ * PCB, interactive printed circuit board design
+ * Copyright (C) 1994,1995,1996 Thomas Nau
+ * pcb-rnd Copyright (C) 2017 Tibor 'Igor2' Palinkas
+ *
+ * This program 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.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#include "config.h"
+#include "bu_cursor_pos.h"
+#include "conf_core.h"
+#include "hid_actions.h"
+#include "crosshair.h"
+#include "misc_util.h"
+#include "compat_nls.h"
+#include "math_helper.h"
+
+static void grid_units_button_cb(GtkWidget * widget, gpointer data)
+{
+ /* Button only toggles between mm and mil */
+ if (conf_core.editor.grid_unit == get_unit_struct("mm"))
+ pcb_hid_actionl("SetUnits", "mil", NULL);
+ else
+ pcb_hid_actionl("SetUnits", "mm", NULL);
+}
+
+/*
+ * The two following callbacks are used to keep the absolute
+ * and relative cursor labels from growing and shrinking as you
+ * move the cursor around.
+ */
+static void absolute_label_size_req_cb(GtkWidget * widget, GtkRequisition * req, gpointer data)
+{
+
+ static gint w = 0;
+ if (req->width > w)
+ w = req->width;
+ else
+ req->width = w;
+}
+
+static void relative_label_size_req_cb(GtkWidget * widget, GtkRequisition * req, gpointer data)
+{
+
+ static gint w = 0;
+ if (req->width > w)
+ w = req->width;
+ else
+ req->width = w;
+}
+
+
+void make_cursor_position_labels(GtkWidget *hbox, pcb_gtk_cursor_pos_t *cps)
+{
+ GtkWidget *frame, *label;
+
+ /* The grid units button next to the cursor position labels.
+ */
+ cps->grid_units_button = gtk_button_new();
+ label = gtk_label_new("");
+ gtk_label_set_markup(GTK_LABEL(label), conf_core.editor.grid_unit->in_suffix);
+ cps->grid_units_label = label;
+ gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
+ gtk_container_add(GTK_CONTAINER(cps->grid_units_button), label);
+ gtk_box_pack_end(GTK_BOX(hbox), cps->grid_units_button, FALSE, TRUE, 0);
+ g_signal_connect(cps->grid_units_button, "clicked", G_CALLBACK(grid_units_button_cb), NULL);
+
+ /* The absolute cursor position label
+ */
+ frame = gtk_frame_new(NULL);
+ gtk_box_pack_end(GTK_BOX(hbox), frame, FALSE, TRUE, 0);
+ gtk_container_set_border_width(GTK_CONTAINER(frame), 0);
+ gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_OUT);
+
+ label = gtk_label_new("");
+ gtk_container_add(GTK_CONTAINER(frame), label);
+ cps->cursor_position_absolute_label = label;
+ g_signal_connect(G_OBJECT(label), "size-request", G_CALLBACK(absolute_label_size_req_cb), NULL);
+
+
+ /* The relative cursor position label
+ */
+ frame = gtk_frame_new(NULL);
+ gtk_box_pack_end(GTK_BOX(hbox), frame, FALSE, TRUE, 0);
+ gtk_container_set_border_width(GTK_CONTAINER(frame), 0);
+ gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_OUT);
+ label = gtk_label_new(" __.__ __.__ ");
+ gtk_container_add(GTK_CONTAINER(frame), label);
+ cps->cursor_position_relative_label = label;
+ g_signal_connect(G_OBJECT(label), "size-request", G_CALLBACK(relative_label_size_req_cb), NULL);
+}
+
+void ghid_cursor_position_label_set_text(pcb_gtk_cursor_pos_t *cps, gchar * text)
+{
+ if (cps->cursor_position_absolute_label != NULL)
+ gtk_label_set_markup(GTK_LABEL(cps->cursor_position_absolute_label), text ? text : "");
+}
+
+void ghid_cursor_position_relative_label_set_text(pcb_gtk_cursor_pos_t *cps, gchar * text)
+{
+ if (cps->cursor_position_relative_label != NULL)
+ gtk_label_set_markup(GTK_LABEL(cps->cursor_position_relative_label), text ? text : "");
+}
+
+void ghid_set_cursor_position_labels(pcb_gtk_cursor_pos_t *cps, int compact_vertical)
+{
+ char *text, sep = ' ';
+ if (compact_vertical)
+ sep = '\n';
+
+ if (pcb_marked.status) {
+ pcb_coord_t dx = pcb_crosshair.X - pcb_marked.X;
+ pcb_coord_t dy = pcb_crosshair.Y - pcb_marked.Y;
+ pcb_coord_t r = pcb_distance(pcb_crosshair.X, pcb_crosshair.Y, pcb_marked.X, pcb_marked.Y);
+ double a = atan2(dy, dx) * PCB_RAD_TO_DEG;
+
+
+ text = pcb_strdup_printf(_("%m+r %-mS;%cphi %-.1f;%c%-mS %-mS"), conf_core.editor.grid_unit->allow, r, sep, a, sep, dx, dy);
+ ghid_cursor_position_relative_label_set_text(cps, text);
+ free(text);
+ }
+ else {
+ char text[64];
+ sprintf(text, _("r __.__;%cphi __._;%c__.__ __.__"), sep, sep);
+ ghid_cursor_position_relative_label_set_text(cps, text);
+ }
+
+ text = pcb_strdup_printf("%m+%-mS%c%-mS", conf_core.editor.grid_unit->allow, pcb_crosshair.X, sep, pcb_crosshair.Y);
+ ghid_cursor_position_label_set_text(cps, text);
+ free(text);
+}
+
Index: trunk/src_plugins/lib_gtk_common/bu_cursor_pos.h
===================================================================
--- trunk/src_plugins/lib_gtk_common/bu_cursor_pos.h (nonexistent)
+++ trunk/src_plugins/lib_gtk_common/bu_cursor_pos.h (revision 6667)
@@ -0,0 +1,14 @@
+#include
+
+typedef struct pcb_gtk_cursor_pos_s {
+ GtkWidget *cursor_position_relative_label;
+ GtkWidget *cursor_position_absolute_label;
+ GtkWidget *grid_units_label;
+ GtkWidget *grid_units_button;
+} pcb_gtk_cursor_pos_t;
+
+/* Create cps's widgets in the hbox */
+void make_cursor_position_labels(GtkWidget *hbox, pcb_gtk_cursor_pos_t *cps);
+
+/* update the content of the cursor pos labels */
+void ghid_set_cursor_position_labels(pcb_gtk_cursor_pos_t *cps, int compact_vertical);