Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <eiseljulian@gmail.com>2018-05-23 23:38:25 +0300
committerJulian Eisel <eiseljulian@gmail.com>2018-05-23 23:38:25 +0300
commit6f20fcd5984a47baee9ff440e9e59584fccd1e59 (patch)
tree5b81aad5b91eb0893a4e0b9276ae2819e66cb631 /source/blender/editors/space_statusbar
parent7b58073dc09c7241dfa08071323dfb7af3646e80 (diff)
UI: Global "Status-bar" Area (WIP)
* Add horizontal bar at bottom of all non-temp windows, similar to the Top-bar. * Status-bar is hidden in UI-less fullscreen mode * Current contents are preliminary and based on T54861: ** Left: Current file-path if needed. "(Modified)" note if file was changed. ** Center: Scene statistics (like in 2.7 Info Editor). ** Right: Progress-bars and reports * Internally managed as own "STATUSBAR" editor-type (hidden in UI). * Like with the Top-bar, Status-bar data and SDNA writing is disabled. * Most changes in low-level screen/area code are to support layout bounds that differ from window bounds. Design task: T54861 Main changes approved by @brecht.
Diffstat (limited to 'source/blender/editors/space_statusbar')
-rw-r--r--source/blender/editors/space_statusbar/CMakeLists.txt45
-rw-r--r--source/blender/editors/space_statusbar/space_statusbar.c200
2 files changed, 245 insertions, 0 deletions
diff --git a/source/blender/editors/space_statusbar/CMakeLists.txt b/source/blender/editors/space_statusbar/CMakeLists.txt
new file mode 100644
index 00000000000..31439942397
--- /dev/null
+++ b/source/blender/editors/space_statusbar/CMakeLists.txt
@@ -0,0 +1,45 @@
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# 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
+# of the License, 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 this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# Contributor(s): Jacques Beaurain.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(INC
+ ../include
+ ../../blenkernel
+ ../../blenlib
+ ../../blenloader
+ ../../blentranslation
+ ../../gpu
+ ../../makesdna
+ ../../makesrna
+ ../../windowmanager
+ ../../../../intern/guardedalloc
+ ../../../../intern/glew-mx
+)
+
+set(INC_SYS
+ ${GLEW_INCLUDE_PATH}
+)
+
+set(SRC
+ space_statusbar.c
+)
+
+add_definitions(${GL_DEFINITIONS})
+
+blender_add_lib(bf_editor_space_statusbar "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/space_statusbar/space_statusbar.c b/source/blender/editors/space_statusbar/space_statusbar.c
new file mode 100644
index 00000000000..4c6a2eea469
--- /dev/null
+++ b/source/blender/editors/space_statusbar/space_statusbar.c
@@ -0,0 +1,200 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, 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 this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/space_statusbar/space_statusbar.c
+ * \ingroup spstatusbar
+ */
+
+
+#include <string.h>
+#include <stdio.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+
+#include "BKE_context.h"
+#include "BKE_screen.h"
+
+#include "ED_screen.h"
+#include "ED_space_api.h"
+
+#include "RNA_access.h"
+
+#include "UI_interface.h"
+#include "UI_view2d.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+#include "WM_message.h"
+
+
+/* ******************** default callbacks for statusbar space ******************** */
+
+static SpaceLink *statusbar_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
+{
+ ARegion *ar;
+ SpaceStatusBar *sstatusbar;
+
+ sstatusbar = MEM_callocN(sizeof(*sstatusbar), "init statusbar");
+ sstatusbar->spacetype = SPACE_STATUSBAR;
+
+ /* header regions */
+ /* *** NOTE: ***
+ * Python layout code (space_statusbar.py) depends on the list order of
+ * these! Not nice at all, but the only way to identify the correct header
+ * to draw to is using alignment + list position. It can't use alignment
+ * only since code below has to set two right aligned regions - XXX. */
+ ar = MEM_callocN(sizeof(*ar), "right aligned header for statusbar");
+ BLI_addtail(&sstatusbar->regionbase, ar);
+ ar->regiontype = RGN_TYPE_HEADER;
+ ar->alignment = RGN_ALIGN_RIGHT;
+ ar = MEM_callocN(sizeof(*ar), "center header for statusbar");
+ BLI_addtail(&sstatusbar->regionbase, ar);
+ ar->regiontype = RGN_TYPE_HEADER;
+ ar->alignment = RGN_ALIGN_RIGHT; /* Right aligned too, so region layout code scales it correctly. */
+ ar = MEM_callocN(sizeof(*ar), "left aligned header for statusbar");
+ BLI_addtail(&sstatusbar->regionbase, ar);
+ ar->regiontype = RGN_TYPE_HEADER;
+ ar->alignment = RGN_ALIGN_NONE;
+
+ return (SpaceLink *)sstatusbar;
+}
+
+/* not spacelink itself */
+static void statusbar_free(SpaceLink *UNUSED(sl))
+{
+
+}
+
+
+/* spacetype; init callback */
+static void statusbar_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
+{
+
+}
+
+static SpaceLink *statusbar_duplicate(SpaceLink *sl)
+{
+ SpaceStatusBar *sstatusbarn = MEM_dupallocN(sl);
+
+ /* clear or remove stuff from old */
+
+ return (SpaceLink *)sstatusbarn;
+}
+
+
+
+/* add handlers, stuff you only do once or on area/region changes */
+static void statusbar_header_region_init(wmWindowManager *UNUSED(wm), ARegion *region)
+{
+ if (ELEM(region->alignment, RGN_ALIGN_RIGHT)) {
+ region->flag |= RGN_FLAG_DYNAMIC_SIZE;
+ }
+ ED_region_header_init(region);
+}
+
+static void statusbar_operatortypes(void)
+{
+
+}
+
+static void statusbar_keymap(struct wmKeyConfig *UNUSED(keyconf))
+{
+
+}
+
+static void statusbar_header_region_listener(
+ bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmNotifier *wmn, const Scene *UNUSED(scene))
+{
+ /* context changes */
+ switch (wmn->category) {
+ case NC_SCREEN:
+ if (ELEM(wmn->data, ND_LAYER, ND_SCREENCAST, ND_ANIMPLAY)) {
+ ED_region_tag_redraw(ar);
+ }
+ break;
+ case NC_WM:
+ if (wmn->data == ND_JOB)
+ ED_region_tag_redraw(ar);
+ break;
+ case NC_SCENE:
+ if (wmn->data == ND_RENDER_RESULT)
+ ED_region_tag_redraw(ar);
+ break;
+ case NC_SPACE:
+ if (wmn->data == ND_SPACE_INFO)
+ ED_region_tag_redraw(ar);
+ break;
+ case NC_ID:
+ if (wmn->action == NA_RENAME)
+ ED_region_tag_redraw(ar);
+ break;
+ }
+}
+
+static void statusbar_header_region_message_subscribe(
+ const bContext *UNUSED(C),
+ WorkSpace *UNUSED(workspace), Scene *UNUSED(scene),
+ bScreen *UNUSED(screen), ScrArea *UNUSED(sa), ARegion *ar,
+ struct wmMsgBus *mbus)
+{
+ wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
+ .owner = ar,
+ .user_data = ar,
+ .notify = ED_region_do_msg_notify_tag_redraw,
+ };
+
+ WM_msg_subscribe_rna_anon_prop(mbus, Window, view_layer, &msg_sub_value_region_tag_redraw);
+ WM_msg_subscribe_rna_anon_prop(mbus, ViewLayer, name, &msg_sub_value_region_tag_redraw);
+}
+
+/* only called once, from space/spacetypes.c */
+void ED_spacetype_statusbar(void)
+{
+ SpaceType *st = MEM_callocN(sizeof(*st), "spacetype statusbar");
+ ARegionType *art;
+
+ st->spaceid = SPACE_STATUSBAR;
+ strncpy(st->name, "Status Bar", BKE_ST_MAXNAME);
+
+ st->new = statusbar_new;
+ st->free = statusbar_free;
+ st->init = statusbar_init;
+ st->duplicate = statusbar_duplicate;
+ st->operatortypes = statusbar_operatortypes;
+ st->keymap = statusbar_keymap;
+
+ /* regions: header window */
+ art = MEM_callocN(sizeof(*art), "spacetype statusbar header region");
+ art->regionid = RGN_TYPE_HEADER;
+ art->prefsizey = HEADERY;
+ art->prefsizex = UI_UNIT_X * 5; /* Mainly to avoid glitches */
+ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER;
+ art->init = statusbar_header_region_init;
+ art->layout = ED_region_header_layout;
+ art->draw = ED_region_header_draw;
+ art->listener = statusbar_header_region_listener;
+ art->message_subscribe = statusbar_header_region_message_subscribe;
+ BLI_addhead(&st->regiontypes, art);
+
+ BKE_spacetype_register(st);
+}