add olaf's neophyte theme, honor numlock and use kp numerics
[goodguy/history.git] / cinelerra-5.1 / plugins / findobj / findobjwindow.C
index 5ccec7689c18474c033ba3d5f4e7a0b90dc51140..2f5cd7a2b4725b482e1c6a396de81a5a1630b250 100644 (file)
@@ -32,7 +32,7 @@
 
 
 FindObjWindow::FindObjWindow(FindObjMain *plugin)
- : PluginClientWindow(plugin, 500, 660, 500, 660, 0)
+ : PluginClientWindow(plugin, 500, 700, 500, 700, 0)
 {
        this->plugin = plugin;
 }
@@ -47,17 +47,35 @@ void FindObjWindow::create_objects()
        plugin->load_configuration();
 
        BC_Title *title;
+       add_subwindow(title = new BC_Title(x1, y, _("Mode:")));
+       add_subwindow(mode = new FindObjMode(plugin, this,
+               x1 + 100, y));
+       add_subwindow(reset = new FindObjReset(plugin, this, get_w()-15, y));
+       mode->create_objects();
+       y += mode->get_h() + 10;
+       int y0 = y;
        add_subwindow(title = new BC_Title(x1, y, _("Algorithm:")));
        add_subwindow(algorithm = new FindObjAlgorithm(plugin, this,
-               x1 + title->get_w() + 10, y));
+               x1 + 100, y));
        algorithm->create_objects();
-       add_subwindow(reset = new FindObjReset(plugin, this, get_w() - 15, y));
        y += algorithm->get_h() + plugin->get_theme()->widget_border;
-
        add_subwindow(use_flann = new FindObjUseFlann(plugin, this, x, y));
-       y += use_flann->get_h() + plugin->get_theme()->widget_border + 20;
-
-       int x0 = x + 200;
+       y += use_flann->get_h() + 10;
+
+       int y1 = y;  y = y0;
+       add_subwindow(replace_object = new FindObjReplace(plugin, this,x3, y));
+       y += replace_object->get_h() + 10;
+       add_subwindow(draw_match = new FindObjDrawMatch(plugin, this, x3, y));
+       y += draw_match->get_h() + 10;
+       add_subwindow(aspect = new FindObjAspect(plugin, this, x3, y));
+       y += aspect->get_h() + 10;
+       add_subwindow(scale = new FindObjScale(plugin, this, x3, y));
+       y += scale->get_h() + 10;
+       add_subwindow(rotate = new FindObjRotate(plugin, this, x3, y));
+       y += rotate->get_h() + 10;
+       add_subwindow(translate = new FindObjTranslate(plugin, this, x3, y));
+
+       int x0 = x + 200;  y = y1 + 10;
        add_subwindow(title = new BC_Title(x, y, _("Output/scene layer:")));
        scene_layer = new FindObjLayer(plugin, this, x0, y,
                &plugin->config.scene_layer);
@@ -76,10 +94,11 @@ void FindObjWindow::create_objects()
        replace_layer->create_objects();
        y += replace_layer->get_h() + plugin->get_theme()->widget_border + 10;
 
+       y += 10;
        add_subwindow(title = new BC_Title(x+15, y, _("Units: 0 to 100 percent")));
        y += title->get_h();
 
-       int y1 = y;
+       y1 = y;
        add_subwindow(title = new BC_Title(x1, y + 10, _("Scene X:")));
        Track *track = plugin->server->plugin->track;
        int trk_w = track->track_w, trk_h = track->track_h;
@@ -184,9 +203,6 @@ void FindObjWindow::create_objects()
        object_h_text->center = object_h;
 
        y = y1;
-       add_subwindow(replace_object = new FindObjReplace(plugin, this,
-                       x3, y - title->get_h() - 15));
-
        add_subwindow(title = new BC_Title(x3, y + 10, _("Replace X:")));
        drag_w = trk_w * plugin->config.replace_w / 100.;
        drag_h = trk_h * plugin->config.replace_h / 100.;
@@ -322,6 +338,11 @@ void FindObjWindow::update_gui()
        FindObjConfig &conf = plugin->config;
        algorithm->update(conf.algorithm);
        use_flann->update(conf.use_flann);
+       draw_match->update(conf.draw_match);
+       aspect->update(conf.aspect);
+       scale->update(conf.scale);
+       rotate->update(conf.rotate);
+       translate->update(conf.translate);
        drag_object->update(conf.drag_object);
        object_x->update(conf.object_x);
        object_x_text->update((float)conf.object_x);
@@ -520,6 +541,7 @@ int64_t FindObjDragScene::get_drag_position()
 }
 void FindObjDragScene::update_gui()
 {
+       bound();
        Track *track = get_drag_track();
        int trk_w = track->track_w, trk_h = track->track_h;
        float ctr_x = drag_x + drag_w/2, ctr_y = drag_y + drag_h/2;
@@ -559,6 +581,7 @@ int64_t FindObjDragObject::get_drag_position()
 }
 void FindObjDragObject::update_gui()
 {
+       bound();
        Track *track = get_drag_track();
        int trk_w = track->track_w, trk_h = track->track_h;
        float ctr_x = drag_x + drag_w/2, ctr_y = drag_y + drag_h/2;
@@ -598,6 +621,7 @@ int64_t FindObjDragReplace::get_drag_position()
 }
 void FindObjDragReplace::update_gui()
 {
+       bound();
        Track *track = get_drag_track();
        int trk_w = track->track_w, trk_h = track->track_h;
        float ctr_x = drag_x + drag_w/2, ctr_y = drag_y + drag_h/2;
@@ -729,6 +753,138 @@ int FindObjUseFlann::handle_event()
        return 1;
 }
 
+FindObjDrawMatch::FindObjDrawMatch(FindObjMain *plugin, FindObjWindow *gui,
+       int x, int y)
+ : BC_CheckBox(x, y, plugin->config.draw_match, _("Draw match"))
+{
+       this->gui = gui;
+       this->plugin = plugin;
+}
+
+int FindObjDrawMatch::handle_event()
+{
+       plugin->config.draw_match = get_value();
+       plugin->send_configure_change();
+       return 1;
+}
+
+FindObjAspect::FindObjAspect(FindObjMain *plugin, FindObjWindow *gui,
+       int x, int y)
+ : BC_CheckBox(x, y, plugin->config.aspect, _("Aspect"))
+{
+       this->gui = gui;
+       this->plugin = plugin;
+}
+
+int FindObjAspect::handle_event()
+{
+       plugin->config.aspect = get_value();
+       plugin->send_configure_change();
+       return 1;
+}
+
+FindObjScale::FindObjScale(FindObjMain *plugin, FindObjWindow *gui,
+       int x, int y)
+ : BC_CheckBox(x, y, plugin->config.scale, _("Scale"))
+{
+       this->gui = gui;
+       this->plugin = plugin;
+}
+
+int FindObjScale::handle_event()
+{
+       plugin->config.scale = get_value();
+       plugin->send_configure_change();
+       return 1;
+}
+
+FindObjRotate::FindObjRotate(FindObjMain *plugin, FindObjWindow *gui,
+       int x, int y)
+ : BC_CheckBox(x, y, plugin->config.rotate, _("Rotate"))
+{
+       this->gui = gui;
+       this->plugin = plugin;
+}
+
+int FindObjRotate::handle_event()
+{
+       plugin->config.rotate = get_value();
+       plugin->send_configure_change();
+       return 1;
+}
+
+FindObjTranslate::FindObjTranslate(FindObjMain *plugin, FindObjWindow *gui,
+       int x, int y)
+ : BC_CheckBox(x, y, plugin->config.translate, _("Translate"))
+{
+       this->gui = gui;
+       this->plugin = plugin;
+}
+
+int FindObjTranslate::handle_event()
+{
+       plugin->config.translate = get_value();
+       plugin->send_configure_change();
+       return 1;
+}
+
+FindObjMode::FindObjMode(FindObjMain *plugin, FindObjWindow *gui, int x, int y)
+ : BC_PopupMenu(x, y, calculate_w(gui), to_text(plugin->config.mode))
+{
+       this->plugin = plugin;
+       this->gui = gui;
+}
+
+int FindObjMode::handle_event()
+{
+       plugin->config.mode = from_text(get_text());
+       plugin->send_configure_change();
+       return 1;
+}
+
+void FindObjMode::create_objects()
+{
+       add_item(new BC_MenuItem(to_text(MODE_SQUARE)));
+       add_item(new BC_MenuItem(to_text(MODE_RHOMBUS)));
+       add_item(new BC_MenuItem(to_text(MODE_RECTANGLE)));
+       add_item(new BC_MenuItem(to_text(MODE_PARALLELOGRAM)));
+       add_item(new BC_MenuItem(to_text(MODE_QUADRILATERAL)));
+}
+int FindObjMode::from_text(char *text)
+{
+       if(!strcmp(text, _("Square"))) return MODE_SQUARE;
+       if(!strcmp(text, _("Rhombus"))) return MODE_RHOMBUS;
+       if(!strcmp(text, _("Rectangle"))) return MODE_RECTANGLE;
+       if(!strcmp(text, _("Parallelogram"))) return MODE_PARALLELOGRAM;
+       if(!strcmp(text, _("Quadrilateral"))) return MODE_QUADRILATERAL;
+       return MODE_NONE;
+}
+
+void FindObjMode::update(int mode)
+{
+       set_text(to_text(mode));
+}
+
+char* FindObjMode::to_text(int mode)
+{
+       switch( mode ) {
+       case MODE_SQUARE: return _("Square");
+       case MODE_RHOMBUS: return _("Rhombus");
+       case MODE_RECTANGLE: return _("Rectangle");
+       case MODE_PARALLELOGRAM: return _("Parallelogram");
+       case MODE_QUADRILATERAL: return _("Quadrilateral");
+       }
+       return _("None");
+}
+
+int FindObjMode::calculate_w(FindObjWindow *gui)
+{
+       int result = 0;
+       for( int mode=MODE_NONE; mode<MODE_MAX; ++mode )
+               result = MAX(result, gui->get_text_width(MEDIUMFONT, to_text(mode)));
+       return result + 50;
+}
+
 
 FindObjLayer::FindObjLayer(FindObjMain *plugin, FindObjWindow *gui,
        int x, int y, int *value)