3 * Copyright (C) 2014 Adam Williams <broadcast at earthling dot net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "bcdisplayinfo.h"
24 #include "stylizeobj.h"
25 #include "stylizeobjwindow.h"
28 StylizeObjWindow::StylizeObjWindow(StylizeObj *plugin)
29 : PluginClientWindow(plugin, 320, 160, 320, 160, 0)
31 this->plugin = plugin;
40 StylizeObjWindow::~StylizeObjWindow()
44 void StylizeObjWindow::create_objects()
47 BC_Title *title = new BC_Title(x, y, _("StylizeObj"));
49 y += title->get_h() + 10;
51 add_subwindow(title = new BC_Title(x1, y, _("Mode: ")));
52 x1 += title->get_w() + 15;
53 add_subwindow(mode = new StylizeObjMode(this, x1, y, &plugin->config.mode));
54 mode->create_objects();
55 y += mode->get_h() + 10;
61 void StylizeObjWindow::update_params()
64 if( plugin->config.mode == MODE_PENCIL_SKETCH ||
65 plugin->config.mode == MODE_COLOR_SKETCH ) {
68 add_subwindow(smooth_title = new BC_Title(x,y,_("Smooth:")));
70 add_subwindow(smoothing = new StylizeObjFSlider(this,
71 x1,y,180, 0,100, &plugin->config.smoothing));
72 y += smoothing->get_h() + 10;
74 add_subwindow(edge_title = new BC_Title(x,y,_("Edges:")));
76 add_subwindow(edge_strength = new StylizeObjFSlider(this,
77 x1,y,180, 0,100, &plugin->config.edge_strength));
78 y += edge_strength->get_h() + 10;
80 add_subwindow(shade_title = new BC_Title(x,y,_("Shade:")));
82 add_subwindow(shade_factor = new StylizeObjFSlider(this,
83 x1,y,180, 0,100, &plugin->config.shade_factor));
84 //y += shade_factor->get_h() + 10;
87 delete smooth_title; smooth_title = 0;
88 delete smoothing; smoothing = 0;
89 delete edge_title; edge_title = 0;
90 delete edge_strength; edge_strength = 0;
91 delete shade_title; shade_title = 0;
92 delete shade_factor; shade_factor = 0;
96 StylizeObjModeItem::StylizeObjModeItem(StylizeObjMode *popup, int type, const char *text)
103 StylizeObjModeItem::~StylizeObjModeItem()
107 int StylizeObjModeItem::handle_event()
110 popup->win->update_params();
111 return popup->handle_event();
114 StylizeObjMode::StylizeObjMode(StylizeObjWindow *win, int x, int y, int *value)
115 : BC_PopupMenu(x, y, 150, "", 1)
121 StylizeObjMode::~StylizeObjMode()
125 void StylizeObjMode::create_objects()
127 add_item(new StylizeObjModeItem(this, MODE_EDGE_SMOOTH, _("Edge smooth")));
128 add_item(new StylizeObjModeItem(this, MODE_EDGE_RECURSIVE, _("Edge recursive")));
129 add_item(new StylizeObjModeItem(this, MODE_DETAIL_ENHANCE, _("Detail Enhance")));
130 add_item(new StylizeObjModeItem(this, MODE_PENCIL_SKETCH, _("Pencil Sketch")));
131 add_item(new StylizeObjModeItem(this, MODE_COLOR_SKETCH, _("Color Sketch")));
132 add_item(new StylizeObjModeItem(this, MODE_STYLIZATION, _("Stylization")));
136 int StylizeObjMode::handle_event()
138 win->plugin->send_configure_change();
142 void StylizeObjMode::update(int v)
144 set_value(*value = v);
147 void StylizeObjMode::set_value(int v)
149 int i = total_items();
150 while( --i >= 0 && ((StylizeObjModeItem*)get_item(i))->type != v );
151 if( i >= 0 ) set_text(get_item(i)->get_text());
154 StylizeObjFSlider::StylizeObjFSlider(StylizeObjWindow *win,
155 int x, int y, int w, float min, float max, float *output)
156 : BC_FSlider(x, y, 0,w,w, min,max, *output)
159 this->output = output;
161 StylizeObjFSlider::~StylizeObjFSlider()
165 int StylizeObjFSlider::handle_event()
167 *output = get_value();
168 win->plugin->send_configure_change();