00001 #include "whirlwindow.h"
00002
00003 #include <libintl.h>
00004 #define _(String) gettext(String)
00005 #define gettext_noop(String) String
00006 #define N_(String) gettext_noop (String)
00007
00008
00009 WhirlThread::WhirlThread(WhirlMain *client)
00010 : Thread()
00011 {
00012 this->client = client;
00013 synchronous = 1;
00014 gui_started.lock();
00015 }
00016
00017 WhirlThread::~WhirlThread()
00018 {
00019 }
00020
00021 void WhirlThread::run()
00022 {
00023 window = new WhirlWindow(client);
00024 window->create_objects();
00025 gui_started.unlock();
00026 window->run_window();
00027 delete window;
00028 }
00029
00030
00031
00032
00033
00034
00035 WhirlWindow::WhirlWindow(WhirlMain *client)
00036 : BC_Window("", MEGREY, client->gui_string, 210, 170, 200, 170, 0, !client->show_initially)
00037 { this->client = client; }
00038
00039 WhirlWindow::~WhirlWindow()
00040 {
00041 delete angle_slider;
00042 delete pinch_slider;
00043 delete radius_slider;
00044 delete automation[0];
00045 delete automation[1];
00046 delete automation[2];
00047 }
00048
00049 int WhirlWindow::create_objects()
00050 {
00051 int x = 10, y = 10;
00052 add_tool(new BC_Title(x, y, _("Angle")));
00053 add_tool(automation[0] = new AutomatedFn(client, this, x + 80, y, 0));
00054 y += 20;
00055 add_tool(angle_slider = new AngleSlider(client, x, y));
00056 y += 35;
00057 add_tool(new BC_Title(x, y, _("Pinch")));
00058 add_tool(automation[1] = new AutomatedFn(client, this, x + 80, y, 1));
00059 y += 20;
00060 add_tool(pinch_slider = new PinchSlider(client, x, y));
00061 y += 35;
00062 add_tool(new BC_Title(x, y, _("Radius")));
00063 add_tool(automation[2] = new AutomatedFn(client, this, x + 80, y, 2));
00064 y += 20;
00065 add_tool(radius_slider = new RadiusSlider(client, x, y));
00066 }
00067
00068 int WhirlWindow::close_event()
00069 {
00070 client->save_defaults();
00071 hide_window();
00072 client->send_hide_gui();
00073 }
00074
00075 AngleSlider::AngleSlider(WhirlMain *client, int x, int y)
00076 : BC_ISlider(x, y, 190, 30, 200, client->angle, -MAXANGLE, MAXANGLE, DKGREY, BLACK, 1)
00077 {
00078 this->client = client;
00079 }
00080 AngleSlider::~AngleSlider()
00081 {
00082 }
00083 int AngleSlider::handle_event()
00084 {
00085 client->angle = get_value();
00086 client->send_configure_change();
00087 }
00088
00089 PinchSlider::PinchSlider(WhirlMain *client, int x, int y)
00090 : BC_ISlider(x, y, 190, 30, 200, client->pinch, -MAXPINCH, MAXPINCH, DKGREY, BLACK, 1)
00091 {
00092 this->client = client;
00093 }
00094 PinchSlider::~PinchSlider()
00095 {
00096 }
00097 int PinchSlider::handle_event()
00098 {
00099 client->pinch = get_value();
00100 client->send_configure_change();
00101 }
00102
00103 RadiusSlider::RadiusSlider(WhirlMain *client, int x, int y)
00104 : BC_ISlider(x, y, 190, 30, 200, client->radius, 0, MAXRADIUS, DKGREY, BLACK, 1)
00105 {
00106 this->client = client;
00107 }
00108 RadiusSlider::~RadiusSlider()
00109 {
00110 }
00111 int RadiusSlider::handle_event()
00112 {
00113 client->radius = get_value();
00114 client->send_configure_change();
00115 }
00116
00117 AutomatedFn::AutomatedFn(WhirlMain *client, WhirlWindow *window, int x, int y, int number)
00118 : BC_CheckBox(x, y, 16, 16, client->automated_function == number, _("Automate"))
00119 {
00120 this->client = client;
00121 this->window = window;
00122 this->number = number;
00123 }
00124
00125 AutomatedFn::~AutomatedFn()
00126 {
00127 }
00128
00129 int AutomatedFn::handle_event()
00130 {
00131 for(int i = 0; i < 3; i++)
00132 {
00133 if(i != number) window->automation[i]->update(0);
00134 }
00135 update(1);
00136 client->automated_function = number;
00137 client->send_configure_change();
00138 }
00139