gimpinkoptions-gui.c 5.93 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
/* The GIMP -- an image manipulation program
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
 * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#include "config.h"

#include <gtk/gtk.h>

#include "libgimpwidgets/gimpwidgets.h"

#include "tools-types.h"

27 28
#include "config/gimpconfig-utils.h"

29
#include "paint/gimpinkoptions.h"
30

31
#include "widgets/gimpblobeditor.h"
32

33
#include "gimpinkoptions-gui.h"
34
#include "gimppaintoptions-gui.h"
35

36
#include "gimp-intl.h"
37 38


39
static GtkWidget * blob_image_new  (GimpInkBlobType  blob_type);
40

41

42
GtkWidget *
43 44
gimp_ink_options_gui (GimpToolOptions *tool_options)
{
45 46 47 48 49 50 51 52
  GObject        *config      = G_OBJECT (tool_options);
  GimpInkOptions *ink_options = GIMP_INK_OPTIONS (tool_options);
  GtkWidget      *table;
  GtkWidget      *vbox;
  GtkWidget      *blob_vbox;
  GtkWidget      *hbox;
  GtkWidget      *frame;
  GtkWidget      *editor;
53
  GtkObject      *adj;
54

55
  vbox = gimp_paint_options_gui (tool_options);
56 57

  /* adjust sliders */
58
  frame = gimp_frame_new (_("Adjustment"));
59 60 61 62 63 64 65 66 67
  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0);
  gtk_widget_show (frame);

  table = gtk_table_new (2, 3, FALSE);
  gtk_table_set_col_spacings (GTK_TABLE (table), 2);
  gtk_container_add (GTK_CONTAINER (frame), table);
  gtk_widget_show (table);

  /*  size slider  */
68 69 70 71 72 73
  adj = gimp_prop_scale_entry_new (config, "size",
                                   GTK_TABLE (table), 0, 0,
                                   _("Size:"),
                                   1.0, 2.0, 1,
                                   FALSE, 0.0, 0.0);
  gimp_scale_entry_set_logarithmic (adj, TRUE);
74 75

  /* angle adjust slider */
76 77 78 79 80
  gimp_prop_scale_entry_new (config, "tilt-angle",
                             GTK_TABLE (table), 0, 1,
                             _("Angle:"),
                             1.0, 10.0, 1,
                             FALSE, 0.0, 0.0);
81 82

  /* sens sliders */
83
  frame = gimp_frame_new (_("Sensitivity"));
84 85 86 87 88 89 90 91 92
  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0);
  gtk_widget_show (frame);

  table = gtk_table_new (3, 3, FALSE);
  gtk_table_set_col_spacings (GTK_TABLE (table), 2);
  gtk_container_add (GTK_CONTAINER (frame), table);
  gtk_widget_show (table);

  /* size sens slider */
93
  gimp_prop_scale_entry_new (config, "size-sensitivity",
94 95 96 97
                             GTK_TABLE (table), 0, 0,
                             _("Size:"),
                             0.01, 0.1, 1,
                             FALSE, 0.0, 0.0);
98

99
  /* tilt sens slider */
100 101 102 103 104
  gimp_prop_scale_entry_new (config, "tilt-sensitivity",
                             GTK_TABLE (table), 0, 1,
                             _("Tilt:"),
                             0.01, 0.1, 1,
                             FALSE, 0.0, 0.0);
105 106

  /* velocity sens slider */
107 108 109 110 111
  gimp_prop_scale_entry_new (config, "vel-sensitivity",
                             GTK_TABLE (table), 0, 2,
                             _("Speed:"),
                             0.01, 0.1, 1,
                             FALSE, 0.0, 0.0);
112 113 114

  /*  bottom hbox */
  hbox = gtk_hbox_new (FALSE, 2);
115
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
116 117
  gtk_widget_show (hbox);

118
  /* Blob type radiobuttons */
119 120
  frame = gimp_prop_enum_radio_frame_new (config, "blob-type",
                                          _("Type"), 0, 0);
121 122 123
  gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
  gtk_widget_show (frame);

124
  {
125 126 127
    GList           *children;
    GList           *list;
    GimpInkBlobType  blob_type;
128

129 130
    children =
      gtk_container_get_children (GTK_CONTAINER (GTK_BIN (frame)->child));
131

132
    for (list = children, blob_type = GIMP_INK_BLOB_TYPE_ELLIPSE;
133
         list;
134
         list = g_list_next (list), blob_type++)
135
      {
136
        GtkWidget *radio = GTK_WIDGET (list->data);
137
        GtkWidget *blob;
138

139
        gtk_container_remove (GTK_CONTAINER (radio), GTK_BIN (radio)->child);
140

141
        blob = blob_image_new (blob_type);
142 143 144
        gtk_container_add (GTK_CONTAINER (radio), blob);
        gtk_widget_show (blob);
      }
145

146 147
    g_list_free (children);
  }
148

149
  /* Blob shape widget */
150
  frame = gimp_frame_new (_("Shape"));
151 152 153
  gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
  gtk_widget_show (frame);

154 155 156
  blob_vbox = gtk_vbox_new (FALSE, 2);
  gtk_container_add (GTK_CONTAINER (frame), blob_vbox);
  gtk_widget_show (blob_vbox);
157 158 159

  frame = gtk_aspect_frame_new (NULL, 0.0, 0.5, 1.0, FALSE);
  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
160
  gtk_box_pack_start (GTK_BOX (blob_vbox), frame, TRUE, TRUE, 0);
161
  gtk_widget_show (frame);
162

163 164 165 166 167 168
  editor = gimp_blob_editor_new (ink_options->blob_type,
                                 ink_options->blob_aspect,
                                 ink_options->blob_angle);
  gtk_widget_set_size_request (editor, 60, 60);
  gtk_container_add (GTK_CONTAINER (frame), editor);
  gtk_widget_show (editor);
169

170
  gimp_config_connect (config, G_OBJECT (editor), NULL);
171

172
  return vbox;
173 174
}

175
static GtkWidget *
176
blob_image_new (GimpInkBlobType blob_type)
177
{
178
  const gchar *stock_id = NULL;
179 180 181 182

  switch (blob_type)
    {
    case GIMP_INK_BLOB_TYPE_ELLIPSE:
183
      stock_id = GIMP_STOCK_SHAPE_CIRCLE;
184 185 186
      break;

    case GIMP_INK_BLOB_TYPE_SQUARE:
187
      stock_id = GIMP_STOCK_SHAPE_SQUARE;
188 189 190
      break;

    case GIMP_INK_BLOB_TYPE_DIAMOND:
191
      stock_id = GIMP_STOCK_SHAPE_DIAMOND;
192 193 194
      break;
    }

195
  return gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU);
196
}