[haiku-commits] haiku: hrev46251 - src/kits/shared src/kits/tracker src/apps/webpositive headers/private/shared

  • From: jscipione@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 18 Oct 2013 09:23:04 +0200 (CEST)

hrev46251 adds 4 changesets to branch 'master'
old head: 2809b77fc6b2ce5407d5dd9989e4c3ed9b7acb6b
new head: 959a0ca10dd06b205f13b51040f03da3ae4c5e75
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=959a0ca+%5E2809b77

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

000e7d4: Tracker: Add zoom shortcuts to menuless windows
  
  (for instance the desktop)

1d04310: Keymap: Add a method to get modified characters for a key
  
  This method fills out the passed-in BList of modified utf-8 characters for
  a given utf-8 character and set of modifiers.
  
  For example if you pass in "=" and B_SHIFT_KEY the list will get filled
  out with each character in the shift map that has "=" in the normal map.
  
  Each supported keymap modifier combination is available.
  
  The reason this is useful will soon become apparent.
  
  A BList is used because the character might be mapped multiple times,
  for example if you have a Mac keyboard you've got two "=" keys, one in
  0x1d and one in 0x6a.
  
  The caller is responsible for creating the BList and destroying it as well as
  freeing the resulting character strings.

57f830c: Tracker: Add semantic zoom in shortcut.
  
  Fixes #6692
  
  iif '+' is localed in shift + '=' in your keymap, add a shortcut for
  Command + '=' to zoom in.

959a0ca: WebPositive: Add semantic zoom in shortcut.
  
  Fixes #7428
  
  iif '+' is localed in shift + '=' in your keymap, add a shortcut for
  Command + '=' to zoom in.

                                     [ John Scipione <jscipione@xxxxxxxxx> ]

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

4 files changed, 110 insertions(+), 3 deletions(-)
headers/private/shared/Keymap.h        |  5 +++
src/apps/webpositive/BrowserWindow.cpp | 23 +++++++++++--
src/kits/shared/Keymap.cpp             | 55 ++++++++++++++++++++++++++++++
src/kits/tracker/ContainerWindow.cpp   | 30 +++++++++++++++-

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

Commit:      000e7d408880f298fea192cefa46526965245165
URL:         http://cgit.haiku-os.org/haiku/commit/?id=000e7d4
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Fri Oct 18 06:49:30 2013 UTC

Tracker: Add zoom shortcuts to menuless windows

(for instance the desktop)

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

diff --git a/src/kits/tracker/ContainerWindow.cpp 
b/src/kits/tracker/ContainerWindow.cpp
index 3be7a68..33b4474 100644
--- a/src/kits/tracker/ContainerWindow.cpp
+++ b/src/kits/tracker/ContainerWindow.cpp
@@ -2108,6 +2108,14 @@ BContainerWindow::AddShortcuts()
                new BMessage(kOpenParentDir), PoseView());
        AddShortcut('O', B_COMMAND_KEY | B_CONTROL_KEY,
                new BMessage(kOpenSelectionWith), PoseView());
+
+       BMessage* decreaseSize = new BMessage(kIconMode);
+       decreaseSize->AddInt32("scale", 0);
+       AddShortcut('-', B_COMMAND_KEY, decreaseSize, PoseView());
+
+       BMessage* increaseSize = new BMessage(kIconMode);
+       increaseSize->AddInt32("scale", 1);
+       AddShortcut('+', B_COMMAND_KEY, increaseSize, PoseView());
 }
 
 

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

Commit:      1d043104595fbf5f7e6068e749981bd3913b4369
URL:         http://cgit.haiku-os.org/haiku/commit/?id=1d04310
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Fri Oct 18 07:01:53 2013 UTC

Keymap: Add a method to get modified characters for a key

This method fills out the passed-in BList of modified utf-8 characters for
a given utf-8 character and set of modifiers.

For example if you pass in "=" and B_SHIFT_KEY the list will get filled
out with each character in the shift map that has "=" in the normal map.

Each supported keymap modifier combination is available.

The reason this is useful will soon become apparent.

A BList is used because the character might be mapped multiple times,
for example if you have a Mac keyboard you've got two "=" keys, one in
0x1d and one in 0x6a.

The caller is responsible for creating the BList and destroying it as well as
freeing the resulting character strings.

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

diff --git a/headers/private/shared/Keymap.h b/headers/private/shared/Keymap.h
index 8b95913..37d9060 100644
--- a/headers/private/shared/Keymap.h
+++ b/headers/private/shared/Keymap.h
@@ -14,6 +14,8 @@
 #include <InterfaceDefs.h>
 
 
+class BList;
+
 class BKeymap {
 public:
                                                                BKeymap();
@@ -38,6 +40,9 @@ public:
                        void                            GetChars(uint32 
keyCode, uint32 modifiers,
                                                                        uint8 
activeDeadKey, char** chars,
                                                                        int32* 
numBytes) const;
+                       status_t                        
GetModifiedCharacters(const char* normal,
+                                                                       int32 
modifiers,
+                                                                       BList* 
_modifiedCharacters);
 
                        const key_map&          Map() const { return fKeys; }
 
diff --git a/src/kits/shared/Keymap.cpp b/src/kits/shared/Keymap.cpp
index 9ffe977..1aab46b 100644
--- a/src/kits/shared/Keymap.cpp
+++ b/src/kits/shared/Keymap.cpp
@@ -19,6 +19,7 @@
 
 #include <ByteOrder.h>
 #include <File.h>
+#include <List.h>
 
 #ifdef HAIKU_TARGET_PLATFORM_HAIKU
 #      include "SystemKeymap.h"
@@ -441,6 +442,60 @@ BKeymap::GetChars(uint32 keyCode, uint32 modifiers, uint8 
activeDeadKey,
 }
 
 
+status_t
+BKeymap::GetModifiedCharacters(const char* normal, int32 modifiers,
+       BList* _modifiedCharacters)
+{
+       if (normal == NULL || strcmp(normal, "") == 0
+               || _modifiedCharacters == NULL) {
+               return B_BAD_VALUE;
+       }
+
+       int32 normalOffset;
+       int32 modifiedOffset;
+
+       for(uint32 i = 0; i < 128; i++) {
+               normalOffset = fKeys.normal_map[i];
+               size_t sizeNormal = fChars[normalOffset++];
+               if (sizeNormal == 0
+                       || memcmp(normal, fChars + normalOffset, sizeNormal) != 
0) {
+                       // this character isn't mapped or doesn't match
+                       continue;
+               }
+
+               if (modifiers == B_SHIFT_KEY)
+                       modifiedOffset = fKeys.shift_map[i];
+               else if (modifiers == B_CONTROL_KEY)
+                       modifiedOffset = fKeys.control_map[i];
+               else if (modifiers == B_OPTION_KEY)
+                       modifiedOffset = fKeys.option_map[i];
+               else if (modifiers == (B_OPTION_KEY | B_SHIFT_KEY))
+                       modifiedOffset = fKeys.option_shift_map[i];
+               else if (modifiers == B_CAPS_LOCK)
+                       modifiedOffset = fKeys.caps_map[i];
+               else if (modifiers == (B_CAPS_LOCK | B_SHIFT_KEY))
+                       modifiedOffset = fKeys.caps_shift_map[i];
+               else if (modifiers == (B_OPTION_KEY | B_CAPS_LOCK))
+                       modifiedOffset = fKeys.option_caps_map[i];
+               else if (modifiers == (B_OPTION_KEY | B_CAPS_LOCK | 
B_SHIFT_KEY))
+                       modifiedOffset = fKeys.option_caps_shift_map[i];
+               else
+                       return B_BAD_VALUE;
+
+               size_t sizeModified = fChars[modifiedOffset++];
+               char* modified = (char*)malloc(sizeModified + 1);
+               if (modified == NULL)
+                       return B_NO_MEMORY;
+
+               memcpy(modified, fChars + modifiedOffset, sizeModified);
+               modified[sizeModified] = '\0';
+               _modifiedCharacters->AddItem(modified);
+       }
+
+       return B_OK;
+}
+
+
 bool
 BKeymap::operator==(const BKeymap& other) const
 {

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

Commit:      57f830cef752330a920b3fe3f5fe4367921f51ce
URL:         http://cgit.haiku-os.org/haiku/commit/?id=57f830c
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Fri Oct 18 07:08:07 2013 UTC

Ticket:      https://dev.haiku-os.org/ticket/6692

Tracker: Add semantic zoom in shortcut.

Fixes #6692

iif '+' is localed in shift + '=' in your keymap, add a shortcut for
Command + '=' to zoom in.

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

diff --git a/src/kits/tracker/ContainerWindow.cpp 
b/src/kits/tracker/ContainerWindow.cpp
index 33b4474..d18eef7 100644
--- a/src/kits/tracker/ContainerWindow.cpp
+++ b/src/kits/tracker/ContainerWindow.cpp
@@ -45,7 +45,7 @@ All rights reserved.
 #include <Directory.h>
 #include <Entry.h>
 #include <FindDirectory.h>
-#include <InterfaceDefs.h>
+#include <Keymap.h>
 #include <Locale.h>
 #include <MenuItem.h>
 #include <MenuBar.h>
@@ -937,6 +937,26 @@ BContainerWindow::Init(const BMessage* message)
                AddShortcuts();
        }
 
+       BKeymap keymap;
+       keymap.SetToCurrent();
+       BList shiftChars;
+       if (keymap.GetModifiedCharacters("=", B_SHIFT_KEY, &shiftChars)
+                       == B_OK) {
+               int32 count = shiftChars.CountItems();
+               for (int32 i = 0; i < count; i++) {
+                       if (strcmp((const char*)shiftChars.ItemAt(i), "+") == 
0) {
+                               // Add semantic zoom in shortcut, bug #6692
+                               BMessage* increaseSize = new 
BMessage(kIconMode);
+                               increaseSize->AddInt32("scale", 1);
+                               AddShortcut('=', B_COMMAND_KEY, increaseSize, 
PoseView());
+                               break;
+                       }
+               }
+       }
+       while (!shiftChars.IsEmpty())
+               delete (const char*)shiftChars.RemoveItem((int32)0);
+       shiftChars.MakeEmpty();
+
        AddContextMenus();
        AddShortcut('T', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(kDelete),
                PoseView());

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

Revision:    hrev46251
Commit:      959a0ca10dd06b205f13b51040f03da3ae4c5e75
URL:         http://cgit.haiku-os.org/haiku/commit/?id=959a0ca
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Fri Oct 18 07:09:08 2013 UTC

Ticket:      https://dev.haiku-os.org/ticket/7428

WebPositive: Add semantic zoom in shortcut.

Fixes #7428

iif '+' is localed in shift + '=' in your keymap, add a shortcut for
Command + '=' to zoom in.

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

diff --git a/src/apps/webpositive/BrowserWindow.cpp 
b/src/apps/webpositive/BrowserWindow.cpp
index bd61ff5..fa5b2b8 100644
--- a/src/apps/webpositive/BrowserWindow.cpp
+++ b/src/apps/webpositive/BrowserWindow.cpp
@@ -5,8 +5,7 @@
  * Copyright (C) 2010 Stephan Aßmus <superstippi@xxxxxx>
  * Copyright (C) 2010 Michael Lotz <mmlr@xxxxxxxx>
  * Copyright (C) 2010 Rene Gollent <rene@xxxxxxxxxxx>
- *
- * All rights reserved.
+ * Copyright 2013 Haiku, Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -48,6 +47,7 @@
 #include <GridLayoutBuilder.h>
 #include <GroupLayout.h>
 #include <GroupLayoutBuilder.h>
+#include <Keymap.h>
 #include <LayoutBuilder.h>
 #include <Locale.h>
 #include <MenuBar.h>
@@ -610,6 +610,25 @@ BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* 
appSettings,
                AddShortcut(numStr[0], B_COMMAND_KEY, selectTab);
        }
 
+       BKeymap keymap;
+       keymap.SetToCurrent();
+       BList shiftChars;
+       if (keymap.GetModifiedCharacters("=", B_SHIFT_KEY, &shiftChars)
+                       == B_OK) {
+               int32 count = shiftChars.CountItems();
+               for (int32 i = 0; i < count; i++) {
+                       if (strcmp((const char*)shiftChars.ItemAt(i), "+") == 
0) {
+                               // Add semantic zoom in shortcut, bug #7428
+                               AddShortcut('=', B_COMMAND_KEY,
+                                       new BMessage(ZOOM_FACTOR_INCREASE));
+                               break;
+                       }
+               }
+       }
+       while (!shiftChars.IsEmpty())
+               delete (const char*)shiftChars.RemoveItem((int32)0);
+       shiftChars.MakeEmpty();
+
        be_app->PostMessage(WINDOW_OPENED);
 }
 


Other related posts: