screen: adjust indentation
This commit is contained in:
266
src/screen.h
266
src/screen.h
@@ -30,90 +30,89 @@ void scrollpadMouseButtonPressed(NC::Scrollpad *w, MEVENT me);
|
|||||||
/// An interface for various instantiations of Screen template class. Since C++ doesn't like
|
/// An interface for various instantiations of Screen template class. Since C++ doesn't like
|
||||||
/// comparison of two different instantiations of the same template class we need the most
|
/// comparison of two different instantiations of the same template class we need the most
|
||||||
/// basic class to be non-template to allow it.
|
/// basic class to be non-template to allow it.
|
||||||
class BasicScreen
|
struct BasicScreen
|
||||||
{
|
{
|
||||||
public:
|
/// Initializes all variables to zero
|
||||||
/// Initializes all variables to zero
|
BasicScreen() : hasToBeResized(0), isInitialized(0) { }
|
||||||
BasicScreen() : hasToBeResized(0), isInitialized(0) { }
|
|
||||||
|
virtual ~BasicScreen() { }
|
||||||
virtual ~BasicScreen() { }
|
|
||||||
|
/// @see Screen::activeWindow()
|
||||||
/// @see Screen::activeWindow()
|
virtual NC::Window *activeWindow() = 0;
|
||||||
virtual NC::Window *activeWindow() = 0;
|
|
||||||
|
/// @see Screen::refresh()
|
||||||
/// @see Screen::refresh()
|
virtual void refresh() = 0;
|
||||||
virtual void refresh() = 0;
|
|
||||||
|
/// @see Screen::refreshWindow()
|
||||||
/// @see Screen::refreshWindow()
|
virtual void refreshWindow() = 0;
|
||||||
virtual void refreshWindow() = 0;
|
|
||||||
|
/// @see Screen::scroll()
|
||||||
/// @see Screen::scroll()
|
virtual void scroll(NC::Where where) = 0;
|
||||||
virtual void scroll(NC::Where where) = 0;
|
|
||||||
|
/// Method used for switching to screen
|
||||||
/// Method used for switching to screen
|
virtual void switchTo() = 0;
|
||||||
virtual void switchTo() = 0;
|
|
||||||
|
/// Method that should resize screen
|
||||||
/// Method that should resize screen
|
/// if requested by hasToBeResized
|
||||||
/// if requested by hasToBeResized
|
virtual void resize() = 0;
|
||||||
virtual void resize() = 0;
|
|
||||||
|
/// @return title of the screen
|
||||||
/// @return title of the screen
|
virtual std::wstring title() = 0;
|
||||||
virtual std::wstring title() = 0;
|
|
||||||
|
/// If the screen contantly has to update itself
|
||||||
/// If the screen contantly has to update itself
|
/// somehow, it should be called by this function.
|
||||||
/// somehow, it should be called by this function.
|
virtual void update() = 0;
|
||||||
virtual void update() = 0;
|
|
||||||
|
/// Invoked after Enter was pressed
|
||||||
/// Invoked after Enter was pressed
|
virtual void enterPressed() = 0;
|
||||||
virtual void enterPressed() = 0;
|
|
||||||
|
/// Invoked after Space was pressed
|
||||||
/// Invoked after Space was pressed
|
virtual void spacePressed() = 0;
|
||||||
virtual void spacePressed() = 0;
|
|
||||||
|
/// @see Screen::mouseButtonPressed()
|
||||||
/// @see Screen::mouseButtonPressed()
|
virtual void mouseButtonPressed(MEVENT me) = 0;
|
||||||
virtual void mouseButtonPressed(MEVENT me) = 0;
|
|
||||||
|
/// When this is overwritten with a function returning true, the
|
||||||
/// When this is overwritten with a function returning true, the
|
/// screen will be used in tab switching.
|
||||||
/// screen will be used in tab switching.
|
virtual bool isTabbable() = 0;
|
||||||
virtual bool isTabbable() = 0;
|
|
||||||
|
/// @return true if screen is mergable, ie. can be "proper" subwindow
|
||||||
/// @return true if screen is mergable, ie. can be "proper" subwindow
|
/// if one of the screens is locked. Screens that somehow resemble popups
|
||||||
/// if one of the screens is locked. Screens that somehow resemble popups
|
/// will want to return false here.
|
||||||
/// will want to return false here.
|
virtual bool isMergable() = 0;
|
||||||
virtual bool isMergable() = 0;
|
|
||||||
|
/// Locks current screen.
|
||||||
/// Locks current screen.
|
/// @return true if lock was successful, false otherwise. Note that
|
||||||
/// @return true if lock was successful, false otherwise. Note that
|
/// if there is already locked screen, it'll not overwrite it.
|
||||||
/// if there is already locked screen, it'll not overwrite it.
|
bool lock();
|
||||||
bool lock();
|
|
||||||
|
/// Should be set to true each time screen needs resize
|
||||||
/// Should be set to true each time screen needs resize
|
bool hasToBeResized;
|
||||||
bool hasToBeResized;
|
|
||||||
|
/// Unlocks a screen, ie. hides merged window (if there is one set).
|
||||||
/// Unlocks a screen, ie. hides merged window (if there is one set).
|
static void unlock();
|
||||||
static void unlock();
|
|
||||||
|
protected:
|
||||||
protected:
|
/// Since screens initialization is lazy, we don't want to do
|
||||||
/// Since screens initialization is lazy, we don't want to do
|
/// this in the constructor. This function should be invoked
|
||||||
/// this in the constructor. This function should be invoked
|
/// only once and after that isInitialized flag has to be set
|
||||||
/// only once and after that isInitialized flag has to be set
|
/// to true to somehow avoid next attempt of initialization.
|
||||||
/// to true to somehow avoid next attempt of initialization.
|
virtual void init() = 0;
|
||||||
virtual void init() = 0;
|
|
||||||
|
/// @return true if screen can be locked. Note that returning
|
||||||
/// @return true if screen can be locked. Note that returning
|
/// false here doesn't neccesarily mean that screen is also not
|
||||||
/// false here doesn't neccesarily mean that screen is also not
|
/// mergable (eg. lyrics screen is not lockable since that wouldn't
|
||||||
/// mergable (eg. lyrics screen is not lockable since that wouldn't
|
/// make much sense, but it's perfectly fine to merge it).
|
||||||
/// make much sense, but it's perfectly fine to merge it).
|
virtual bool isLockable() = 0;
|
||||||
virtual bool isLockable() = 0;
|
|
||||||
|
/// Gets X offset and width of current screen to be used eg. in resize() function.
|
||||||
/// Gets X offset and width of current screen to be used eg. in resize() function.
|
/// @param adjust_locked_screen indicates whether this function should
|
||||||
/// @param adjust_locked_screen indicates whether this function should
|
/// automatically adjust locked screen's dimensions (if there is one set)
|
||||||
/// automatically adjust locked screen's dimensions (if there is one set)
|
/// if current screen is going to be subwindow.
|
||||||
/// if current screen is going to be subwindow.
|
void getWindowResizeParams(size_t &x_offset, size_t &width, bool adjust_locked_screen = true);
|
||||||
void getWindowResizeParams(size_t &x_offset, size_t &width, bool adjust_locked_screen = true);
|
|
||||||
|
/// Flag that inditates whether the screen is initialized or not
|
||||||
/// Flag that inditates whether the screen is initialized or not
|
bool isInitialized;
|
||||||
bool isInitialized;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void applyToVisibleWindows(void (BasicScreen::*f)());
|
void applyToVisibleWindows(void (BasicScreen::*f)());
|
||||||
@@ -124,58 +123,57 @@ bool isVisible(BasicScreen *screen);
|
|||||||
/// for the screen to be working properly and assumes that we didn't forget
|
/// for the screen to be working properly and assumes that we didn't forget
|
||||||
/// about anything vital.
|
/// about anything vital.
|
||||||
///
|
///
|
||||||
template <typename WindowT> class Screen : public BasicScreen
|
template <typename WindowT> struct Screen : public BasicScreen
|
||||||
{
|
{
|
||||||
public:
|
typedef WindowT ScreenType;
|
||||||
typedef WindowT ScreenType;
|
|
||||||
|
Screen() : w(0) { }
|
||||||
Screen() : w(0) { }
|
virtual ~Screen() { }
|
||||||
virtual ~Screen() { }
|
|
||||||
|
/// Since some screens contain more that one window
|
||||||
/// Since some screens contain more that one window
|
/// it's useful to determine the one that is being
|
||||||
/// it's useful to determine the one that is being
|
/// active
|
||||||
/// active
|
/// @return address to window object cast to void *
|
||||||
/// @return address to window object cast to void *
|
virtual NC::Window *activeWindow() OVERRIDE {
|
||||||
virtual NC::Window *activeWindow() OVERRIDE {
|
return w;
|
||||||
return w;
|
}
|
||||||
}
|
|
||||||
|
/// Refreshes whole screen
|
||||||
/// Refreshes whole screen
|
virtual void refresh() OVERRIDE {
|
||||||
virtual void refresh() OVERRIDE {
|
w->display();
|
||||||
w->display();
|
}
|
||||||
}
|
|
||||||
|
/// Refreshes active window of the screen
|
||||||
/// Refreshes active window of the screen
|
virtual void refreshWindow() OVERRIDE {
|
||||||
virtual void refreshWindow() OVERRIDE {
|
w->display();
|
||||||
w->display();
|
}
|
||||||
}
|
|
||||||
|
/// Scrolls the screen by given amount of lines and
|
||||||
/// Scrolls the screen by given amount of lines and
|
/// if fancy scrolling feature is disabled, enters the
|
||||||
/// if fancy scrolling feature is disabled, enters the
|
/// loop that holds main loop until user releases the key
|
||||||
/// loop that holds main loop until user releases the key
|
/// @param where indicates where one wants to scroll
|
||||||
/// @param where indicates where one wants to scroll
|
virtual void scroll(NC::Where where) OVERRIDE {
|
||||||
virtual void scroll(NC::Where where) OVERRIDE {
|
w->scroll(where);
|
||||||
w->scroll(where);
|
}
|
||||||
}
|
|
||||||
|
/// Invoked after there was one of mouse buttons pressed
|
||||||
/// Invoked after there was one of mouse buttons pressed
|
/// @param me struct that contains coords of where the click
|
||||||
/// @param me struct that contains coords of where the click
|
/// had its place and button actions
|
||||||
/// had its place and button actions
|
virtual void mouseButtonPressed(MEVENT me) OVERRIDE {
|
||||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE {
|
genericMouseButtonPressed(w, me);
|
||||||
genericMouseButtonPressed(w, me);
|
}
|
||||||
}
|
|
||||||
|
/// @return pointer to currently active window
|
||||||
/// @return pointer to currently active window
|
WindowT *main() {
|
||||||
WindowT *main() {
|
return w;
|
||||||
return w;
|
}
|
||||||
}
|
|
||||||
|
protected:
|
||||||
protected:
|
/// Template parameter that should indicate the main type
|
||||||
/// Template parameter that should indicate the main type
|
/// of window used by the screen. What is more, it should
|
||||||
/// of window used by the screen. What is more, it should
|
/// always be assigned to the currently active window (if
|
||||||
/// always be assigned to the currently active window (if
|
/// acreen contains more that one)
|
||||||
/// acreen contains more that one)
|
WindowT *w;
|
||||||
WindowT *w;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Specialization for Screen<Scrollpad>::mouseButtonPressed, that should
|
/// Specialization for Screen<Scrollpad>::mouseButtonPressed, that should
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
#include "actions.h"
|
#include "actions.h"
|
||||||
#include "strbuffer.h"
|
#include "strbuffer.h"
|
||||||
|
|
||||||
class BasicScreen; // forward declaration for screens sequence
|
struct BasicScreen; // forward declaration for screens sequence
|
||||||
|
|
||||||
enum SortMode { smName, smMTime, smCustomFormat };
|
enum SortMode { smName, smMTime, smCustomFormat };
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user