gimpinkoptions-gui.c 5.87 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 "widgets/gimppropwidgets.h"

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

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


40
static GtkWidget * blob_image_new  (GimpInkBlobType  blob_type);
41

42

43
GtkWidget *
44 45
gimp_ink_options_gui (GimpToolOptions *tool_options)
{
46 47 48 49 50 51 52 53
  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;
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
  gimp_prop_scale_entry_new (config, "size",
                             GTK_TABLE (table), 0, 0,
                             _("Size:"),
                             1.0, 2.0, 1,
                             FALSE, 0.0, 0.0);
73 74

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

  /* sens sliders */
82
  frame = gimp_frame_new (_("Sensitivity"));
83 84 85 86 87 88 89 90 91
  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 */
92
  gimp_prop_scale_entry_new (config, "size-sensitivity",
93 94 95 96
                             GTK_TABLE (table), 0, 0,
                             _("Size:"),
                             0.01, 0.1, 1,
                             FALSE, 0.0, 0.0);
97

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

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

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

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

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

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

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

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

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

145 146
    g_list_free (children);
  }
147

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

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

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

162 163 164 165 166 167
  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);
168

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

171
  return vbox;
172 173
}

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

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

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

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

194
  return gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU);
195
}