block 'a' to 'z', '+' and '-' for numeric input fields, Issue 2808

This commit is contained in:
Ingo
2015-06-13 14:58:49 +02:00
parent 6ef1edbe8a
commit 4f81331ea7
4 changed files with 36 additions and 16 deletions

View File

@@ -56,6 +56,9 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PROC_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PROC_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PROC_FLAGS}")
#stop compile on typos like std:swap (missing colon will be detected as unused label)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=unused-label")
if (WIN32)
# we additionnally look in the MinGW path first then in the Gtkmm path,
# so if you wish to build some dependant library, you have to install them in MinGW to use them

View File

@@ -32,7 +32,7 @@
using namespace rtengine::procparams;
EditorPanel::EditorPanel (FilePanel* filePanel)
: beforePreviewHandler(NULL), beforeIarea(NULL), beforeBox(NULL), afterBox(NULL), afterHeaderBox(NULL), parent(NULL), ipc(NULL), beforeIpc(NULL), isProcessing(false), catalogPane(NULL), iHistoryShow(NULL), iHistoryHide(NULL), iBeforeLockON(NULL),iBeforeLockOFF(NULL), iRightPanel_1_Show(NULL), iRightPanel_1_Hide(NULL), iTopPanel_1_Show(NULL), iTopPanel_1_Hide(NULL), openThm(NULL), realized(false) {
: realized(false), iHistoryShow(NULL), iHistoryHide(NULL), iTopPanel_1_Show(NULL), iTopPanel_1_Hide(NULL), iRightPanel_1_Show(NULL), iRightPanel_1_Hide(NULL), iBeforeLockON(NULL),iBeforeLockOFF(NULL), beforePreviewHandler(NULL), beforeIarea(NULL), beforeBox(NULL), afterBox(NULL), afterHeaderBox(NULL), parent(NULL), openThm(NULL), ipc(NULL), beforeIpc(NULL), isProcessing(false), catalogPane(NULL) {
epih = new EditorPanelIdleHelper;
epih->epanel = this;
@@ -952,10 +952,12 @@ bool EditorPanel::handleShortcutKey (GdkEventKey* event) {
return true;
case GDK_plus:
case GDK_equal:
case GDK_KP_Add:
iareapanel->imageArea->zoomPanel->zoomInClicked();
return true;
case GDK_minus:
case GDK_underscore:
case GDK_KP_Subtract:
iareapanel->imageArea->zoomPanel->zoomOutClicked();
return true;
case GDK_z://GDK_1
@@ -995,7 +997,7 @@ bool EditorPanel::handleShortcutKey (GdkEventKey* event) {
return true;
case GDK_F5:
openThm->openDefaultViewer(event->state & GDK_SHIFT_MASK ? 2 : 1);
openThm->openDefaultViewer((event->state & GDK_SHIFT_MASK) ? 2 : 1);
return true;
case GDK_y: // synchronize filebrowser with image in Editor
if (!simpleEditor && fPanel && !fname.empty()){

View File

@@ -75,7 +75,7 @@ bool removeIfThere (Gtk::Container* cont, Gtk::Widget* w, bool increference) {
Glib::ListHandle<Gtk::Widget*> list = cont->get_children ();
Glib::ListHandle<Gtk::Widget*>::iterator i = list.begin ();
for (; i!=list.end() && *i!=w; i++);
for (; i!=list.end() && *i!=w; ++i);
if (i!=list.end()) {
if (increference)
w->reference ();
@@ -212,17 +212,17 @@ void drawCrop (Cairo::RefPtr<Cairo::Context> cr, int imx, int imy, int imw, int
// To have even distribution, normalize it a bit
const int longSideNumLines=10;
int w=rectx2-rectx1, h=recty2-recty1, shortSideNumLines;
int w=rectx2-rectx1, h=recty2-recty1;
if (w>longSideNumLines && h>longSideNumLines) {
if (w>h) {
for (int i=1;i<longSideNumLines;i++) vert_ratios.push_back ((double)i/longSideNumLines);
shortSideNumLines=(int)round(h*(double)longSideNumLines/w);
int shortSideNumLines=(int)round(h*(double)longSideNumLines/w);
for (int i=1;i<shortSideNumLines;i++) horiz_ratios.push_back ((double)i/shortSideNumLines);
} else {
for (int i=1;i<longSideNumLines;i++) horiz_ratios.push_back ((double)i/longSideNumLines);
shortSideNumLines=(int)round(w*(double)longSideNumLines/h);
int shortSideNumLines=(int)round(w*(double)longSideNumLines/h);
for (int i=1;i<shortSideNumLines;i++) vert_ratios.push_back ((double)i/shortSideNumLines);
}
}
@@ -310,7 +310,7 @@ void drawCrop (Cairo::RefPtr<Cairo::Context> cr, int imx, int imy, int imw, int
} else if (cparams.guide=="Golden Triangle 1" || cparams.guide=="Golden Triangle 2") {
// main diagonal
if(cparams.guide=="Golden Triangle 2") {
std:swap(rectx1,rectx2);
std::swap(rectx1,rectx2);
}
cr->set_source_rgba (1.0, 1.0, 1.0, 0.618);
cr->move_to (rectx1, recty1);
@@ -815,13 +815,11 @@ MySpinButton::MySpinButton () {
void MySpinButton::updateSize() {
double vMin, vMax;
double step, page;
int maxAbs;
unsigned int digits, digits2;
unsigned int maxLen;
get_range(vMin, vMax);
get_increments (step, page);
digits = get_digits();
maxAbs = (int)(fmax(fabs(vMin), fabs(vMax))+0.000001);
@@ -837,13 +835,21 @@ void MySpinButton::updateSize() {
}
bool MySpinButton::on_key_press_event (GdkEventKey* event) {
bool rcode = Gtk::Widget::on_key_press_event(event);
double vMin, vMax;
get_range(vMin, vMax);
if ( (event->string[0] >= 'a' && event->string[0] <= 'z')
||(event->string[0] >= 'A' && event->string[0] <= 'Z')
|| event->string[0] == '+'
|| event->string[0] == '+' || (event->string[0] == '-' && vMin >= 0)
|| event->string[0] == '=' || event->string[0] == '_'
)
return false;
return rcode;
return false;
else {
if(event->string[0] == ',') {
event->keyval = GDK_period;
event->string[0] = '.';
}
return Gtk::Widget::on_key_press_event(event);
}
}
bool MySpinButton::on_scroll_event (GdkEventScroll* event) {
@@ -867,6 +873,14 @@ bool MyHScale::on_scroll_event (GdkEventScroll* event) {
return false;
}
bool MyHScale::on_key_press_event (GdkEventKey* event) {
if ( event->string[0] == '+' || event->string[0] == '-' )
return false;
else
return Gtk::Widget::on_key_press_event(event);
}
MyFileChooserButton::MyFileChooserButton (const Glib::ustring& title, Gtk::FileChooserAction action) : Gtk::FileChooserButton(title, action) {
set_size_request(20, -1);
}

View File

@@ -262,6 +262,7 @@ public:
class MyHScale : public Gtk::HScale {
bool on_scroll_event (GdkEventScroll* event);
bool on_key_press_event (GdkEventKey* event);
};
/**