Author: mordante
Date: Fri May 22 21:08:34 2009
New Revision: 35828

URL: http://svn.gna.org/viewcvs/wesnoth?rev=35828&view=rev
Log:
Add a new transient dialog.

Added:
    trunk/data/gui/default/window/transient_message.cfg   (with props)
    trunk/src/gui/dialogs/transient_message.cpp   (with props)
    trunk/src/gui/dialogs/transient_message.hpp   (with props)
Modified:
    trunk/changelog
    trunk/po/wesnoth-lib/POTFILES.in
    trunk/src/CMakeLists.txt
    trunk/src/Makefile.am
    trunk/src/SConscript
    trunk/src/gui/widgets/settings.cpp
    trunk/src/gui/widgets/settings.hpp
    trunk/src/tests/gui/test_gui2.cpp

Modified: trunk/changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=35828&r1=35827&r2=35828&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Fri May 22 21:08:34 2009
@@ -8,6 +8,7 @@
    * Added unit tests for the new widgets
    * Improved the layout algorithm not to show scrollbars when they make the
      situation worse
+   * Add a new transient message dialog
  * Miscellaneous and bugfixes:
    * Add strict compilation to cmake
    * Let cmake also use the CXXFLAGS and CFLAGS environment variables

Added: trunk/data/gui/default/window/transient_message.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/gui/default/window/transient_message.cfg?rev=35828&view=auto
==============================================================================
--- trunk/data/gui/default/window/transient_message.cfg (added)
+++ trunk/data/gui/default/window/transient_message.cfg Fri May 22 21:08:34 2009
@@ -1,0 +1,58 @@
+#textdomain wesnoth-lib
+###
+### In game transient message dialog.
+###
+
+[window]
+       id = "transient_message"
+       description = "A transient message on a semi-transparent dialog."
+
+       [resolution]
+               definition = "message"
+
+               easy_close = "true"
+
+               [grid]  
+
+                       [row]
+
+                               [column]
+                                       border = "all"
+                                       border_size = 5
+
+                                       vertical_alignment = "top"
+                                       horizontal_alignment = "left"
+
+                                       [label]
+                                               id = "title"
+                                               definition = "title"
+                                       [/label]
+
+                               [/column]
+
+                       [/row]
+
+                       [row]
+
+                               [column]
+                                       border = "all"
+                                       border_size = 5
+
+                                       vertical_alignment = "top"
+                                       horizontal_alignment = "left"
+
+                                       [label]
+                                               id = "message"
+                                               definition = "wml_message"
+                                       [/label]
+
+                               [/column]
+
+                       [/row]
+
+               [/grid]
+
+       [/resolution]
+
+[/window]
+

Propchange: trunk/data/gui/default/window/transient_message.cfg
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: trunk/po/wesnoth-lib/POTFILES.in
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/po/wesnoth-lib/POTFILES.in?rev=35828&r1=35827&r2=35828&view=diff
==============================================================================
--- trunk/po/wesnoth-lib/POTFILES.in (original)
+++ trunk/po/wesnoth-lib/POTFILES.in Fri May 22 21:08:34 2009
@@ -19,6 +19,7 @@
 src/gui/dialogs/mp_create_game.cpp
 src/gui/dialogs/mp_method_selection.cpp
 src/gui/dialogs/title_screen.cpp
+src/gui/dialogs/transient_message.cpp
 src/gui/dialogs/wml_message.cpp
 src/gui/widgets/button.cpp
 src/gui/widgets/control.cpp

Modified: trunk/src/CMakeLists.txt
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/CMakeLists.txt?rev=35828&r1=35827&r2=35828&view=diff
==============================================================================
--- trunk/src/CMakeLists.txt (original)
+++ trunk/src/CMakeLists.txt Fri May 22 21:08:34 2009
@@ -261,6 +261,7 @@
     gui/dialogs/mp_method_selection.cpp
     gui/dialogs/mp_cmd_wrapper.cpp
     gui/dialogs/title_screen.cpp
+    gui/dialogs/transient_message.cpp
     gui/dialogs/wml_message.cpp
     gui/widgets/button.cpp
     gui/widgets/control.cpp

Modified: trunk/src/Makefile.am
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/Makefile.am?rev=35828&r1=35827&r2=35828&view=diff
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Fri May 22 21:08:34 2009
@@ -91,6 +91,7 @@
        gui/dialogs/mp_method_selection.cpp \
        gui/dialogs/mp_cmd_wrapper.cpp \
        gui/dialogs/title_screen.cpp \
+       gui/dialogs/transient_message.cpp \
        gui/dialogs/wml_message.cpp \
        gui/widgets/button.cpp \
        gui/widgets/control.cpp \

Modified: trunk/src/SConscript
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/SConscript?rev=35828&r1=35827&r2=35828&view=diff
==============================================================================
--- trunk/src/SConscript (original)
+++ trunk/src/SConscript Fri May 22 21:08:34 2009
@@ -246,6 +246,7 @@
     gui/dialogs/mp_method_selection.cpp
     gui/dialogs/mp_cmd_wrapper.cpp
     gui/dialogs/title_screen.cpp
+    gui/dialogs/transient_message.cpp
     gui/dialogs/wml_message.cpp
     gui/widgets/button.cpp
     gui/widgets/control.cpp

Added: trunk/src/gui/dialogs/transient_message.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/transient_message.cpp?rev=35828&view=auto
==============================================================================
--- trunk/src/gui/dialogs/transient_message.cpp (added)
+++ trunk/src/gui/dialogs/transient_message.cpp Fri May 22 21:08:34 2009
@@ -1,0 +1,58 @@
+/* $Id$ */
+/*
+   Copyright (C) 2009 by Mark de Wever <[email protected]>
+   Part of the Battle for Wesnoth Project http://www.wesnoth.org/
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License 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.
+
+   See the COPYING file for more details.
+*/
+
+#define GETTEXT_DOMAIN "wesnoth-lib"
+
+#include "gui/dialogs/transient_message.hpp"
+
+#include "gui/widgets/label.hpp"
+#include "gui/widgets/window.hpp"
+
+namespace gui2 {
+
+twindow* ttransient_message::build_window(CVideo& video)
+{
+       return build(video, get_id(TRANSIENT_MESSAGE));
+}
+
+void ttransient_message::pre_show(CVideo& /*video*/, twindow& window)
+{
+       tlabel* title =
+               dynamic_cast<tlabel*>(window.find_widget("title", false));
+       VALIDATE(title, missing_widget("title"));
+
+       title->set_label(title_);
+       title->set_markup_mode(title_markup_mode_);
+
+       tlabel* message =
+               dynamic_cast<tlabel*>(window.find_widget("message", false));
+       VALIDATE(message, missing_widget("message"));
+
+       message->set_label(message_);
+       message->set_markup_mode(message_markup_mode_);
+       message->set_can_wrap(true);
+}
+
+void show_transient_message(CVideo& video, const std::string& title,
+       const std::string& message,
+       const tcontrol::tmarkup_mode message_markup_mode,
+       const tcontrol::tmarkup_mode title_markup_mode)
+{
+       ttransient_message dlg(title, title_markup_mode,
+                       message, message_markup_mode);
+       dlg.show(video);
+}
+
+} // namespace gui2
+

Propchange: trunk/src/gui/dialogs/transient_message.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/src/gui/dialogs/transient_message.cpp
------------------------------------------------------------------------------
    svn:keywords = 'Author Date Id Revision'

Added: trunk/src/gui/dialogs/transient_message.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/transient_message.hpp?rev=35828&view=auto
==============================================================================
--- trunk/src/gui/dialogs/transient_message.hpp (added)
+++ trunk/src/gui/dialogs/transient_message.hpp Fri May 22 21:08:34 2009
@@ -1,0 +1,83 @@
+/* $Id$ */
+/*
+   Copyright (C) 2009 by Mark de Wever <[email protected]>
+   Part of the Battle for Wesnoth Project http://www.wesnoth.org/
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License 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.
+
+   See the COPYING file for more details.
+*/
+
+#ifndef GUI_DIALOGS_TRANSIENT_MESSAGE_HPP_INCLUDED
+#define GUI_DIALOGS_TRANSIENT_MESSAGE_HPP_INCLUDED
+
+#include "gui/dialogs/dialog.hpp"
+#include "gui/widgets/control.hpp"
+
+namespace gui2 {
+
+/** Shows a transient message. */
+class ttransient_message
+       : public tdialog
+{
+public:
+       ttransient_message(const std::string& title,
+                       const tcontrol::tmarkup_mode title_markup_mode,
+                       const std::string& message,
+                       const tcontrol::tmarkup_mode message_markup_mode)
+               : title_(title)
+               , title_markup_mode_(title_markup_mode)
+               , message_(message)
+               , message_markup_mode_(message_markup_mode)
+       {}
+
+protected:
+       /** Inherited from tdialog. */
+       void pre_show(CVideo& video, twindow& window);
+
+private:
+       /** The title for the dialog. */
+       std::string title_;
+
+       /** The markup mode for the title. */
+       tcontrol::tmarkup_mode title_markup_mode_;
+
+       /** The message to show to the user. */
+       std::string message_;
+
+       /** The markup mode for the message. */
+       tcontrol::tmarkup_mode message_markup_mode_;
+
+       /** Inherited from tdialog. */
+       twindow* build_window(CVideo& video);
+};
+
+/**
+ * Shows a transient message to the user.
+ *
+ * This shows a dialog with a short message which can be dismissed with a
+ * single click.
+ *
+ * @note The message _should_ be small enough to fit on the window, the test
+ * can contain newlines and will wrap when needed.
+ *
+ * @param video               The video which contains the surface to draw
+ *                            upon.
+ * @param title               The title of the dialog.
+ * @param message             The message to show in the dialog.
+ * @param message_markup_mode The markup mode used for the title.
+ * @param title_markup_mod    The markup mode used for the title.
+ */
+void show_transient_message(CVideo& video, const std::string& title,
+       const std::string& message,
+       const tcontrol::tmarkup_mode message_markup_mode = tcontrol::NO_MARKUP,
+       const tcontrol::tmarkup_mode title_markup_mode = tcontrol::NO_MARKUP);
+
+} // namespace gui2
+
+#endif
+

Propchange: trunk/src/gui/dialogs/transient_message.hpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/src/gui/dialogs/transient_message.hpp
------------------------------------------------------------------------------
    svn:keywords = 'Author Date Id Revision'

Modified: trunk/src/gui/widgets/settings.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/settings.cpp?rev=35828&r1=35827&r2=35828&view=diff
==============================================================================
--- trunk/src/gui/widgets/settings.cpp (original)
+++ trunk/src/gui/widgets/settings.cpp Fri May 22 21:08:34 2009
@@ -80,6 +80,7 @@
        window_type_list[WML_MESSAGE_LEFT] = "wml_message_left";
        window_type_list[WML_MESSAGE_RIGHT] = "wml_message_right";
        window_type_list[MESSAGE] = "message";
+       window_type_list[TRANSIENT_MESSAGE] = "transient_message";
        window_type_list[MP_CONNECT] = "mp_connect";
        window_type_list[MP_METHOD_SELECTION] = "mp_method_selection";
        window_type_list[MP_SERVER_LIST] = "mp_server_list";

Modified: trunk/src/gui/widgets/settings.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/settings.hpp?rev=35828&r1=35827&r2=35828&view=diff
==============================================================================
--- trunk/src/gui/widgets/settings.hpp (original)
+++ trunk/src/gui/widgets/settings.hpp Fri May 22 21:08:34 2009
@@ -42,6 +42,7 @@
        CAMPAIGN_SELECTION,      /**< The campaign selection dialog. */
        LANGUAGE_SELECTION,      /**< The language selection dialog. */
        MESSAGE,                 /**< A generic message dialog. */
+       TRANSIENT_MESSAGE,       /**< A transient message dialog. */
        WML_MESSAGE_LEFT,        /**<
                                  * A WML message dialog with the portrait on
                                  * the left side.

Modified: trunk/src/tests/gui/test_gui2.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tests/gui/test_gui2.cpp?rev=35828&r1=35827&r2=35828&view=diff
==============================================================================
--- trunk/src/tests/gui/test_gui2.cpp (original)
+++ trunk/src/tests/gui/test_gui2.cpp Fri May 22 21:08:34 2009
@@ -39,6 +39,7 @@
 #include "gui/dialogs/mp_method_selection.hpp"
 #include "gui/dialogs/mp_cmd_wrapper.hpp"
 #include "gui/dialogs/title_screen.hpp"
+#include "gui/dialogs/transient_message.hpp"
 #include "gui/dialogs/wml_message.hpp"
 #include "gui/widgets/helper.hpp"
 #include "gui/widgets/settings.hpp"
@@ -334,6 +335,17 @@
 };
 
 template<>
+struct twrapper<gui2::ttransient_message>
+{
+       static gui2::ttransient_message* create()
+       {
+               return new gui2::ttransient_message(
+                               "Title", gui2::tcontrol::NO_MARKUP,
+                               "Message", gui2::tcontrol::NO_MARKUP);
+       }
+};
+
+template<>
 struct twrapper<gui2::twml_message_left>
 {
        static gui2::twml_message_left* create()


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to