[haiku-commits] haiku: hrev49613 - src/kits/interface src/apps/terminal headers/os/interface

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 3 Sep 2015 21:32:01 +0200 (CEST)

hrev49613 adds 4 changesets to branch 'master'
old head: 9a1b63b19f445ef9f09b5a0dd1f69e41c26a7454
new head: fa89878a70f7795615f55d16c7669f0a4c71b402
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=fa89878a70f7+%5E9a1b63b19f44

----------------------------------------------------------------------------

b7d012007427: Terminal: Added "Save as defaults" back.

* It's still convenient to have.
* Furthermore, the distinction between when settings are stored is hard
to grasp otherwise.
* Plus, adopting the current window size is now much more straight forward.

ebf4cbe6e75f: Incredibly smart BWindow::MoveOnScreen() method added.

* Makes sure that the window is as complete as possible on screen.

52e43a20be44: Terminal: replaced positioning with BWindow::MoveOnScreen().

* The previous mechanism was pretty crude, and didn't work that well.

fa89878a70f7: Terminal: renamed some variables for clarity.

* Unless they really have no meaning beyond serving as an index, you
should avoid naming your variables just i, j, k, l.

[ Axel Dörfler <axeld@xxxxxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

4 files changed, 69 insertions(+), 15 deletions(-)
headers/os/interface/Window.h | 3 ++-
src/apps/terminal/TermConst.h | 3 ++-
src/apps/terminal/TermWindow.cpp | 35 +++++++++++++++++++----------
src/kits/interface/Window.cpp | 43 +++++++++++++++++++++++++++++++++++-

############################################################################

Commit: b7d012007427f3f0cc0881275cf5bcf7b198fb32
URL: http://cgit.haiku-os.org/haiku/commit/?id=b7d012007427
Author: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date: Thu Sep 3 17:23:23 2015 UTC

Terminal: Added "Save as defaults" back.

* It's still convenient to have.
* Furthermore, the distinction between when settings are stored is hard
to grasp otherwise.
* Plus, adopting the current window size is now much more straight forward.

----------------------------------------------------------------------------

diff --git a/src/apps/terminal/TermConst.h b/src/apps/terminal/TermConst.h
index ef7d704..f1d965f 100644
--- a/src/apps/terminal/TermConst.h
+++ b/src/apps/terminal/TermConst.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2013, Haiku.
+ * Copyright 2001-2015, Haiku.
* Copyright (c) 2003-4 Kian Duffy <myob@xxxxxxxxxxxxxxxxxxxxx>
* Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
*
@@ -71,6 +71,7 @@ static const uint32 ONETHREETWOTWENTYFIVE
= 'hunv';
static const uint32 FULLSCREEN
= 'fscr';

static const uint32 MSG_FONT_CHANGED =
'fntc';
+static const uint32 MSG_SAVE_AS_DEFAULT
= 'sadf';
static const uint32 MSG_CHECK_CHILDREN =
'ckch';
static const uint32 MSG_REMOVE_RESIZE_VIEW_IF_NEEDED = 'rmrv';
static const uint32 MSG_TERMINAL_BUFFER_CHANGED =
'bufc';
diff --git a/src/apps/terminal/TermWindow.cpp b/src/apps/terminal/TermWindow.cpp
index 88762c7..8519082 100644
--- a/src/apps/terminal/TermWindow.cpp
+++ b/src/apps/terminal/TermWindow.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2007-2013, Haiku, Inc. All rights reserved.
+ * Copyright 2007-2015, Haiku, Inc. All rights reserved.
* Copyright (c) 2004 Daniel Furrer <assimil8or@xxxxxxxxxxxxxxxxxxxxx>
* Copyright (c) 2003-2004 Kian Duffy <myob@xxxxxxxxxxxxxxxxxxxxx>
* Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
@@ -523,10 +523,10 @@ TermWindow::_SetupMenu()
.AddItem(windowSize)
.AddItem(fEncodingMenu)
.AddItem(fFontSizeMenu)
+ .AddItem(B_TRANSLATE("Save as default"),
MSG_SAVE_AS_DEFAULT)
.AddSeparator()
.AddItem(B_TRANSLATE("Settings" B_UTF8_ELLIPSIS),
MENU_PREF_OPEN)
- .End()
- ;
+ .End();

AddChild(fMenuBar);

@@ -935,6 +935,15 @@ TermWindow::MessageReceived(BMessage *message)
_ActiveTermView()->Invalidate();
break;
}
+ case MSG_SAVE_AS_DEFAULT:
+ {
+ BPath path;
+ if (PrefHandler::GetDefaultPath(path) == B_OK) {
+ PrefHandler::Default()->SaveAsText(path.Path(),
+ PREFFILE_MIMETYPE);
+ }
+ break;
+ }

case MENU_PAGE_SETUP:
_DoPageSetup();

############################################################################

Commit: ebf4cbe6e75f7317ff9be2371212eec0c94f7b4a
URL: http://cgit.haiku-os.org/haiku/commit/?id=ebf4cbe6e75f
Author: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date: Thu Sep 3 17:33:07 2015 UTC

Incredibly smart BWindow::MoveOnScreen() method added.

* Makes sure that the window is as complete as possible on screen.

----------------------------------------------------------------------------

diff --git a/headers/os/interface/Window.h b/headers/os/interface/Window.h
index dbf0431..37fbf88 100644
--- a/headers/os/interface/Window.h
+++ b/headers/os/interface/Window.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2011, Haiku, Inc. All rights reserved.
+ * Copyright 2001-2015, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _WINDOW_H
@@ -170,6 +170,7 @@ public:
void CenterIn(const BRect&
rect);
void CenterOnScreen();
void
CenterOnScreen(screen_id id);
+ void MoveOnScreen();

virtual void Show();
virtual void Hide();
diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp
index 141e489..70cc845 100644
--- a/src/kits/interface/Window.cpp
+++ b/src/kits/interface/Window.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2014 Haiku, Inc. All rights reserved
+ * Copyright 2001-2015 Haiku, Inc. All rights reserved
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -2569,6 +2569,47 @@ BWindow::CenterOnScreen(screen_id id)


void
+BWindow::MoveOnScreen()
+{
+ // Set size limits now if needed
+ UpdateSizeLimits();
+
+ BRect screenFrame = BScreen(this).Frame();
+ BRect frame = Frame();
+
+ float borderWidth;
+ float tabHeight;
+ _GetDecoratorSize(&borderWidth, &tabHeight);
+
+ frame.InsetBy(-borderWidth, -borderWidth);
+ frame.top -= tabHeight;
+
+ if (!frame.Intersects(screenFrame)) {
+ // Off and away
+ CenterOnScreen();
+ return;
+ }
+
+ // Move such that the upper left corner, and most of the window
+ // will be visible.
+ float left = frame.left;
+ if (left < screenFrame.left)
+ left = screenFrame.left;
+ else if (frame.right > screenFrame.right)
+ left = std::max(0.f, screenFrame.right - frame.Width());
+
+ float top = frame.top;
+ if (top < screenFrame.top)
+ top = screenFrame.top;
+ else if (frame.bottom > screenFrame.bottom)
+ top = std::max(0.f, screenFrame.bottom - frame.Height());
+
+ if (top != frame.top || left != frame.left)
+ MoveTo(left + borderWidth, top + tabHeight + borderWidth);
+}
+
+
+void
BWindow::Show()
{
bool runCalled = true;

############################################################################

Commit: 52e43a20be446f7dffbb41eedd87d6b9a8ce00cd
URL: http://cgit.haiku-os.org/haiku/commit/?id=52e43a20be44
Author: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date: Thu Sep 3 17:36:44 2015 UTC

Terminal: replaced positioning with BWindow::MoveOnScreen().

* The previous mechanism was pretty crude, and didn't work that well.

----------------------------------------------------------------------------

diff --git a/src/apps/terminal/TermWindow.cpp b/src/apps/terminal/TermWindow.cpp
index 8519082..4b1ce3b 100644
--- a/src/apps/terminal/TermWindow.cpp
+++ b/src/apps/terminal/TermWindow.cpp
@@ -225,11 +225,13 @@ TermWindow::TermWindow(const BString& title, Arguments*
args)
if (_LoadWindowPosition(&frame, &workspaces) == B_OK) {
// make sure the window is still on screen
// (for example if there was a resolution change)
- if (frame.Intersects(BScreen(this).Frame())) {
- MoveTo(frame.LeftTop());
+ BRect screenFrame = BScreen(this).Frame();
+ if (frame.Width() <= screenFrame.Width()
+ && frame.Height() <= screenFrame.Height())
ResizeTo(frame.Width(), frame.Height());
- } else
- CenterOnScreen();
+
+ MoveTo(frame.LeftTop());
+ MoveOnScreen();

SetWorkspaces(workspaces);
} else {

############################################################################

Revision: hrev49613
Commit: fa89878a70f7795615f55d16c7669f0a4c71b402
URL: http://cgit.haiku-os.org/haiku/commit/?id=fa89878a70f7
Author: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date: Thu Sep 3 18:01:26 2015 UTC

Terminal: renamed some variables for clarity.

* Unless they really have no meaning beyond serving as an index, you
should avoid naming your variables just i, j, k, l.

----------------------------------------------------------------------------

diff --git a/src/apps/terminal/TermWindow.cpp b/src/apps/terminal/TermWindow.cpp
index 4b1ce3b..7151367 100644
--- a/src/apps/terminal/TermWindow.cpp
+++ b/src/apps/terminal/TermWindow.cpp
@@ -236,12 +236,12 @@ TermWindow::TermWindow(const BString& title, Arguments*
args)
SetWorkspaces(workspaces);
} else {
// use computed defaults
- int i = id / 16;
- int j = id % 16;
- int k = (j * 16) + (i * 64) + 50;
- int l = (j * 16) + 50;
+ int row = id / 16;
+ int column = id % 16;
+ int x = (column * 16) + (row * 64) + 50;
+ int y = (column * 16) + 50;

- MoveTo(k, l);
+ MoveTo(x, y);
}

// init the GUI and add a tab


Other related posts:

  • » [haiku-commits] haiku: hrev49613 - src/kits/interface src/apps/terminal headers/os/interface - axeld