Skip to content

Commit

Permalink
Refactor|libcommon|Menu: Renamed *ColorPreviewWidget as *ColorEditWidget
Browse files Browse the repository at this point in the history
For consistency with the other Widgets that edit value(s).
  • Loading branch information
danij-deng committed Sep 21, 2014
1 parent 1217118 commit 7502fad
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 86 deletions.
8 changes: 4 additions & 4 deletions doomsday/plugins/common/common.pri
Expand Up @@ -74,8 +74,8 @@ HEADERS += \
$$common_inc/x_hair.h \
$$common_inc/menu/page.h \
$$common_inc/menu/widgets/buttonwidget.h \
$$common_inc/menu/widgets/colorpreviewwidget.h \
$$common_inc/menu/widgets/cvarcolorpreviewwidget.h \
$$common_inc/menu/widgets/coloreditwidget.h \
$$common_inc/menu/widgets/cvarcoloreditwidget.h \
$$common_inc/menu/widgets/cvarinlinelistwidget.h \
$$common_inc/menu/widgets/cvarlineeditwidget.h \
$$common_inc/menu/widgets/cvarsliderwidget.h \
Expand Down Expand Up @@ -155,8 +155,8 @@ SOURCES += \
$$common_src/thinkerinfo.cpp \
$$common_src/x_hair.c \
$$common_src/menu/page.cpp \
$$common_src/menu/widgets/colorpreviewwidget.cpp \
$$common_src/menu/widgets/cvarcolorpreviewwidget.cpp \
$$common_src/menu/widgets/coloreditwidget.cpp \
$$common_src/menu/widgets/cvarcoloreditwidget.cpp \
$$common_src/menu/widgets/cvarinlinelistwidget.cpp \
$$common_src/menu/widgets/cvarlineeditwidget.cpp \
$$common_src/menu/widgets/cvarsliderwidget.cpp \
Expand Down
@@ -1,4 +1,4 @@
/** @file colorpreviewwidget.h UI widget for previewing a color.
/** @file coloreditwidget.h UI widget for editing a color.
*
* @authors Copyright © 2005-2014 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2005-2014 Daniel Swanson <danij@dengine.net>
Expand All @@ -18,8 +18,8 @@
* 02110-1301 USA</small>
*/

#ifndef LIBCOMMON_UI_COLORPREVIEWWIDGET
#define LIBCOMMON_UI_COLORPREVIEWWIDGET
#ifndef LIBCOMMON_UI_COLOREDITWIDGET
#define LIBCOMMON_UI_COLOREDITWIDGET

#include <de/Vector>
#include "widget.h"
Expand All @@ -38,16 +38,16 @@ namespace menu {
///@}

/**
* UI widget for previewing a color.
* UI widget for editing a color.
*
* @ingroup menu
*/
class ColorPreviewWidget : public Widget
class ColorEditWidget : public Widget
{
public:
explicit ColorPreviewWidget(de::Vector4f const &color = de::Vector4f(),
bool rgbaMode = false);
virtual ~ColorPreviewWidget();
explicit ColorEditWidget(de::Vector4f const &color = de::Vector4f(),
bool rgbaMode = false);
virtual ~ColorEditWidget();

void draw(Point2Raw const *origin);
void updateGeometry(Page *pagePtr);
Expand All @@ -58,9 +58,9 @@ class ColorPreviewWidget : public Widget
*
* @param newDimensions New dimensions of the preview area.
*
* @return Reference to this ColorPreviewWidget.
* @return Reference to this ColorEditWidget.
*/
ColorPreviewWidget &setPreviewDimensions(de::Vector2i const &newDimensions);
ColorEditWidget &setPreviewDimensions(de::Vector2i const &newDimensions);

/**
* Returns the dimensions of the preview area (in fixed 320x200 space).
Expand Down Expand Up @@ -88,14 +88,14 @@ class ColorPreviewWidget : public Widget
* @param newColor New color and alpha.
* @param flags @ref mncolorboxSetColorFlags
*
* @return Reference to this ColorPreviewWidget.
* @return Reference to this ColorEditWidget.
*/
ColorPreviewWidget &setColor(de::Vector4f const &newColor, int flags = MNCOLORBOX_SCF_NO_ACTION);
ColorEditWidget &setColor(de::Vector4f const &newColor, int flags = MNCOLORBOX_SCF_NO_ACTION);

ColorPreviewWidget &setRed (float newRed, int flags = MNCOLORBOX_SCF_NO_ACTION);
ColorPreviewWidget &setGreen(float newGreen, int flags = MNCOLORBOX_SCF_NO_ACTION);
ColorPreviewWidget &setBlue (float newBlue, int flags = MNCOLORBOX_SCF_NO_ACTION);
ColorPreviewWidget &setAlpha(float newAlpha, int flags = MNCOLORBOX_SCF_NO_ACTION);
ColorEditWidget &setRed (float newRed, int flags = MNCOLORBOX_SCF_NO_ACTION);
ColorEditWidget &setGreen(float newGreen, int flags = MNCOLORBOX_SCF_NO_ACTION);
ColorEditWidget &setBlue (float newBlue, int flags = MNCOLORBOX_SCF_NO_ACTION);
ColorEditWidget &setAlpha(float newAlpha, int flags = MNCOLORBOX_SCF_NO_ACTION);

private:
DENG2_PRIVATE(d)
Expand All @@ -104,4 +104,4 @@ class ColorPreviewWidget : public Widget
} // namespace menu
} // namespace common

#endif // LIBCOMMON_UI_COLORPREVIEWWIDGET
#endif // LIBCOMMON_UI_COLOREDITWIDGET
@@ -1,4 +1,4 @@
/** @file cvarcolorpreviewwidget.h UI widget for previewing a color cvar.
/** @file cvarcoloreditwidget.h UI widget for editing a color cvar.
*
* @authors Copyright © 2005-2014 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2005-2014 Daniel Swanson <danij@dengine.net>
Expand All @@ -18,27 +18,27 @@
* 02110-1301 USA</small>
*/

#ifndef LIBCOMMON_UI_CVARCOLORPREVIEWWIDGET
#define LIBCOMMON_UI_CVARCOLORPREVIEWWIDGET
#ifndef LIBCOMMON_UI_CVARCOLOREDITWIDGET
#define LIBCOMMON_UI_CVARCOLOREDITWIDGET

#include "colorpreviewwidget.h"
#include "coloreditwidget.h"

namespace common {
namespace menu {

/**
* UI widget for previewing a color cvar.
* UI widget for editing a color cvar.
*
* @ingroup menu
*/
class CVarColorPreviewWidget : public ColorPreviewWidget
class CVarColorEditWidget : public ColorEditWidget
{
public:
explicit CVarColorPreviewWidget(char const *redCVarPath, char const *greenCVarPath,
char const *blueCVarPath, char const *alphaCVarPath = 0,
de::Vector4f const &color = de::Vector4f(),
bool rgbaMode = false);
virtual ~CVarColorPreviewWidget();
explicit CVarColorEditWidget(char const *redCVarPath, char const *greenCVarPath,
char const *blueCVarPath, char const *alphaCVarPath = 0,
de::Vector4f const &color = de::Vector4f(),
bool rgbaMode = false);
virtual ~CVarColorEditWidget();

char const *cvarPath(int component) const;

Expand All @@ -51,9 +51,9 @@ class CVarColorPreviewWidget : public ColorPreviewWidget
char const *_cvarPaths[4];
};

void CVarColorPreviewWidget_UpdateCVar(Widget *wi, Widget::mn_actionid_t action);
void CVarColorEditWidget_UpdateCVar(Widget *wi, Widget::mn_actionid_t action);

} // namespace menu
} // namespace common

#endif // LIBCOMMON_UI_COLORPREVIEWWIDGET
#endif // LIBCOMMON_UI_CVARCOLOREDITWIDGET
46 changes: 23 additions & 23 deletions doomsday/plugins/common/src/hu_menu.cpp
Expand Up @@ -47,8 +47,8 @@
#include "x_hair.h"

#include "menu/page.h"
#include "menu/widgets/colorpreviewwidget.h"
#include "menu/widgets/cvarcolorpreviewwidget.h"
#include "menu/widgets/coloreditwidget.h"
#include "menu/widgets/cvarcoloreditwidget.h"
#include "menu/widgets/cvarinlinelistwidget.h"
#include "menu/widgets/cvarlineeditwidget.h"
#include "menu/widgets/cvarsliderwidget.h"
Expand Down Expand Up @@ -339,7 +339,7 @@ void Hu_MenuInitColorWidgetPage()
Page *page = Hu_MenuAddPage(new Page("ColorWidget", origin, MPF_NEVER_SCROLL, NULL, Hu_MenuColorWidgetCmdResponder));
page->setPredefinedFont(MENU_FONT1, FID(GF_FONTA));

page->addWidget(new ColorPreviewWidget(Vector4f(), true))
page->addWidget(new ColorEditWidget(Vector4f(), true))
.setPreviewDimensions(Vector2i(SCREENHEIGHT / 7, SCREENHEIGHT / 7))
.setFlags(Widget::Id0 | Widget::NoFocus);

Expand Down Expand Up @@ -1258,9 +1258,9 @@ void Hu_MenuInitHUDOptionsPage()
page->addWidget(new LabelWidget("Color"))
.setGroup(2);

page->addWidget(new CVarColorPreviewWidget("msg-color-r", "msg-color-g", "msg-color-b"))
page->addWidget(new CVarColorEditWidget("msg-color-r", "msg-color-g", "msg-color-b"))
.setGroup(2)
.setAction(Widget::MNA_ACTIVEOUT, CVarColorPreviewWidget_UpdateCVar)
.setAction(Widget::MNA_ACTIVEOUT, CVarColorEditWidget_UpdateCVar)
.setAction(Widget::MNA_ACTIVE, Hu_MenuActivateColorWidget);

page->addWidget(new LabelWidget("Crosshair"))
Expand Down Expand Up @@ -1307,9 +1307,9 @@ void Hu_MenuInitHUDOptionsPage()
page->addWidget(new LabelWidget("Color"))
.setGroup(3);

page->addWidget(new CVarColorPreviewWidget("view-cross-r", "view-cross-g", "view-cross-b"))
page->addWidget(new CVarColorEditWidget("view-cross-r", "view-cross-g", "view-cross-b"))
.setGroup(3)
.setAction(Widget::MNA_ACTIVEOUT, CVarColorPreviewWidget_UpdateCVar)
.setAction(Widget::MNA_ACTIVEOUT, CVarColorEditWidget_UpdateCVar)
.setAction(Widget::MNA_ACTIVE, Hu_MenuActivateColorWidget);

#if __JDOOM__ || __JHERETIC__ || __JHEXEN__
Expand Down Expand Up @@ -1396,9 +1396,9 @@ void Hu_MenuInitHUDOptionsPage()
page->addWidget(new LabelWidget("Text Color"))
.setGroup(6);

page->addWidget(new CVarColorPreviewWidget("hud-color-r", "hud-color-g", "hud-color-b", "hud-color-a", Vector4f(), true))
page->addWidget(new CVarColorEditWidget("hud-color-r", "hud-color-g", "hud-color-b", "hud-color-a", Vector4f(), true))
.setGroup(6)
.setAction(Widget::MNA_ACTIVEOUT, CVarColorPreviewWidget_UpdateCVar)
.setAction(Widget::MNA_ACTIVEOUT, CVarColorEditWidget_UpdateCVar)
.setAction(Widget::MNA_ACTIVE, Hu_MenuActivateColorWidget);

#if __JHEXEN__
Expand Down Expand Up @@ -1528,31 +1528,31 @@ void Hu_MenuInitAutomapOptionsPage()
<< new ListWidgetItem("Always", 2));

page->addWidget(new LabelWidget("Wall"));
page->addWidget(new CVarColorPreviewWidget("map-wall-r", "map-wall-g", "map-wall-b"))
page->addWidget(new CVarColorEditWidget("map-wall-r", "map-wall-g", "map-wall-b"))
.setShortcut('w')
.setAction(Widget::MNA_ACTIVE, Hu_MenuActivateColorWidget);

page->addWidget(new LabelWidget("Floor Height Change"));
page->addWidget(new CVarColorPreviewWidget("map-wall-floorchange-r", "map-wall-floorchange-g", "map-wall-floorchange-b"))
page->addWidget(new CVarColorEditWidget("map-wall-floorchange-r", "map-wall-floorchange-g", "map-wall-floorchange-b"))
.setShortcut('f')
.setAction(Widget::MNA_ACTIVE, Hu_MenuActivateColorWidget);

page->addWidget(new LabelWidget("Ceiling Height Change"));
page->addWidget(new CVarColorPreviewWidget("map-wall-ceilingchange-r", "map-wall-ceilingchange-g", "map-wall-ceilingchange-b"))
page->addWidget(new CVarColorEditWidget("map-wall-ceilingchange-r", "map-wall-ceilingchange-g", "map-wall-ceilingchange-b"))
.setAction(Widget::MNA_ACTIVE, Hu_MenuActivateColorWidget);

page->addWidget(new LabelWidget("Unseen"));
page->addWidget(new CVarColorPreviewWidget("map-wall-unseen-r", "map-wall-unseen-g", "map-wall-unseen-b"))
page->addWidget(new CVarColorEditWidget("map-wall-unseen-r", "map-wall-unseen-g", "map-wall-unseen-b"))
.setShortcut('u')
.setAction(Widget::MNA_ACTIVE, Hu_MenuActivateColorWidget);

page->addWidget(new LabelWidget("Thing"));
page->addWidget(new CVarColorPreviewWidget("map-mobj-r", "map-mobj-g", "map-mobj-b"))
page->addWidget(new CVarColorEditWidget("map-mobj-r", "map-mobj-g", "map-mobj-b"))
.setShortcut('t')
.setAction(Widget::MNA_ACTIVE, Hu_MenuActivateColorWidget);

page->addWidget(new LabelWidget("Background"));
page->addWidget(new CVarColorPreviewWidget("map-background-r", "map-background-g", "map-background-b"))
page->addWidget(new CVarColorEditWidget("map-background-r", "map-background-g", "map-background-b"))
.setShortcut('b')
.setAction(Widget::MNA_ACTIVE, Hu_MenuActivateColorWidget);
}
Expand Down Expand Up @@ -2295,7 +2295,7 @@ void Hu_MenuDrawer()
bool showFocusCursor = true;
if(focused && focused->isActive())
{
if(focused->is<ColorPreviewWidget>() || focused->is<InputBindingWidget>())
if(focused->is<ColorEditWidget>() || focused->is<InputBindingWidget>())
{
showFocusCursor = false;
}
Expand All @@ -2318,7 +2318,7 @@ void Hu_MenuDrawer()
// Drawing any overlays?
if(focused && focused->isActive())
{
if(focused->is<ColorPreviewWidget>())
if(focused->is<ColorEditWidget>())
{
drawOverlayBackground(OVERLAY_DARKEN);
GL_BeginBorderedProjection(&bp);
Expand Down Expand Up @@ -2411,11 +2411,11 @@ int Hu_MenuColorWidgetCmdResponder(Page *page, menucommand_e cmd)

case MCMD_SELECT: {
Widget *wi = static_cast<Widget *>(page->userValue().value<void *>());
ColorPreviewWidget &cbox = wi->as<ColorPreviewWidget>();
ColorEditWidget &cbox = wi->as<ColorEditWidget>();
cbox.setFlags(Widget::Active, UnsetFlags);
S_LocalSound(SFX_MENU_ACCEPT, NULL);
colorWidgetActive = false;
cbox.setColor(page->findWidget(Widget::Id0).as<ColorPreviewWidget>().color(), 0);
cbox.setColor(page->findWidget(Widget::Id0).as<ColorEditWidget>().color(), 0);

/// @kludge We should re-focus on the object instead.
cursorAngle = 0; // Stop cursor rotation animation dead (don't rewind).
Expand All @@ -2439,7 +2439,7 @@ static menucommand_e translateCommand(menucommand_e cmd)
if(Widget *wi = Hu_MenuPage().focusWidget())
{
if(wi->isActive() &&
(wi->is<LineEditWidget>() || wi->is<ListWidget>() || wi->is<ColorPreviewWidget>()))
(wi->is<LineEditWidget>() || wi->is<ListWidget>() || wi->is<ColorEditWidget>()))
{
cmd = MCMD_NAV_OUT;
}
Expand Down Expand Up @@ -2818,10 +2818,10 @@ void Hu_MenuActivateColorWidget(Widget *wi, Widget::mn_actionid_t action)
{
if(action != Widget::MNA_ACTIVE) return;

ColorPreviewWidget &cbox = wi->as<ColorPreviewWidget>();
ColorEditWidget &cbox = wi->as<ColorEditWidget>();

Page &colorWidgetPage = Hu_MenuPage("ColorWidget");
ColorPreviewWidget &cboxMix = colorWidgetPage.findWidget(Widget::Id0).as<ColorPreviewWidget>();
ColorEditWidget &cboxMix = colorWidgetPage.findWidget(Widget::Id0).as<ColorEditWidget>();
SliderWidget &sldrRed = colorWidgetPage.findWidget(Widget::Id1).as<SliderWidget>();
SliderWidget &sldrGreen = colorWidgetPage.findWidget(Widget::Id2).as<SliderWidget>();
SliderWidget &sldrBlue = colorWidgetPage.findWidget(Widget::Id3).as<SliderWidget>();
Expand Down Expand Up @@ -2931,7 +2931,7 @@ void Hu_MenuUpdateColorWidgetColor(Widget *wi, Widget::mn_actionid_t action)

SliderWidget &sldr = wi->as<SliderWidget>();
float value = sldr.value();
ColorPreviewWidget &cboxMix = Hu_MenuPage("ColorWidget").findWidget(Widget::Id0).as<ColorPreviewWidget>();
ColorEditWidget &cboxMix = Hu_MenuPage("ColorWidget").findWidget(Widget::Id0).as<ColorEditWidget>();

int const component = wi->userValue2().toInt();
switch(component)
Expand Down
6 changes: 3 additions & 3 deletions doomsday/plugins/common/src/menu/page.cpp
Expand Up @@ -25,7 +25,7 @@

/// @todo Page should not need knowledge of Widget specializations - remove all.
#include "menu/widgets/buttonwidget.h"
#include "menu/widgets/cvarcolorpreviewwidget.h"
#include "menu/widgets/cvarcoloreditwidget.h"
#include "menu/widgets/cvarinlinelistwidget.h"
#include "menu/widgets/cvarlineeditwidget.h"
#include "menu/widgets/cvarsliderwidget.h"
Expand Down Expand Up @@ -274,7 +274,7 @@ void Page::applyLayout()
if(widgetIsDrawable(nextWi) &&
(nextWi->is<ButtonWidget>() ||
nextWi->is<InlineListWidget>() ||
nextWi->is<ColorPreviewWidget>() ||
nextWi->is<ColorEditWidget>() ||
nextWi->is<InputBindingWidget>() ||
nextWi->is<CVarTextualSliderWidget>()))
{
Expand Down Expand Up @@ -755,7 +755,7 @@ void Page::updateWidgets()
value = Con_GetInteger(sldr->cvarPath());
sldr->setValue(value);
}
if(CVarColorPreviewWidget *cbox = wi->maybeAs<CVarColorPreviewWidget>())
if(CVarColorEditWidget *cbox = wi->maybeAs<CVarColorEditWidget>())
{
cbox->setColor(Vector4f(Con_GetFloat(cbox->redCVarPath()),
Con_GetFloat(cbox->greenCVarPath()),
Expand Down

0 comments on commit 7502fad

Please sign in to comment.