~ubuntu-branches/ubuntu/vivid/gimp/vivid

« back to all changes in this revision

Viewing changes to plug-ins/gimpressionist/brush.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach
  • Date: 2012-05-08 18:50:03 UTC
  • mto: (1.1.26) (0.5.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 71.
  • Revision ID: package-import@ubuntu.com-20120508185003-tltkvbaysf8d2426
ImportĀ upstreamĀ versionĀ 2.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 *
4
 
 * This program is free software; you can redistribute it and/or modify
 
4
 * This program is free software: you can redistribute it and/or modify
5
5
 * it under the terms of the GNU General Public License as published by
6
 
 * the Free Software Foundation; either version 2 of the License, or
 
6
 * the Free Software Foundation; either version 3 of the License, or
7
7
 * (at your option) any later version.
8
8
 *
9
9
 * This program is distributed in the hope that it will be useful,
12
12
 * GNU General Public License for more details.
13
13
 *
14
14
 * You should have received a copy of the GNU General Public License
15
 
 * along with this program; if not, write to the Free Software
16
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
16
 */
18
17
 
19
18
#include "config.h"
42
41
static GtkWidget    *brush_preview    = NULL;
43
42
static GtkListStore *brush_list_store = NULL;
44
43
 
45
 
static GtkWidget *brush_list          = NULL;
46
 
static GtkObject *brush_relief_adjust = NULL;
47
 
static GtkObject *brush_aspect_adjust = NULL;
48
 
static GtkObject *brush_gamma_adjust  = NULL;
49
 
static gboolean   brush_dont_update   = FALSE;
 
44
static GtkWidget     *brush_list          = NULL;
 
45
static GtkAdjustment *brush_relief_adjust = NULL;
 
46
static GtkAdjustment *brush_aspect_adjust = NULL;
 
47
static GtkAdjustment *brush_gamma_adjust  = NULL;
 
48
static gboolean       brush_dont_update   = FALSE;
50
49
 
51
50
static gchar *last_selected_brush = NULL;
52
51
 
58
57
brush_restore (void)
59
58
{
60
59
  reselect (brush_list, pcvals.selected_brush);
61
 
  gtk_adjustment_set_value (GTK_ADJUSTMENT (brush_gamma_adjust), pcvals.brushgamma);
62
 
  gtk_adjustment_set_value (GTK_ADJUSTMENT (brush_relief_adjust), pcvals.brush_relief);
63
 
  gtk_adjustment_set_value (GTK_ADJUSTMENT (brush_aspect_adjust), pcvals.brush_aspect);
 
60
  gtk_adjustment_set_value (brush_gamma_adjust, pcvals.brushgamma);
 
61
  gtk_adjustment_set_value (brush_relief_adjust, pcvals.brush_relief);
 
62
  gtk_adjustment_set_value (brush_aspect_adjust, pcvals.brush_aspect);
64
63
}
65
64
 
66
65
void
67
66
brush_store (void)
68
67
{
69
 
  pcvals.brushgamma = GTK_ADJUSTMENT (brush_gamma_adjust)->value;
 
68
  pcvals.brushgamma = gtk_adjustment_get_value (brush_gamma_adjust);
70
69
}
71
70
 
72
71
void
104
103
  guchar       *src_row;
105
104
  guchar       *src;
106
105
  gint          id;
107
 
  gint          alpha, bpp;
108
 
  gboolean      has_alpha;
 
106
  gint          bpp;
109
107
  gint          x, y;
110
108
  ppm_t        *p;
111
109
  gint          x1, y1, x2, y2;
129
127
      preset_save_button_set_sensitive (FALSE);
130
128
    }
131
129
 
132
 
  gtk_adjustment_set_value (GTK_ADJUSTMENT (brush_gamma_adjust), 1.0);
133
 
  gtk_adjustment_set_value (GTK_ADJUSTMENT (brush_aspect_adjust), 0.0);
 
130
  gtk_adjustment_set_value (brush_gamma_adjust, 1.0);
 
131
  gtk_adjustment_set_value (brush_aspect_adjust, 0.0);
134
132
 
135
133
  drawable = gimp_drawable_get (id);
136
134
 
137
135
  gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
138
136
 
139
137
  bpp = gimp_drawable_bpp (drawable->drawable_id);
140
 
  has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
141
 
  alpha = (has_alpha) ? bpp - 1 : bpp;
142
138
 
143
139
  ppm_kill (&brushppm);
144
140
  ppm_new (&brushppm, x2 - x1, y2 - y1);
364
360
 
365
361
      set_colorbrushes (fn);
366
362
 
367
 
      sc = GTK_ADJUSTMENT (brush_gamma_adjust)->value;
 
363
      sc = gtk_adjustment_get_value (brush_gamma_adjust);
368
364
      if (sc != 1.0)
369
365
        for (i = 0; i < 256; i++)
370
366
          gammatable[i] = pow (i / 255.0, sc) * 255;
373
369
          gammatable[i] = i;
374
370
 
375
371
      newheight = p.height *
376
 
                    pow (10, GTK_ADJUSTMENT (brush_aspect_adjust)->value);
 
372
        pow (10, gtk_adjustment_get_value (brush_aspect_adjust));
377
373
 
378
374
      sc = p.width > newheight ? p.width : newheight;
379
375
      sc = 100.0 / sc;
448
444
        }
449
445
 
450
446
      brush_dont_update = TRUE;
451
 
      gtk_adjustment_set_value (GTK_ADJUSTMENT (brush_gamma_adjust), 1.0);
452
 
      gtk_adjustment_set_value (GTK_ADJUSTMENT (brush_aspect_adjust), 0.0);
 
447
      gtk_adjustment_set_value (brush_gamma_adjust, 1.0);
 
448
      gtk_adjustment_set_value (brush_aspect_adjust, 0.0);
453
449
      brush_dont_update = FALSE;
454
450
 
455
451
      if (brush)
506
502
 
507
503
  label = gtk_label_new_with_mnemonic (_("_Brush"));
508
504
 
509
 
  thispage = gtk_vbox_new (FALSE, 12);
 
505
  thispage = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
510
506
  gtk_container_set_border_width (GTK_CONTAINER (thispage), 12);
511
507
  gtk_widget_show (thispage);
512
508
 
513
 
  box1 = gtk_hbox_new (FALSE, 12);
 
509
  box1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
514
510
  gtk_box_pack_start (GTK_BOX (thispage), box1, TRUE,TRUE,0);
515
511
  gtk_widget_show (box1);
516
512
 
521
517
 
522
518
  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
523
519
 
524
 
  box2 = gtk_vbox_new (FALSE, 12);
 
520
  box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
525
521
  gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
526
522
  gtk_widget_show (box2);
527
523
 
537
533
  g_signal_connect (brush_preview, "size-allocate",
538
534
                    G_CALLBACK (brush_preview_size_allocate), NULL);
539
535
 
540
 
  box3 = gtk_vbox_new (FALSE, 2);
 
536
  box3 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
541
537
  gtk_box_pack_end (GTK_BOX (box2), box3, FALSE, FALSE,0);
542
538
  gtk_widget_show (box3);
543
539
 
546
542
  gtk_box_pack_start (GTK_BOX (box3), tmpw, FALSE, FALSE,0);
547
543
  gtk_widget_show (tmpw);
548
544
 
549
 
  brush_gamma_adjust = gtk_adjustment_new (pcvals.brushgamma,
550
 
                                           0.5, 3.0, 0.1, 0.1, 1.0);
551
 
  tmpw = gtk_hscale_new (GTK_ADJUSTMENT (brush_gamma_adjust));
 
545
  brush_gamma_adjust = GTK_ADJUSTMENT (gtk_adjustment_new (pcvals.brushgamma,
 
546
                                                           0.5, 3.0, 0.1, 0.1, 1.0));
 
547
  tmpw = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, brush_gamma_adjust);
552
548
  gtk_widget_set_size_request (GTK_WIDGET (tmpw), 100, 30);
553
549
  gtk_scale_set_draw_value (GTK_SCALE (tmpw), FALSE);
554
550
  gtk_scale_set_digits (GTK_SCALE (tmpw), 2);
561
557
  gimp_help_set_help_data
562
558
    (tmpw, _("Changes the gamma (brightness) of the selected brush"), NULL);
563
559
 
564
 
  box3 = gtk_hbox_new (FALSE, 6);
 
560
  box3 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
565
561
  gtk_box_pack_start (GTK_BOX (thispage), box3, FALSE, FALSE,0);
566
562
  gtk_widget_show (box3);
567
563
 
594
590
  gtk_box_pack_start (GTK_BOX (thispage), table, FALSE, FALSE, 0);
595
591
  gtk_widget_show (table);
596
592
 
597
 
  brush_aspect_adjust =
 
593
  brush_aspect_adjust = (GtkAdjustment *)
598
594
    gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
599
595
                          _("Aspect ratio:"),
600
596
                          150, -1, pcvals.brush_aspect,
607
603
  g_signal_connect (brush_aspect_adjust, "value-changed",
608
604
                    G_CALLBACK (brush_asepct_adjust_cb), &pcvals.brush_aspect);
609
605
 
610
 
  brush_relief_adjust =
 
606
  brush_relief_adjust = (GtkAdjustment *)
611
607
    gimp_scale_entry_new (GTK_TABLE (table), 0, 1,
612
608
                          _("Relief:"),
613
609
                          150, -1, pcvals.brush_relief,