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, xS(320), yS(160), xS(320), yS(160), 0)
31 this->plugin = plugin;
40 StylizeObjWindow::~StylizeObjWindow()
44 void StylizeObjWindow::create_objects()
47 int ys10 = yS(10), ys15 = yS(15);
48 int x = xs10, y = ys10;
49 BC_Title *title = new BC_Title(x, y, _("StylizeObj"));
51 y += title->get_h() + ys10;
53 add_subwindow(title = new BC_Title(x1, y, _("Mode: ")));
54 x1 += title->get_w() + ys15;
55 add_subwindow(mode = new StylizeObjMode(this, x1, y, &plugin->config.mode));
56 mode->create_objects();
57 y += mode->get_h() + ys10;
63 void StylizeObjWindow::update_params()
67 if( plugin->config.mode == MODE_PENCIL_SKETCH ||
68 plugin->config.mode == MODE_COLOR_SKETCH ) {
71 add_subwindow(smooth_title = new BC_Title(x,y,_("Smooth:")));
73 add_subwindow(smoothing = new StylizeObjFSlider(this,
74 x1,y,xS(180), 0,xS(100), &plugin->config.smoothing));
75 y += smoothing->get_h() + ys10;
77 add_subwindow(edge_title = new BC_Title(x,y,_("Edges:")));
79 add_subwindow(edge_strength = new StylizeObjFSlider(this,
80 x1,y,xS(180), 0,xS(100), &plugin->config.edge_strength));
81 y += edge_strength->get_h() + ys10;
83 add_subwindow(shade_title = new BC_Title(x,y,_("Shade:")));
85 add_subwindow(shade_factor = new StylizeObjFSlider(this,
86 x1,y,xS(180), 0,xS(100), &plugin->config.shade_factor));
87 //y += shade_factor->get_h() + ys10;
90 delete smooth_title; smooth_title = 0;
91 delete smoothing; smoothing = 0;
92 delete edge_title; edge_title = 0;
93 delete edge_strength; edge_strength = 0;
94 delete shade_title; shade_title = 0;
95 delete shade_factor; shade_factor = 0;
99 StylizeObjModeItem::StylizeObjModeItem(StylizeObjMode *popup, int type, const char *text)
106 StylizeObjModeItem::~StylizeObjModeItem()
110 int StylizeObjModeItem::handle_event()
113 popup->win->update_params();
114 return popup->handle_event();
117 StylizeObjMode::StylizeObjMode(StylizeObjWindow *win, int x, int y, int *value)
118 : BC_PopupMenu(x, y, xS(150), "", 1)
124 StylizeObjMode::~StylizeObjMode()
128 void StylizeObjMode::create_objects()
130 add_item(new StylizeObjModeItem(this, MODE_EDGE_SMOOTH, _("Edge smooth")));
131 add_item(new StylizeObjModeItem(this, MODE_EDGE_RECURSIVE, _("Edge recursive")));
132 add_item(new StylizeObjModeItem(this, MODE_DETAIL_ENHANCE, _("Detail Enhance")));
133 add_item(new StylizeObjModeItem(this, MODE_PENCIL_SKETCH, _("Pencil Sketch")));
134 add_item(new StylizeObjModeItem(this, MODE_COLOR_SKETCH, _("Color Sketch")));
135 add_item(new StylizeObjModeItem(this, MODE_STYLIZATION, _("Stylization")));
139 int StylizeObjMode::handle_event()
141 win->plugin->send_configure_change();
145 void StylizeObjMode::update(int v)
147 set_value(*value = v);
150 void StylizeObjMode::set_value(int v)
152 int i = total_items();
153 while( --i >= 0 && ((StylizeObjModeItem*)get_item(i))->type != v );
154 if( i >= 0 ) set_text(get_item(i)->get_text());
157 StylizeObjFSlider::StylizeObjFSlider(StylizeObjWindow *win,
158 int x, int y, int w, float min, float max, float *output)
159 : BC_FSlider(x, y, 0,w,w, min,max, *output)
162 this->output = output;
164 StylizeObjFSlider::~StylizeObjFSlider()
168 int StylizeObjFSlider::handle_event()
170 *output = get_value();
171 win->plugin->send_configure_change();