1 |
/* |
/* |
2 |
* Copyright (C) 2006-2014 Andreas Persson |
* Copyright (C) 2006-2015 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 |
348 |
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create(context); |
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create(context); |
349 |
layout->set_text(Glib::Ascii::dtostr(prevUpperLimit+1)); |
layout->set_text(Glib::Ascii::dtostr(prevUpperLimit+1)); |
350 |
Gdk::Cairo::set_source_rgba(cr, black); |
Gdk::Cairo::set_source_rgba(cr, black); |
|
Pango::Rectangle rect = layout->get_logical_extents(); |
|
351 |
// get the text dimensions |
// get the text dimensions |
352 |
int text_width, text_height; |
int text_width, text_height; |
353 |
layout->get_pixel_size(text_width, text_height); |
layout->get_pixel_size(text_width, text_height); |
365 |
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create(context); |
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create(context); |
366 |
layout->set_text(Glib::Ascii::dtostr(upperLimit)); |
layout->set_text(Glib::Ascii::dtostr(upperLimit)); |
367 |
Gdk::Cairo::set_source_rgba(cr, black); |
Gdk::Cairo::set_source_rgba(cr, black); |
|
Pango::Rectangle rect = layout->get_logical_extents(); |
|
368 |
// get the text dimensions |
// get the text dimensions |
369 |
int text_width, text_height; |
int text_width, text_height; |
370 |
layout->get_pixel_size(text_width, text_height); |
layout->get_pixel_size(text_width, text_height); |
406 |
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create(context); |
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create(context); |
407 |
layout->set_text(Glib::Ascii::dtostr((j-1) * 128/nbZones)); |
layout->set_text(Glib::Ascii::dtostr((j-1) * 128/nbZones)); |
408 |
Gdk::Cairo::set_source_rgba(cr, black); |
Gdk::Cairo::set_source_rgba(cr, black); |
|
Pango::Rectangle rect = layout->get_logical_extents(); |
|
409 |
// get the text dimensions |
// get the text dimensions |
410 |
int text_width, text_height; |
int text_width, text_height; |
411 |
layout->get_pixel_size(text_width, text_height); |
layout->get_pixel_size(text_width, text_height); |
423 |
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create(context); |
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create(context); |
424 |
layout->set_text(Glib::Ascii::dtostr(j * 128/nbZones - 1)); |
layout->set_text(Glib::Ascii::dtostr(j * 128/nbZones - 1)); |
425 |
Gdk::Cairo::set_source_rgba(cr, black); |
Gdk::Cairo::set_source_rgba(cr, black); |
|
Pango::Rectangle rect = layout->get_logical_extents(); |
|
426 |
// get the text dimensions |
// get the text dimensions |
427 |
int text_width, text_height; |
int text_width, text_height; |
428 |
layout->get_pixel_size(text_width, text_height); |
layout->get_pixel_size(text_width, text_height); |
846 |
|
|
847 |
bool DimRegionChooser::on_focus(Gtk::DirectionType direction) |
bool DimRegionChooser::on_focus(Gtk::DirectionType direction) |
848 |
{ |
{ |
849 |
// TODO: kolla att region finns osv, dvs att det går att sätta |
// TODO: check that region exists etc, that is, that it's possible |
850 |
// fokus. |
// to set focus |
851 |
if (direction == Gtk::DIR_TAB_FORWARD || |
if (direction == Gtk::DIR_TAB_FORWARD || |
852 |
direction == Gtk::DIR_DOWN) { |
direction == Gtk::DIR_DOWN) { |
853 |
if (!has_focus()) { |
if (!has_focus()) { |
879 |
} |
} |
880 |
} |
} |
881 |
} else if (!has_focus()) { |
} else if (!has_focus()) { |
882 |
// TODO: kolla att focus_line finns! |
// TODO: check that focus_line exists |
883 |
grab_focus(); |
grab_focus(); |
884 |
return true; |
return true; |
885 |
} else { |
} else { |
886 |
// TODO: öka eller minska värde! |
// TODO: increase or decrease value |
887 |
} |
} |
888 |
|
return false; |
889 |
} |
} |
890 |
|
|
891 |
void DimRegionChooser::split_dimension_zone() { |
void DimRegionChooser::split_dimension_zone() { |
922 |
//printf("key down\n"); |
//printf("key down\n"); |
923 |
if (key->keyval == GDK_KEY_Control_L || key->keyval == GDK_KEY_Control_R) |
if (key->keyval == GDK_KEY_Control_L || key->keyval == GDK_KEY_Control_R) |
924 |
multiSelectKeyDown = true; |
multiSelectKeyDown = true; |
925 |
|
return false; |
926 |
} |
} |
927 |
|
|
928 |
bool DimRegionChooser::onKeyReleased(GdkEventKey* key) { |
bool DimRegionChooser::onKeyReleased(GdkEventKey* key) { |
929 |
//printf("key up\n"); |
//printf("key up\n"); |
930 |
if (key->keyval == GDK_KEY_Control_L || key->keyval == GDK_KEY_Control_R) |
if (key->keyval == GDK_KEY_Control_L || key->keyval == GDK_KEY_Control_R) |
931 |
multiSelectKeyDown = false; |
multiSelectKeyDown = false; |
932 |
|
return false; |
933 |
|
} |
934 |
|
|
935 |
|
void DimRegionChooser::resetSelectedZones() { |
936 |
|
this->dimzones.clear(); |
937 |
|
if (!region) { |
938 |
|
queue_draw(); // redraw required parts |
939 |
|
return; |
940 |
|
} |
941 |
|
if (maindimregno < 0 || maindimregno >= region->DimensionRegions) { |
942 |
|
queue_draw(); // redraw required parts |
943 |
|
return; |
944 |
|
} |
945 |
|
if (!region->pDimensionRegions[maindimregno]) { |
946 |
|
queue_draw(); // redraw required parts |
947 |
|
return; |
948 |
|
} |
949 |
|
gig::DimensionRegion* dimrgn = region->pDimensionRegions[maindimregno]; |
950 |
|
|
951 |
|
bool isValidZone; |
952 |
|
this->maindimcase = caseOfDimRegion(dimrgn, &isValidZone); |
953 |
|
if (!isValidZone) { |
954 |
|
queue_draw(); // redraw required parts |
955 |
|
return; |
956 |
|
} |
957 |
|
|
958 |
|
for (std::map<gig::dimension_t,int>::const_iterator it = this->maindimcase.begin(); |
959 |
|
it != this->maindimcase.end(); ++it) |
960 |
|
{ |
961 |
|
this->dimzones[it->first].insert(it->second); |
962 |
|
} |
963 |
|
|
964 |
|
// redraw required parts |
965 |
|
queue_draw(); |
966 |
|
} |
967 |
|
|
968 |
|
bool DimRegionChooser::select_dimregion(gig::DimensionRegion* dimrgn) { |
969 |
|
if (!region) return false; //.selection failed |
970 |
|
|
971 |
|
for (int dr = 0; dr < region->DimensionRegions && region->pDimensionRegions[dr]; ++dr) { |
972 |
|
if (region->pDimensionRegions[dr] == dimrgn) { |
973 |
|
// reset dim region zone selection to the requested specific dim region case |
974 |
|
maindimregno = dr; |
975 |
|
resetSelectedZones(); |
976 |
|
|
977 |
|
// emit signal that dimregion selection has changed, for external entities |
978 |
|
dimregion_selected(); |
979 |
|
|
980 |
|
return true; // selection success |
981 |
|
} |
982 |
|
} |
983 |
|
|
984 |
|
return false; //.selection failed |
985 |
} |
} |
986 |
|
|
987 |
gig::DimensionRegion* DimRegionChooser::get_main_dimregion() const { |
gig::DimensionRegion* DimRegionChooser::get_main_dimregion() const { |