aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorametovic <ametovic@svn>2010-03-23 07:38:50 +0000
committerametovic <ametovic@svn>2010-03-23 07:38:50 +0000
commitf65a9a26ab48b204cfe1081e9a570f263171e658 (patch)
treeb1717697a2353ff262059c0360f468f768ddb122
parent7ab54c2aae2a3dd4479a56f047702b613ecfbd1c (diff)
added ability for slider to return the percentage value to the scripts
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@28765 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
-rw-r--r--XBMC.xcodeproj/project.pbxproj6
-rw-r--r--project/VS2008Express/XBMC.vcproj4
-rw-r--r--xbmc/lib/libPython/xbmcmodule/Makefile2
-rw-r--r--xbmc/lib/libPython/xbmcmodule/control.h13
-rw-r--r--xbmc/lib/libPython/xbmcmodule/controlslider.cpp186
-rw-r--r--xbmc/lib/libPython/xbmcmodule/window.cpp10
-rw-r--r--xbmc/lib/libPython/xbmcmodule/xbmcguimodule.cpp4
7 files changed, 224 insertions, 1 deletions
diff --git a/XBMC.xcodeproj/project.pbxproj b/XBMC.xcodeproj/project.pbxproj
index a958fbb856..227e475a3f 100644
--- a/XBMC.xcodeproj/project.pbxproj
+++ b/XBMC.xcodeproj/project.pbxproj
@@ -281,6 +281,8 @@
88ECB6E70DE07BA6003396A7 /* libfontconfig.1.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 88ECB6E60DE07BA6003396A7 /* libfontconfig.1.dylib */; };
88ECB6EA0DE07BEE003396A7 /* libogg.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 88ECB6E90DE07BEE003396A7 /* libogg.0.dylib */; };
8DD76F790486A8DE00D96B5E /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 09AB6884FE841BABC02AAC07 /* CoreFoundation.framework */; };
+ C80425711158A0DE00D158A6 /* controlslider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C80425701158A0DE00D158A6 /* controlslider.cpp */; };
+ C80425721158A0DE00D158A6 /* controlslider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C80425701158A0DE00D158A6 /* controlslider.cpp */; };
E306D12E0DDF7B590052C2AD /* XBMCHelper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E306D12C0DDF7B590052C2AD /* XBMCHelper.cpp */; };
E33206380D5070AA00435CE3 /* DVDDemuxVobsub.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E33206370D5070AA00435CE3 /* DVDDemuxVobsub.cpp */; };
E33466A60D2E5103005A65EC /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E33466A50D2E5103005A65EC /* IOKit.framework */; };
@@ -2187,6 +2189,7 @@
88ECB6E60DE07BA6003396A7 /* libfontconfig.1.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libfontconfig.1.dylib; path = /opt/local/lib/libfontconfig.1.dylib; sourceTree = "<absolute>"; };
88ECB6E90DE07BEE003396A7 /* libogg.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libogg.0.dylib; path = /opt/local/lib/libogg.0.dylib; sourceTree = "<absolute>"; };
8DD76F7E0486A8DE00D96B5E /* XBMC */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = XBMC; sourceTree = BUILT_PRODUCTS_DIR; };
+ C80425701158A0DE00D158A6 /* controlslider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = controlslider.cpp; sourceTree = "<group>"; };
E306D12C0DDF7B590052C2AD /* XBMCHelper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XBMCHelper.cpp; sourceTree = "<group>"; };
E306D12D0DDF7B590052C2AD /* XBMCHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XBMCHelper.h; sourceTree = "<group>"; };
E30B3E8E0D5D59290030A311 /* libshout-x86-osx.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libshout-x86-osx.a"; path = "xbmc/lib/libshout/libshout-x86-osx.a"; sourceTree = "<group>"; };
@@ -5838,6 +5841,7 @@
E38E19DA0D25F9FB00618676 /* xbmcmodule */ = {
isa = PBXGroup;
children = (
+ C80425701158A0DE00D158A6 /* controlslider.cpp */,
E354EF030D99EDC900B55311 /* controlradiobutton.cpp */,
E38E257E0D263CE000618676 /* action.cpp */,
E38E19DC0D25F9FB00618676 /* action.h */,
@@ -8130,6 +8134,7 @@
18B4A0061152BFA5001AF8A6 /* ScreenSaver.cpp in Sources */,
18B4A0071152BFA5001AF8A6 /* Visualisation.cpp in Sources */,
7C8A14571154CB2600E5FCFA /* TextureCache.cpp in Sources */,
+ C80425711158A0DE00D158A6 /* controlslider.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -8992,6 +8997,7 @@
18B4A00C1152BFA5001AF8A6 /* ScreenSaver.cpp in Sources */,
18B4A00D1152BFA5001AF8A6 /* Visualisation.cpp in Sources */,
7C8A14561154CB2600E5FCFA /* TextureCache.cpp in Sources */,
+ C80425721158A0DE00D158A6 /* controlslider.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/project/VS2008Express/XBMC.vcproj b/project/VS2008Express/XBMC.vcproj
index adae96b3ea..f41602eda3 100644
--- a/project/VS2008Express/XBMC.vcproj
+++ b/project/VS2008Express/XBMC.vcproj
@@ -6153,6 +6153,10 @@
>
</File>
<File
+ RelativePath="..\..\xbmc\lib\libPython\xbmcmodule\controlslider.cpp"
+ >
+ </File>
+ <File
RelativePath="..\..\xbmc\lib\libPython\xbmcmodule\controlradiobutton.cpp"
>
</File>
diff --git a/xbmc/lib/libPython/xbmcmodule/Makefile b/xbmc/lib/libPython/xbmcmodule/Makefile
index 989ef1c967..343b5be3ec 100644
--- a/xbmc/lib/libPython/xbmcmodule/Makefile
+++ b/xbmc/lib/libPython/xbmcmodule/Makefile
@@ -1,6 +1,6 @@
INCLUDES=-I../../../.. -I. -I../../../ -I../../../linux -I../../../../guilib -I../../../utils -I../../../cores
-SRCS=action.cpp controlbutton.cpp controlcheckmark.cpp control.cpp controlfadelabel.cpp controlimage.cpp controllabel.cpp controllist.cpp controlprogress.cpp controlspin.cpp controltextbox.cpp dialog.cpp GUIPythonWindow.cpp GUIPythonWindowDialog.cpp GUIPythonWindowXML.cpp GUIPythonWindowXMLDialog.cpp infotagmusic.cpp infotagvideo.cpp keyboard.cpp listitem.cpp player.cpp pyplaylist.cpp PythonPlayer.cpp pyutil.cpp window.cpp winxml.cpp winxmldialog.cpp xbmcguimodule.cpp xbmcmodule.cpp controlgroup.cpp xbmcplugin.cpp controlradiobutton.cpp language.cpp PythonSettings.cpp
+SRCS=action.cpp controlbutton.cpp controlcheckmark.cpp control.cpp controlfadelabel.cpp controlimage.cpp controllabel.cpp controllist.cpp controlprogress.cpp controlslider.cpp controlspin.cpp controltextbox.cpp dialog.cpp GUIPythonWindow.cpp GUIPythonWindowDialog.cpp GUIPythonWindowXML.cpp GUIPythonWindowXMLDialog.cpp infotagmusic.cpp infotagvideo.cpp keyboard.cpp listitem.cpp player.cpp pyplaylist.cpp PythonPlayer.cpp pyutil.cpp window.cpp winxml.cpp winxmldialog.cpp xbmcguimodule.cpp xbmcmodule.cpp controlgroup.cpp xbmcplugin.cpp controlradiobutton.cpp language.cpp PythonSettings.cpp
LIB=xbmcmodule.a
diff --git a/xbmc/lib/libPython/xbmcmodule/control.h b/xbmc/lib/libPython/xbmcmodule/control.h
index 7711eb1b7d..c76b37ce6c 100644
--- a/xbmc/lib/libPython/xbmcmodule/control.h
+++ b/xbmc/lib/libPython/xbmcmodule/control.h
@@ -78,6 +78,9 @@
#define ControlRadioButton_Check(op) PyObject_TypeCheck(op, &ControlRadioButton_Type)
#define ControlRadioButton_CheckExact(op) ((op)->ob_type == &ControlRadioButton_Type)
+#define ControlSlider_Check(op) PyObject_TypeCheck(op, &ControlSlider_Type)
+#define ControlSlider_CheckExact(op) ((op)->ob_type == &ControlSlider_Type)
+
// -----------------
// hardcoded offsets for button controls (and controls that use button controls)
@@ -234,6 +237,13 @@ namespace PYXBMC
color_t shadowColor;
color_t focusedColor;
} ControlRadioButton;
+
+ typedef struct {
+ PyObject_HEAD_XBMC_CONTROL
+ std::string strTextureBack;
+ std::string strTexture;
+ std::string strTextureFoc;
+ } ControlSlider;
extern void Control_Dealloc(Control* self);
@@ -251,6 +261,7 @@ namespace PYXBMC
extern PyTypeObject ControlList_Type;
extern PyTypeObject ControlProgress_Type;
extern PyTypeObject ControlRadioButton_Type;
+ extern PyTypeObject ControlSlider_Type;
CGUIControl* ControlLabel_Create(ControlLabel* pControl);
CGUIControl* ControlFadeLabel_Create(ControlFadeLabel* pControl);
@@ -262,6 +273,7 @@ namespace PYXBMC
CGUIControl* ControlList_Create(ControlList* pControl);
CGUIControl* ControlProgress_Create(ControlProgress* pControl);
CGUIControl* ControlRadioButton_Create(ControlRadioButton* pControl);
+ CGUIControl* ControlSlider_Create(ControlSlider* pControl);
void initControl_Type();
void initControlSpin_Type();
@@ -275,6 +287,7 @@ namespace PYXBMC
void initControlGroup_Type();
void initControlProgress_Type();
void initControlRadioButton_Type();
+ void initControlSlider_Type();
}
#ifdef __cplusplus
diff --git a/xbmc/lib/libPython/xbmcmodule/controlslider.cpp b/xbmc/lib/libPython/xbmcmodule/controlslider.cpp
new file mode 100644
index 0000000000..751cce11fa
--- /dev/null
+++ b/xbmc/lib/libPython/xbmcmodule/controlslider.cpp
@@ -0,0 +1,186 @@
+/*
+ * Copyright (C) 2005-2010 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#if (defined HAVE_CONFIG_H) && (!defined WIN32)
+ #include "config.h"
+#endif
+#if (defined USE_EXTERNAL_PYTHON)
+ #if (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_4)
+ #include <python2.4/Python.h>
+ #else
+ #error "Could not determine version of Python to use."
+ #endif
+#else
+ #include "lib/libPython/Python/Include/Python.h"
+#endif
+#include "GUISliderControl.h"
+#include "control.h"
+#include "pyutil.h"
+#include "utils/log.h"
+using namespace std;
+
+#ifndef __GNUC__
+#pragma code_seg("PY_TEXT")
+#pragma data_seg("PY_DATA")
+#pragma bss_seg("PY_BSS")
+#pragma const_seg("PY_RDATA")
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+namespace PYXBMC
+{
+ PyObject * ControlSlider_New (PyTypeObject *type, PyObject *args, PyObject *kwds)
+ {
+ static const char* keywords[] = { "x", "y", "width", "height", "textureback", "texture", "texturefocus", NULL };
+
+ ControlSlider *self;
+ char *cTextureBack = NULL;
+ char *cTexture = NULL;
+ char *cTextureFoc = NULL;
+
+ self = (ControlSlider *) type->tp_alloc (type, 0);
+ if (!self) return NULL;
+ new(&self->strTextureBack) string();
+ new(&self->strTexture) string();
+ new(&self->strTextureFoc) string();
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds,
+ (char*)"llll|sss",
+ (char**)keywords,
+ &self->dwPosX,
+ &self->dwPosY,
+ &self->dwWidth,
+ &self->dwHeight,
+ &cTextureBack,
+ &cTexture,
+ &cTextureFoc))
+ {
+ Py_DECREF( self );
+ return NULL;
+ }
+ // if texture is supplied use it, else get default ones
+ self->strTextureBack = cTextureBack ? cTextureBack : PyXBMCGetDefaultImage((char*)"slider", (char*)"texturesliderbar", (char*)"osd_slider_bg_2.png");
+ self->strTexture = cTexture ? cTexture : PyXBMCGetDefaultImage((char*)"slider", (char*)"textureslidernib", (char*)"osd_slider_nibNF.png");
+ self->strTextureFoc = cTextureFoc ? cTextureFoc : PyXBMCGetDefaultImage((char*)"slider", (char*)"textureslidernibfocus", (char*)"osd_slider_nib.png");
+
+ return (PyObject*)self;
+ }
+
+ void ControlSlider_Dealloc(ControlSlider* self)
+ {
+ self->strTextureBack.~string();
+ self->strTexture.~string();
+ self->strTextureFoc.~string();
+ self->ob_type->tp_free((PyObject*)self);
+ }
+
+ CGUIControl* ControlSlider_Create (ControlSlider* pControl)
+ {
+
+ pControl->pGUIControl = new CGUISliderControl(pControl->iParentId, pControl->iControlId,(float)pControl->dwPosX, (float)pControl->dwPosY,
+ (float)pControl->dwWidth,(float)pControl->dwHeight,
+ (CStdString)pControl->strTextureBack,(CStdString)pControl->strTexture,
+ (CStdString)pControl->strTextureFoc,0);
+
+
+ return pControl->pGUIControl;
+ }
+
+ PyDoc_STRVAR(getPercent__doc__,
+ "getPercent() -- Returns a float of the percent of the slider.\n"
+ "\n"
+ "example:\n"
+ " - print self.slider.getPercent()\n");
+
+ PyObject* ControlSlider_GetPercent(ControlSlider*self, PyObject *args)
+ {
+ if (self->pGUIControl)
+ {
+ float fPercent;
+ fPercent = ((CGUISliderControl*)self->pGUIControl)->GetPercentage();
+ return Py_BuildValue((char*)"f", fPercent);
+ }
+ return Py_BuildValue((char*)"f", 0);
+ }
+
+
+
+ PyMethodDef ControlSlider_methods[] = {
+ {(char*)"getPercent", (PyCFunction)ControlSlider_GetPercent, METH_VARARGS, getPercent__doc__},
+ {NULL, NULL, 0, NULL}
+ };
+
+ // ControlProgress class
+ PyDoc_STRVAR(ControlSlider__doc__,
+ "ControlSlider class.\n"
+ "\n"
+ "ControlSlider(x, y, width, height[, textureback, texture, texturefocus])\n"
+ "\n"
+ "x : integer - x coordinate of control.\n"
+ "y : integer - y coordinate of control.\n"
+ "width : integer - width of control.\n"
+ "height : integer - height of control.\n"
+ "textureback : [opt] string - image filename.\n"
+ "texture : [opt] string - image filename.\n"
+ "texturefocus : [opt] string - image filename.\n"
+ "*Note, You can use the above as keywords for arguments and skip certain optional arguments.\n"
+ " Once you use a keyword, all following arguments require the keyword.\n"
+ " After you create the control, you need to add it to the window with addControl().\n"
+ "\n"
+ "example:\n"
+ " - self.slider = xbmcgui.ControlSlider(100, 250, 350, 40)\n");
+
+// Restore code and data sections to normal.
+#ifndef __GNUC__
+#pragma code_seg()
+#pragma data_seg()
+#pragma bss_seg()
+#pragma const_seg()
+#endif
+
+ PyTypeObject ControlSlider_Type;
+
+ void initControlSlider_Type()
+ {
+ PyXBMCInitializeTypeObject(&ControlSlider_Type);
+
+ ControlSlider_Type.tp_name = (char*)"xbmcgui.ControlSlider";
+ ControlSlider_Type.tp_basicsize = sizeof(ControlSlider);
+ ControlSlider_Type.tp_dealloc = (destructor)ControlSlider_Dealloc;
+ ControlSlider_Type.tp_compare = 0;
+ ControlSlider_Type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
+ ControlSlider_Type.tp_doc = ControlSlider__doc__;
+ ControlSlider_Type.tp_methods = ControlSlider_methods;
+ ControlSlider_Type.tp_base = &Control_Type;
+ ControlSlider_Type.tp_new = ControlSlider_New;
+ }
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/xbmc/lib/libPython/xbmcmodule/window.cpp b/xbmc/lib/libPython/xbmcmodule/window.cpp
index 6c672f99c7..752831ed2e 100644
--- a/xbmc/lib/libPython/xbmcmodule/window.cpp
+++ b/xbmc/lib/libPython/xbmcmodule/window.cpp
@@ -239,6 +239,12 @@ namespace PYXBMC
new(&((ControlProgress*)pControl)->strTextureBg) string();
new(&((ControlProgress*)pControl)->strTextureOverlay) string();
break;
+ case CGUIControl::GUICONTROL_SLIDER:
+ pControl = (Control*)ControlSlider_Type.tp_alloc(&ControlSlider_Type, 0);
+ new(&((ControlSlider*)pControl)->strTextureBack) string();
+ new(&((ControlSlider*)pControl)->strTexture) string();
+ new(&((ControlSlider*)pControl)->strTextureFoc) string();
+ break;
case CGUIControl::GUICONTAINER_LIST:
case CGUIControl::GUICONTAINER_WRAPLIST:
case CGUIControl::GUICONTAINER_FIXEDLIST:
@@ -598,6 +604,10 @@ namespace PYXBMC
else if (ControlProgress_Check(pControl))
ControlProgress_Create((ControlProgress*)pControl);
+ // Control Slider
+ else if (ControlSlider_Check(pControl))
+ ControlSlider_Create((ControlSlider*)pControl);
+
// Control Group
else if (ControlGroup_Check(pControl))
ControlGroup_Create((ControlGroup*)pControl);
diff --git a/xbmc/lib/libPython/xbmcmodule/xbmcguimodule.cpp b/xbmc/lib/libPython/xbmcmodule/xbmcguimodule.cpp
index ca62603afc..87c0ead844 100644
--- a/xbmc/lib/libPython/xbmcmodule/xbmcguimodule.cpp
+++ b/xbmc/lib/libPython/xbmcmodule/xbmcguimodule.cpp
@@ -157,6 +157,7 @@ namespace PYXBMC
initControlButton_Type();
initControlCheckMark_Type();
initControlProgress_Type();
+ initControlSlider_Type();
initControlList_Type();
initControlImage_Type();
initControlGroup_Type();
@@ -183,6 +184,7 @@ namespace PYXBMC
PyType_Ready(&ControlGroup_Type) < 0 ||
PyType_Ready(&Dialog_Type) < 0 ||
PyType_Ready(&DialogProgress_Type) < 0 ||
+ PyType_Ready(&ControlSlider_Type) < 0 ||
PyType_Ready(&ControlRadioButton_Type) < 0 ||
PyType_Ready(&Action_Type) < 0)
return;
@@ -217,6 +219,7 @@ namespace PYXBMC
Py_INCREF(&ControlList_Type);
Py_INCREF(&ControlImage_Type);
Py_INCREF(&ControlProgress_Type);
+ Py_INCREF(&ControlSlider_Type);
Py_INCREF(&ControlGroup_Type);
Py_INCREF(&Dialog_Type);
Py_INCREF(&DialogProgress_Type);
@@ -242,6 +245,7 @@ namespace PYXBMC
PyModule_AddObject(pXbmcGuiModule, (char*)"ControlList", (PyObject*)&ControlList_Type);
PyModule_AddObject(pXbmcGuiModule, (char*)"ControlImage", (PyObject*)& ControlImage_Type);
PyModule_AddObject(pXbmcGuiModule, (char*)"ControlProgress", (PyObject*)& ControlProgress_Type);
+ PyModule_AddObject(pXbmcGuiModule, (char*)"ControlSlider", (PyObject*)& ControlSlider_Type);
PyModule_AddObject(pXbmcGuiModule, (char*)"ControlGroup", (PyObject*)& ControlGroup_Type);
PyModule_AddObject(pXbmcGuiModule, (char*)"Dialog", (PyObject *)&Dialog_Type);
PyModule_AddObject(pXbmcGuiModule, (char*)"DialogProgress", (PyObject *)&DialogProgress_Type);