From 547c761b2dc26e4ad5f500b5cef9e8a71acd168b Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 16 Jun 2022 13:13:03 +0200 Subject: [PATCH] Make ServerDialog use standard layout constants Makes it easier to adjust the UI from a central place. --- vncviewer/ServerDialog.cxx | 70 +++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/vncviewer/ServerDialog.cxx b/vncviewer/ServerDialog.cxx index e153d3d3..54c34b4f 100644 --- a/vncviewer/ServerDialog.cxx +++ b/vncviewer/ServerDialog.cxx @@ -55,63 +55,63 @@ static LogWriter vlog("ServerDialog"); const char* SERVER_HISTORY="tigervnc.history"; ServerDialog::ServerDialog() - : Fl_Window(450, 160, _("VNC Viewer: Connection Details")) + : Fl_Window(450, 0, _("VNC Viewer: Connection Details")) { - int x, y; + int x, y, x2; Fl_Button *button; Fl_Box *divider; - int margin = 20; - int server_label_width = gui_str_len(_("VNC server:")); - - x = margin + server_label_width; - y = margin; - - serverName = new Fl_Input_Choice(x, y, w() - margin*2 - server_label_width, INPUT_HEIGHT, _("VNC server:")); usedDir = NULL; - int adjust = (w() - 20) / 4; - int button_width = adjust - margin/2; + x = OUTER_MARGIN; + y = OUTER_MARGIN; - x = margin; - y = margin + margin/2 + INPUT_HEIGHT; + serverName = new Fl_Input_Choice(LBLLEFT(x, y, w() - OUTER_MARGIN*2, + INPUT_HEIGHT, _("VNC server:"))); + y += INPUT_HEIGHT + INNER_MARGIN; - y += margin/2; + x2 = x; - button = new Fl_Button(x, y, button_width, BUTTON_HEIGHT, _("Options...")); + button = new Fl_Button(x2, y, BUTTON_WIDTH, BUTTON_HEIGHT, _("Options...")); button->callback(this->handleOptions, this); - - x += adjust; - - button = new Fl_Button(x, y, button_width, BUTTON_HEIGHT, _("Load...")); - button->callback(this->handleLoad, this); + x2 += BUTTON_WIDTH + INNER_MARGIN; - x += adjust; + button = new Fl_Button(x2, y, BUTTON_WIDTH, BUTTON_HEIGHT, _("Load...")); + button->callback(this->handleLoad, this); + x2 += BUTTON_WIDTH + INNER_MARGIN; - button = new Fl_Button(x, y, button_width, BUTTON_HEIGHT, _("Save As...")); + button = new Fl_Button(x2, y, BUTTON_WIDTH, BUTTON_HEIGHT, _("Save As...")); button->callback(this->handleSaveAs, this); - - x = 0; - y += margin/2 + BUTTON_HEIGHT; + x2 += BUTTON_WIDTH + INNER_MARGIN; - divider = new Fl_Box(x, y, w(), 2); + y += BUTTON_HEIGHT + INNER_MARGIN; + + divider = new Fl_Box(0, y, w(), 2); divider->box(FL_THIN_DOWN_FRAME); - - x += margin; - y += margin/2; - button = new Fl_Button(x, y, button_width, BUTTON_HEIGHT, _("About...")); + y += divider->h() + INNER_MARGIN; + + // Symmetric margin around bottom button bar + y += OUTER_MARGIN - INNER_MARGIN; + + button = new Fl_Button(x, y, BUTTON_WIDTH, BUTTON_HEIGHT, _("About...")); button->callback(this->handleAbout, this); - x = w() - margin - adjust - button_width - 20; + x2 = w() - OUTER_MARGIN - BUTTON_WIDTH*2 - INNER_MARGIN*1; - button = new Fl_Button(x, y, button_width, BUTTON_HEIGHT, _("Cancel")); + button = new Fl_Button(x2, y, BUTTON_WIDTH, BUTTON_HEIGHT, _("Cancel")); button->callback(this->handleCancel, this); + x2 += BUTTON_WIDTH + INNER_MARGIN; - x += adjust; - - button = new Fl_Return_Button(x, y, button_width+20, BUTTON_HEIGHT, _("Connect")); + button = new Fl_Return_Button(x2, y, BUTTON_WIDTH, BUTTON_HEIGHT, _("Connect")); button->callback(this->handleConnect, this); + x2 += BUTTON_WIDTH + INNER_MARGIN; + + y += BUTTON_HEIGHT + INNER_MARGIN; + + /* Needed for resize to work sanely */ + resizable(NULL); + h(y-INNER_MARGIN+OUTER_MARGIN); callback(this->handleCancel, this); } -- 2.39.5