]> source.dussan.org Git - tigervnc.git/commitdiff
Make ServerDialog use standard layout constants
authorPierre Ossman <ossman@cendio.se>
Thu, 16 Jun 2022 11:13:03 +0000 (13:13 +0200)
committerPierre Ossman <ossman@cendio.se>
Thu, 22 Dec 2022 12:36:11 +0000 (13:36 +0100)
Makes it easier to adjust the UI from a central place.

vncviewer/ServerDialog.cxx

index e153d3d398c761969f2ce5fce3ef5577e8613ef2..54c34b4ff50b8cb9c36d2d81f2026d33bcfcc279 100644 (file)
@@ -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);
 }