1 |
/* |
/* |
2 |
* Copyright (C) 2006-2011 Andreas Persson |
* Copyright (C) 2006-2014 Andreas Persson |
3 |
* |
* |
4 |
* This program is free software; you can redistribute it and/or |
* This program is free software; you can redistribute it and/or |
5 |
* modify it under the terms of the GNU General Public License as |
* modify it under the terms of the GNU General Public License as |
22 |
#include <gdkmm/cursor.h> |
#include <gdkmm/cursor.h> |
23 |
#include <gdkmm/general.h> |
#include <gdkmm/general.h> |
24 |
#include <glibmm/stringutils.h> |
#include <glibmm/stringutils.h> |
25 |
|
#include <gtkmm/stock.h> |
26 |
|
#include <glibmm/ustring.h> |
27 |
|
#include <gtkmm/messagedialog.h> |
28 |
|
|
29 |
#include "global.h" |
#include "global.h" |
30 |
|
|
41 |
cursor_is_resize = false; |
cursor_is_resize = false; |
42 |
h = 20; |
h = 20; |
43 |
set_can_focus(); |
set_can_focus(); |
44 |
|
|
45 |
|
actionGroup = Gtk::ActionGroup::create(); |
46 |
|
actionGroup->add( |
47 |
|
Gtk::Action::create("SplitDimZone", _("Split Dimensions Zone")), |
48 |
|
sigc::mem_fun(*this, &DimRegionChooser::split_dimension_zone) |
49 |
|
); |
50 |
|
actionGroup->add( |
51 |
|
Gtk::Action::create("DeleteDimZone", _("Delete Dimension Zone")), |
52 |
|
sigc::mem_fun(*this, &DimRegionChooser::delete_dimension_zone) |
53 |
|
); |
54 |
|
|
55 |
|
uiManager = Gtk::UIManager::create(); |
56 |
|
uiManager->insert_action_group(actionGroup); |
57 |
|
Glib::ustring ui_info = |
58 |
|
"<ui>" |
59 |
|
" <popup name='PopupMenuInsideDimRegion'>" |
60 |
|
" <menuitem action='SplitDimZone'/>" |
61 |
|
" <menuitem action='DeleteDimZone'/>" |
62 |
|
" </popup>" |
63 |
|
// " <popup name='PopupMenuOutsideDimRegion'>" |
64 |
|
// " <menuitem action='Add'/>" |
65 |
|
// " </popup>" |
66 |
|
"</ui>"; |
67 |
|
uiManager->add_ui_from_string(ui_info); |
68 |
|
|
69 |
|
popup_menu_inside_dimregion = dynamic_cast<Gtk::Menu*>( |
70 |
|
uiManager->get_widget("/PopupMenuInsideDimRegion")); |
71 |
|
// popup_menu_outside_dimregion = dynamic_cast<Gtk::Menu*>( |
72 |
|
// uiManager->get_widget("/PopupMenuOutsideDimRegion")); |
73 |
|
|
74 |
add_events(Gdk::BUTTON_PRESS_MASK | Gdk::POINTER_MOTION_MASK | |
add_events(Gdk::BUTTON_PRESS_MASK | Gdk::POINTER_MOTION_MASK | |
75 |
Gdk::POINTER_MOTION_HINT_MASK); |
Gdk::POINTER_MOTION_HINT_MASK); |
76 |
|
|
77 |
for (int i = 0 ; i < 256 ; i++) dimvalue[i] = 0; |
for (int i = 0 ; i < 256 ; i++) dimvalue[i] = 0; |
78 |
labels_changed = true; |
labels_changed = true; |
79 |
|
|
80 |
|
set_tooltip_text(_("Right click here for options on altering dimension zones.")); |
81 |
} |
} |
82 |
|
|
83 |
DimRegionChooser::~DimRegionChooser() |
DimRegionChooser::~DimRegionChooser() |
405 |
queue_resize(); |
queue_resize(); |
406 |
} |
} |
407 |
|
|
408 |
|
void DimRegionChooser::refresh_all() { |
409 |
|
set_region(region); |
410 |
|
} |
411 |
|
|
412 |
void DimRegionChooser::get_dimregions(const gig::Region* region, bool stereo, |
void DimRegionChooser::get_dimregions(const gig::Region* region, bool stereo, |
413 |
std::set<gig::DimensionRegion*>& dimregs) const |
std::set<gig::DimensionRegion*>& dimregs) const |
604 |
|
|
605 |
dimregno = c | (z << bitpos); |
dimregno = c | (z << bitpos); |
606 |
|
|
607 |
|
this->dimtype = dim; |
608 |
|
this->dimzone = z; |
609 |
|
|
610 |
focus_line = dim; |
focus_line = dim; |
611 |
if (has_focus()) queue_draw(); |
if (has_focus()) queue_draw(); |
612 |
else grab_focus(); |
else grab_focus(); |
613 |
dimreg = region->pDimensionRegions[dimregno]; |
dimreg = region->pDimensionRegions[dimregno]; |
614 |
dimregion_selected(); |
dimregion_selected(); |
615 |
|
|
616 |
|
if (event->button == 3) { |
617 |
|
printf("dimregion right click\n"); |
618 |
|
popup_menu_inside_dimregion->popup(event->button, event->time); |
619 |
|
} |
620 |
} |
} |
621 |
} |
} |
622 |
return true; |
return true; |
796 |
// TODO: öka eller minska värde! |
// TODO: öka eller minska värde! |
797 |
} |
} |
798 |
} |
} |
799 |
|
|
800 |
|
void DimRegionChooser::split_dimension_zone() { |
801 |
|
printf("split_dimension_zone() type=%d, zone=%d\n", dimtype, dimzone); |
802 |
|
try { |
803 |
|
region->SplitDimensionZone( |
804 |
|
region->pDimensionDefinitions[dimtype].dimension, |
805 |
|
dimzone |
806 |
|
); |
807 |
|
} catch (RIFF::Exception e) { |
808 |
|
Gtk::MessageDialog msg(e.Message, false, Gtk::MESSAGE_ERROR); |
809 |
|
msg.run(); |
810 |
|
} catch (...) { |
811 |
|
Glib::ustring txt = _("An unknown exception occurred!"); |
812 |
|
Gtk::MessageDialog msg(txt, false, Gtk::MESSAGE_ERROR); |
813 |
|
msg.run(); |
814 |
|
} |
815 |
|
refresh_all(); |
816 |
|
} |
817 |
|
|
818 |
|
void DimRegionChooser::delete_dimension_zone() { |
819 |
|
printf("delete_dimension_zone() type=%d, zone=%d\n", dimtype, dimzone); |
820 |
|
try { |
821 |
|
region->DeleteDimensionZone( |
822 |
|
region->pDimensionDefinitions[dimtype].dimension, |
823 |
|
dimzone |
824 |
|
); |
825 |
|
} catch (RIFF::Exception e) { |
826 |
|
Gtk::MessageDialog msg(e.Message, false, Gtk::MESSAGE_ERROR); |
827 |
|
msg.run(); |
828 |
|
} catch (...) { |
829 |
|
Glib::ustring txt = _("An unknown exception occurred!"); |
830 |
|
Gtk::MessageDialog msg(txt, false, Gtk::MESSAGE_ERROR); |
831 |
|
msg.run(); |
832 |
|
} |
833 |
|
refresh_all(); |
834 |
|
} |