[haiku-commits] Change in haiku[master]: WIP: Joystick GUI

  • From: Gerrit <review@xxxxxxxxxxxxxxxxxxx>
  • To: waddlesplash <waddlesplash@xxxxxxxxx>, haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 29 Aug 2020 16:05:27 +0000

From Preetpal Kaur <preetpalok123@xxxxxxxxx>:

Preetpal Kaur has uploaded this change for review. ( 
https://review.haiku-os.org/c/haiku/+/3181 ;)


Change subject: WIP: Joystick GUI
......................................................................

WIP: Joystick GUI

Change-Id: I15196a94f4fcfcdb1b3f4a01bc75beb94ea5740a
---
A src/preferences/joystick2/Jamfile
A src/preferences/joystick2/Joystick.cpp
A src/preferences/joystick2/Joystick.h
A src/preferences/joystick2/JoystickView.cpp
A src/preferences/joystick2/JoystickView.h
A src/preferences/joystick2/JoystickWindow.cpp
A src/preferences/joystick2/JoystickWindow.h
7 files changed, 324 insertions(+), 0 deletions(-)



  git pull ssh://git.haiku-os.org:22/haiku refs/changes/81/3181/1

diff --git a/src/preferences/joystick2/Jamfile 
b/src/preferences/joystick2/Jamfile
new file mode 100644
index 0000000..ebcb511
--- /dev/null
+++ b/src/preferences/joystick2/Jamfile
@@ -0,0 +1,17 @@
+SubDir HAIKU_TOP src preferences joystick2 ;
+
+UsePrivateHeaders joystick2 ;
+Preference  Joystick :
+       Joystick.cpp
+       JoystickWindow.cpp
+       JoystickView.cpp
+       : be [ TargetLibsupc++ ] localestub
+       ;
+
+DoCatalogs Joystick :
+       x-vnd.Haiku-Joystick
+       :
+       Joystick.cpp
+       JoystickWindow.cpp
+       JoystickView.cpp
+;
diff --git a/src/preferences/joystick2/Joystick.cpp 
b/src/preferences/joystick2/Joystick.cpp
new file mode 100644
index 0000000..a4f0806
--- /dev/null
+++ b/src/preferences/joystick2/Joystick.cpp
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2020, Haiku, Inc.
+ * Distributed under the terms of the MIT License.
+ *
+ * Author:
+ *             Preetpal Kaur <preetpalok123@xxxxxxxxx>
+ */
+
+
+#include "Joystick.h"
+
+#include <GroupLayout.h>
+#include <GroupLayoutBuilder.h>
+
+#include "JoystickWindow.h"
+
+
+#undef B_TRANSLATION_CONTEXT
+#define B_TRANSLATION_CONTEXT "JoystickApplication"
+
+const char* kSignature = "application/x-vnd.Haiku-Joystick";
+
+
+JoystickApplication::JoystickApplication()
+       :
+       BApplication(kSignature)
+{
+       BRect rect(0, 0, 600, 500);
+       JoystickWindow* window = new JoystickWindow(rect);
+       window->Show();
+}
+
+
+int
+main(int /*argc*/, char** /*argv*/)
+{
+       JoystickApplication app;
+       app.Run();
+
+       return 0;
+}
diff --git a/src/preferences/joystick2/Joystick.h 
b/src/preferences/joystick2/Joystick.h
new file mode 100644
index 0000000..0bd5b38
--- /dev/null
+++ b/src/preferences/joystick2/Joystick.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2020, Haiku, Inc.
+ * Distributed under the terms of the MIT License.
+ *
+ * Author:
+ *             Preetpal Kaur <preetpalok123@xxxxxxxxx>
+ */
+
+
+#ifndef JOYSTICK_H
+#define JOYSTICK_H
+
+
+#include <Application.h>
+#include <Catalog.h>
+#include <Locale.h>
+
+#include "JoystickWindow.h"
+
+
+class JoystickApplication : public BApplication {
+public:
+                               JoystickApplication();
+};
+
+#endif /* JOYSTICK_H */
diff --git a/src/preferences/joystick2/JoystickView.cpp 
b/src/preferences/joystick2/JoystickView.cpp
new file mode 100644
index 0000000..640a477
--- /dev/null
+++ b/src/preferences/joystick2/JoystickView.cpp
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2020, Haiku, Inc.
+ * Distributed under the terms of the MIT License.
+ *
+ * Author:
+ *             Preetpal Kaur <preetpalok123@xxxxxxxxx>
+ */
+
+
+#include "JoystickView.h"
+
+#include <Bitmap.h>
+#include <Box.h>
+#include <Button.h>
+#include <Catalog.h>
+#include <ControlLook.h>
+#include <Debug.h>
+#include <InterfaceDefs.h>
+#include <LayoutBuilder.h>
+#include <Locale.h>
+#include <MenuField.h>
+#include <MenuItem.h>
+#include <PopUpMenu.h>
+#include <SeparatorView.h>
+#include <Slider.h>
+#include <StringView.h>
+#include <TextControl.h>
+#include <TranslationUtils.h>
+#include <Window.h>
+
+const uint32 kLeftInvertX              = 'BLnx';
+const uint32 kLeftInvertY              = 'BLnY';
+const uint32 kRightInvertX             = 'BRnx';
+const uint32 kRightInvertY             = 'BRnY';
+const uint32 kMsgDefaults              = 'BTde';
+const uint32 kMsgRevert                        = 'BTre';
+
+//     #pragma mark -
+
+#undef B_TRANSLATION_CONTEXT
+#define B_TRANSLATION_CONTEXT "JoystickView"
+
+JoystickView::JoystickView()
+       : BBox("main_view")
+{
+       fLeftInvertX = new BRadioButton("multiple",
+               B_TRANSLATE("Invert X"), new BMessage(kLeftInvertX));
+
+       fLeftInvertY = new BRadioButton("multiple",
+               B_TRANSLATE("Invert Y"), new BMessage(kLeftInvertY));
+
+       fRightInvertX = new BRadioButton("multiple",
+               B_TRANSLATE("Invert X"), new BMessage(kRightInvertX));
+
+       fRightInvertY = new BRadioButton("multiple",
+               B_TRANSLATE("Invert Y"), new BMessage(kRightInvertY));
+
+       fDefaultsButton = new BButton(B_TRANSLATE("Defaults"),
+               new BMessage(kMsgDefaults));
+//     fDefaultsButton->SetEnabled(fSettings.IsDefaultable());
+
+       fRevertButton = new BButton(B_TRANSLATE("Revert"),
+               new BMessage(kMsgRevert));
+//     fRevertButton->SetEnabled(false);
+
+       BLayoutBuilder::Group<>(this, B_VERTICAL, B_USE_DEFAULT_SPACING)
+                       .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
+                               .AddGroup(B_VERTICAL, B_USE_DEFAULT_SPACING)
+                                       .Add(new BStringView("Left Stick",
+                                               B_TRANSLATE("Left Stick")))
+                                       .Add(fLeftInvertX)
+                                       .Add(fLeftInvertY)
+                                       .AddGlue()
+                                       .End()
+                               .Add(new BSeparatorView(B_VERTICAL))
+                                       .AddGroup(B_VERTICAL, 
B_USE_DEFAULT_SPACING, 3)
+                                               .Add(new BStringView("Right 
Stick",
+                                                       B_TRANSLATE("Right 
Stick")))
+                                               .Add(fRightInvertX)
+                                               .Add(fRightInvertY)
+                                               .End()
+                                       .End()
+                               .AddStrut(B_USE_DEFAULT_SPACING)
+                               .Add(new BSeparatorView(B_HORIZONTAL))
+                                       .AddGroup(B_HORIZONTAL, 
B_USE_DEFAULT_SPACING, 3)
+                                       .Add(fDefaultsButton)
+                                       .Add(fRevertButton)
+                                       .AddGlue()
+                                       .End()
+                       .End();
+
+       SetBorder(B_NO_BORDER);
+}
+
+
+JoystickView::~JoystickView()
+{
+}
+
+
+
+
diff --git a/src/preferences/joystick2/JoystickView.h 
b/src/preferences/joystick2/JoystickView.h
new file mode 100644
index 0000000..37dd4af
--- /dev/null
+++ b/src/preferences/joystick2/JoystickView.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2020, Haiku, Inc.
+ * Distributed under the terms of the MIT License.
+ *
+ * Author:
+ *             Preetpal Kaur <preetpalok123@xxxxxxxxx>
+*/
+
+
+#ifndef JOYSTICK_VIEW_H
+#define JOYSTICK_VIEW_H
+
+
+#include <Box.h>
+#include <Bitmap.h>
+#include <Button.h>
+#include <CheckBox.h>
+#include <OptionPopUp.h>
+#include <PopUpMenu.h>
+#include <RadioButton.h>
+#include <Slider.h>
+
+
+class JoystickView : public BBox {
+       public:
+                                                       JoystickView();
+               virtual                         ~JoystickView();
+
+       private:
+               typedef BBox            inherited;
+
+               BRadioButton*           fLeftInvertX;
+               BRadioButton*           fLeftInvertY;
+               BRadioButton*           fRightInvertX;
+               BRadioButton*           fRightInvertY;
+               BButton*                        fDefaultsButton;
+               BButton*                        fRevertButton;
+};
+
+#endif /* JOYSTICK_VIEW_H */
diff --git a/src/preferences/joystick2/JoystickWindow.cpp 
b/src/preferences/joystick2/JoystickWindow.cpp
new file mode 100644
index 0000000..ecfb36d
--- /dev/null
+++ b/src/preferences/joystick2/JoystickWindow.cpp
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2020, Haiku, Inc.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ *             Preetpal Kaur <preetpalok123@xxxxxxxxx>
+ */
+
+#include "JoystickWindow.h"
+
+#include <Alert.h>
+#include <Alignment.h>
+#include <Application.h>
+#include <Button.h>
+#include <CardLayout.h>
+#include <CardView.h>
+#include <Catalog.h>
+#include <Control.h>
+#include <ControlLook.h>
+#include <LayoutBuilder.h>
+#include <SplitView.h>
+#include <Screen.h>
+
+#include "JoystickView.h"
+
+
+#undef B_TRANSLATION_CONTEXT
+#define B_TRANSLATION_CONTEXT "JoystickWindow"
+
+
+JoystickWindow::JoystickWindow(BRect rect)
+       :
+       BWindow(rect, B_TRANSLATE_SYSTEM_NAME("Joystick"), B_TITLED_WINDOW,
+               B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS
+               | B_AUTO_UPDATE_SIZE_LIMITS | B_QUIT_ON_WINDOW_CLOSE)
+{
+       fJoystickView = new JoystickView();
+
+       BLayoutBuilder::Group<>(this, B_HORIZONTAL, 10)
+               .SetInsets(B_USE_WINDOW_SPACING)
+               .Add(fJoystickView)
+               .End();
+}
+
+void
+JoystickWindow::Show()
+{
+       CenterOnScreen();
+       BWindow::Show();
+}
+
+
+void
+JoystickWindow::Hide()
+{
+       BWindow::Hide();
+}
+
diff --git a/src/preferences/joystick2/JoystickWindow.h 
b/src/preferences/joystick2/JoystickWindow.h
new file mode 100644
index 0000000..b1afe89
--- /dev/null
+++ b/src/preferences/joystick2/JoystickWindow.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2020, Haiku, Inc.
+ * Distributed under the terms of the MIT License.
+ *
+ * Author:
+ *             Preetpal Kaur <preetpalok123@xxxxxxxxx>
+ */
+
+
+#ifndef JOYSTICK_WINDOW_H
+#define JOYSTICK_WINDOW_H
+
+
+#include <Box.h>
+#include <CardView.h>
+#include <Input.h>
+#include <ListItem.h>
+#include <ListView.h>
+#include <Message.h>
+#include <ScrollBar.h>
+#include <ScrollView.h>
+#include <SeparatorView.h>
+#include <View.h>
+#include <Window.h>
+
+#include "JoystickView.h"
+
+
+class JoystickWindow : public BWindow
+{
+public:
+                                               JoystickWindow(BRect rect);
+               void                            Show();
+               void                            Hide();
+
+private:
+               JoystickView*   fJoystickView;
+};
+
+#endif /* JOYSTICK_WINDOW_H */

--
To view, visit https://review.haiku-os.org/c/haiku/+/3181
To unsubscribe, or for help writing mail filters, visit 
https://review.haiku-os.org/settings

Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: I15196a94f4fcfcdb1b3f4a01bc75beb94ea5740a
Gerrit-Change-Number: 3181
Gerrit-PatchSet: 1
Gerrit-Owner: Preetpal Kaur <preetpalok123@xxxxxxxxx>
Gerrit-MessageType: newchange

Other related posts:

  • » [haiku-commits] Change in haiku[master]: WIP: Joystick GUI - Gerrit