Skip to content

Commit

Permalink
Updated viewer to use the more consistent Tacent tColour names.
Browse files Browse the repository at this point in the history
  • Loading branch information
bluescan committed Jan 12, 2024
1 parent 66601aa commit da96fdb
Show file tree
Hide file tree
Showing 14 changed files with 121 additions and 117 deletions.
2 changes: 1 addition & 1 deletion Contrib/imgui/imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4534,7 +4534,7 @@ void ImGui::NewFrame()
g.DragDropWithinTarget = false;
g.DragDropHoldJustPressedId = 0;

// Close popups on focus lost (currently @wip/opt-in)
// Close popups on focus lost (currently wip/opt-in)
//if (g.IO.AppFocusLost)
// ClosePopupsExceptModals();

Expand Down
20 changes: 10 additions & 10 deletions Src/ColourDialogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ void Viewer::ShowPixelEditorOverlay(bool* popen)
ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoScrollbar;

static bool live = true;
static tColourf floatCol = tColourf::black;
static tColourf floatColReset = tColourf::black;
static tColour4f floatCol = tColour4f::black;
static tColour4f floatColReset = tColour4f::black;
if (ImGui::Begin("Edit Pixel", popen, flags))
{
float buttonWidth = Gutil::GetUIParamScaled(76.0f, 2.5f);
Expand All @@ -78,13 +78,13 @@ void Viewer::ShowPixelEditorOverlay(bool* popen)
floatColReset.Set(Viewer::PixelColour);
}

tColourf origCol = floatCol;
tColour4f origCol = floatCol;
if ((ImGui::ColorPicker4("Colour", floatCol.E, ImGuiColorEditFlags_AlphaBar | ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_AlphaPreviewHalf), floatColReset.E) && (floatCol != origCol))
{
if (live)
{
CurrImage->Unbind();
tColouri col; col.Set(floatCol);
tColour4b col; col.Set(floatCol);

// Don't push undo steps if we're dragging around the cursor.
CurrImage->SetPixelColour(Viewer::CursorX, Viewer::CursorY, col, false, true);
Expand All @@ -103,7 +103,7 @@ void Viewer::ShowPixelEditorOverlay(bool* popen)
if (live)
{
CurrImage->Unbind();
tColouri col; col.Set(floatColReset);
tColour4b col; col.Set(floatColReset);
CurrImage->SetPixelColour(Viewer::CursorX, Viewer::CursorY, col, true, true);
CurrImage->Bind();
Gutil::SetWindowTitle();
Expand All @@ -119,7 +119,7 @@ void Viewer::ShowPixelEditorOverlay(bool* popen)
if (!live && ImGui::Button("Apply", tVector2(buttonWidth, 0.0f)))
{
CurrImage->Unbind();
tColouri col; col.Set(floatCol);
tColour4b col; col.Set(floatCol);
CurrImage->SetPixelColour(Viewer::CursorX, Viewer::CursorY, col, true);
CurrImage->Bind();
Gutil::SetWindowTitle();
Expand All @@ -130,7 +130,7 @@ void Viewer::ShowPixelEditorOverlay(bool* popen)
if (popen && (*popen == false) && live)
{
CurrImage->Unbind();
tColouri col;
tColour4b col;
col.Set(floatColReset);
CurrImage->SetPixelColour(Viewer::CursorX, Viewer::CursorY, col, false, true);
col.Set(floatCol);
Expand Down Expand Up @@ -218,7 +218,7 @@ void Viewer::ShowChannelFilterOverlay(bool* popen)
float buttonWidth = Gutil::GetUIParamScaled(120.0f, 2.5f);

Config::ProfileData& profile = Config::GetProfileData();
tColourf floatCol(profile.BackgroundColour);
tColour4f floatCol(profile.BackgroundColour);
if (ImGui::ColorEdit3("##Background", floatCol.E, ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_PickerHueBar))
{
profile.BackgroundColour.Set(floatCol);
Expand Down Expand Up @@ -251,7 +251,7 @@ void Viewer::ShowChannelFilterOverlay(bool* popen)
if (ImGui::Button("Max Selected", tVector2(buttonWidth, 0.0f)))
{
CurrImage->Unbind();
tColouri full(255, 255, 255, 255);
tColour4b full(255, 255, 255, 255);
CurrImage->SetAllPixels(full, channels);
CurrImage->Bind();
Gutil::SetWindowTitle();
Expand All @@ -262,7 +262,7 @@ void Viewer::ShowChannelFilterOverlay(bool* popen)
if (ImGui::Button("Zero Selected", tVector2(buttonWidth, 0.0f)))
{
CurrImage->Unbind();
tColouri zero(0, 0, 0, 0);
tColour4b zero(0, 0, 0, 0);
CurrImage->SetAllPixels(zero, channels);
CurrImage->Bind();
Gutil::SetWindowTitle();
Expand Down
30 changes: 15 additions & 15 deletions Src/CommandOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ namespace Command
// to RGBA, or a predefined name: black, white, grey, red, green, blue, yellow, cyan, magenta, or trans
// (transparent black). If the string is not of this form, colour is left unmodified. You may set colour as your
// default colour before calling this. Returns true if colour was modified.
bool ParseColour(tColour4i& colour, const tString& strCol);
bool ParseColour(tColour4b& colour, const tString& strCol);

// Parses chanStr as a set of channels. The string may contain the characters RGBA in any order and in upper or
// lower case. If none of these characters are set, channels is left unmodified and false is returned.
bool ParseChannels(comp_t& channels, const tString& chanStr);
}


bool Command::ParseColour(tColour4i& colour, const tString& colStr)
bool Command::ParseColour(tColour4b& colour, const tString& colStr)
{
if (colStr[0] == '#')
{
Expand All @@ -62,16 +62,16 @@ bool Command::ParseColour(tColour4i& colour, const tString& colStr)

switch (tHash::tHashString(colStr.Chr()))
{
case tHash::tHashCT("black"): colour = tColour4i::black; return true;
case tHash::tHashCT("white"): colour = tColour4i::white; return true;
case tHash::tHashCT("grey"): colour = tColour4i::grey; return true;
case tHash::tHashCT("red"): colour = tColour4i::red; return true;
case tHash::tHashCT("green"): colour = tColour4i::green; return true;
case tHash::tHashCT("blue"): colour = tColour4i::blue; return true;
case tHash::tHashCT("yellow"): colour = tColour4i::yellow; return true;
case tHash::tHashCT("cyan"): colour = tColour4i::cyan; return true;
case tHash::tHashCT("magenta"): colour = tColour4i::magenta; return true;
case tHash::tHashCT("trans"): colour = tColour4i::transparent; return true;
case tHash::tHashCT("black"): colour = tColour4b::black; return true;
case tHash::tHashCT("white"): colour = tColour4b::white; return true;
case tHash::tHashCT("grey"): colour = tColour4b::grey; return true;
case tHash::tHashCT("red"): colour = tColour4b::red; return true;
case tHash::tHashCT("green"): colour = tColour4b::green; return true;
case tHash::tHashCT("blue"): colour = tColour4b::blue; return true;
case tHash::tHashCT("yellow"): colour = tColour4b::yellow; return true;
case tHash::tHashCT("cyan"): colour = tColour4b::cyan; return true;
case tHash::tHashCT("magenta"): colour = tColour4b::magenta; return true;
case tHash::tHashCT("trans"): colour = tColour4b::transparent; return true;
}

return false;
Expand Down Expand Up @@ -141,8 +141,8 @@ bool Command::OperationPixel::Apply(Viewer::Image& image)
int x = tMath::tMod(X, w);
int y = tMath::tMod(Y, h);

tColour4i setCol = PixelColour;
tColour4i pixCol = image.GetPixel(x, y);
tColour4b setCol = PixelColour;
tColour4b pixCol = image.GetPixel(x, y);
if (Channels & tCompBit_R) pixCol.R = setCol.R;
if (Channels & tCompBit_G) pixCol.G = setCol.G;
if (Channels & tCompBit_B) pixCol.B = setCol.B;
Expand Down Expand Up @@ -529,7 +529,7 @@ Command::OperationDeborder::OperationDeborder(const tString& argsStr)
bool Command::OperationDeborder::Apply(Viewer::Image& image)
{
tAssert(Valid);
tColour4i testCol = TestColour;
tColour4b testCol = TestColour;

// Do we need to retrieve test colour from the origin (bottom-left 0,0) of the image?
if (!UseTestColour)
Expand Down
16 changes: 8 additions & 8 deletions Src/CommandOps.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct OperationPixel : public Operation
OperationPixel(const tString& args);
int X = 0;
int Y = 0;
tColour4i PixelColour = tColour4i::black; // Optional.
tColour4b PixelColour = tColour4b::black; // Optional.
comp_t Channels = tCompBit_RGBA; // Optional.

bool Apply(Viewer::Image&) override;
Expand All @@ -64,7 +64,7 @@ struct OperationCanvas : public Operation
int Width = 0;
int Height = 0;
tImage::tPicture::Anchor Anchor = tImage::tPicture::Anchor::MiddleMiddle; // Optional.
tColour4i FillColour = tColour4i::black; // Optional.
tColour4b FillColour = tColour4b::black; // Optional.
int AnchorX = -1; // Optional.
int AnchorY = -1; // Optional.

Expand All @@ -80,7 +80,7 @@ struct OperationAspect : public Operation
enum class AspectMode { Crop, Letterbox };
AspectMode Mode = AspectMode::Crop;
tImage::tPicture::Anchor Anchor = tImage::tPicture::Anchor::MiddleMiddle; // Optional.
tColour4i FillColour = tColour4i::black; // Optional.
tColour4b FillColour = tColour4b::black; // Optional.
int AnchorX = -1; // Optional.
int AnchorY = -1; // Optional.

Expand All @@ -92,7 +92,7 @@ struct OperationDeborder : public Operation
{
OperationDeborder(const tString& args);
bool UseTestColour = false;
tColour4i TestColour = tColour4i::black; // Optional.
tColour4b TestColour = tColour4b::black; // Optional.
comp_t Channels = tCompBit_RGBA; // Optional.

bool Apply(Viewer::Image&) override;
Expand All @@ -108,7 +108,7 @@ struct OperationCrop : public Operation
int OriginY = 0;
int WidthOrMaxX = 4;
int HeightOrMaxY = 4;
tColour4i FillColour = tColour4i::transparent; // Optional.
tColour4b FillColour = tColour4b::transparent; // Optional.

bool Apply(Viewer::Image&) override;
};
Expand Down Expand Up @@ -141,7 +141,7 @@ struct OperationRotate : public Operation
// Valid None Up/down scaling. Use alternate (sharper) downscaling scheme (possibe pad + 2X ScaleHalf).
tImage::tResampleFilter FilterUp = tImage::tResampleFilter::Bilinear; // Optional.
tImage::tResampleFilter FilterDown = tImage::tResampleFilter::None; // Optional.
tColour4i FillColour = tColour4i::black; // Optional.
tColour4b FillColour = tColour4b::black; // Optional.

bool Apply(Viewer::Image&) override;
};
Expand Down Expand Up @@ -219,7 +219,7 @@ struct OperationChannel : public Operation
};
ChanMode Mode = ChanMode::Blend; // Optional.
comp_t Channels = tCompBit_RGBA; // Optional.
tColour4i Colour = tColour4i::black; // Optional.
tColour4b Colour = tColour4b::black; // Optional.

bool Apply(Viewer::Image&) override;
};
Expand Down Expand Up @@ -288,7 +288,7 @@ struct PostOperationContact : public PostOperation

int Columns = 0;
int Rows = 0;
tColour4i FillColour = tColour4i::transparent;
tColour4b FillColour = tColour4b::transparent;
tString SubFolder; // Relative to the current dir.
tString BaseName;

Expand Down
6 changes: 3 additions & 3 deletions Src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,8 @@ void Config::ProfileData::Reset(Viewer::Profile profile, uint32 categories)
SaveFileApngDurMultiFrame = 33;
SaveFileTiffDurMultiFrame = 33;
SaveAllSizeMode = 0;
FillColour = tColouri::black;
FillColourContact = tColouri::transparent;
FillColour = tColour4b::black;
FillColourContact = tColour4b::transparent;
LevelsPowerMidGamma = true;
LevelsAutoMidPoint = false;
LevelsLogarithmicHisto = true;
Expand All @@ -397,7 +397,7 @@ void Config::ProfileData::Reset(Viewer::Profile profile, uint32 categories)
{
BackgroundStyle = (profile == Profile::Basic) || (profile == Profile::Kiosk) ? int(BackgroundStyleEnum::None) : int(BackgroundStyleEnum::Checkerboard);
BackgroundCheckerboxSize = 16;
BackgroundColour = tColouri::black;
BackgroundColour = tColour4b::black;
BackgroundExtend = false;
OnScreenControls = (profile == Profile::Basic) || (profile == Profile::Kiosk) ? int(OnScreenEnum::Never) : int(OnScreenEnum::Auto);
ShowNavFilenameAlways = false;
Expand Down
6 changes: 3 additions & 3 deletions Src/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ struct ProfileData
int BackgroundStyle;
BackgroundStyleEnum GetBackgroundStyle() const { return BackgroundStyleEnum(BackgroundStyle); }
int BackgroundCheckerboxSize;
tColouri BackgroundColour; // Only used if BackgroundStyle is SolidColour.
tColour4b BackgroundColour; // Only used if BackgroundStyle is SolidColour.
bool BackgroundExtend; // Extend background past image bounds.

enum class OnScreenEnum
Expand Down Expand Up @@ -252,8 +252,8 @@ struct ProfileData
int SaveAllSizeMode;
SizeModeEnum GetSaveAllSizeMode() const { return SizeModeEnum(SaveAllSizeMode); }

tColouri FillColour;
tColouri FillColourContact;
tColour4b FillColour;
tColour4b FillColourContact;

bool LevelsPowerMidGamma;
bool LevelsAutoMidPoint;
Expand Down
18 changes: 9 additions & 9 deletions Src/Crop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ namespace Viewer
{
CropWidget CropGizmo;

tColour CropHovCol (0.25f, 0.48f, 1.00f, 1.00f);
tColour CropCol (0.24f, 0.24f, 0.24f, 1.00f);
tColour CropSelCol (0.98f, 0.98f, 0.98f, 1.00f);
const int CropMin = 4;
tColour4f CropHovCol (0.25f, 0.48f, 1.00f, 1.00f);
tColour4f CropCol (0.24f, 0.24f, 0.24f, 1.00f);
tColour4f CropSelCol (0.98f, 0.98f, 0.98f, 1.00f);
const int CropMin = 4;
}


Expand Down Expand Up @@ -695,7 +695,7 @@ void Viewer::CropWidget::DrawMatt(const tVector4& imext, const tVector2& uvoffse

void Viewer::CropWidget::DrawLines()
{
glColor4fv(tColourf::white.E);
glColor4fv(tColour4f::white.E);
float l = (LineL.GetScreenVal());
float r = (LineR.GetScreenVal()) - 1.0f;
float b = (LineB.GetScreenVal());
Expand Down Expand Up @@ -729,7 +729,7 @@ void Viewer::CropWidget::DrawLines()
glVertex2f(l, h);
glVertex2f(r, h);

glColor4fv(tColourf::white.E);
glColor4fv(tColour4f::white.E);
glEnd();
}

Expand All @@ -743,7 +743,7 @@ void Viewer::CropWidget::DrawHandles()
float h = (l+r)/2.0f;
float v = (b+t)/2.0f;
bool anyPressed = LineL.Pressed || LineR.Pressed || LineB.Pressed || LineT.Pressed;
tColour col;
tColour4f col;
glBegin(GL_QUADS);

// TL
Expand Down Expand Up @@ -836,7 +836,7 @@ void Viewer::CropWidget::DrawHandles()
glVertex2f(h+4, v+4);
glVertex2f(h-4, v+4);

glColor4fv(tColourf::white.E);
glColor4fv(tColour4f::white.E);
glEnd();
}

Expand Down Expand Up @@ -1087,7 +1087,7 @@ void Viewer::ShowCropPopup(const tVector4& lrtb, const tVector2& uvoffset)
newH = tClampMin(newH, CropMin);

CurrImage->Unbind();
CurrImage->Crop(newW, newH, minX, minY, tColouri::transparent);
CurrImage->Crop(newW, newH, minX, minY, tColour4b::transparent);
CurrImage->Bind();
Gutil::SetWindowTitle();
CropMode = false;
Expand Down
4 changes: 2 additions & 2 deletions Src/Details.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void Viewer::ShowImageDetailsOverlay(bool* popen, float x, float y, float w, flo

if (CurrImage)
{
tColourf floatCol(PixelColour);
tColour4f floatCol(PixelColour);
tVector4 colV4(floatCol.R, floatCol.G, floatCol.B, floatCol.A);

float colourButtonSize = Gutil::GetUIParamScaled(15.0f, 2.5f);
Expand Down Expand Up @@ -188,7 +188,7 @@ void Viewer::ShowImageDetailsOverlay(bool* popen, float x, float y, float w, flo

void Viewer::ColourCopyAs()
{
tColourf floatCol(PixelColour);
tColour4f floatCol(PixelColour);
ImGui::Text("Copy As...");
int ri = PixelColour.R; int gi = PixelColour.G; int bi = PixelColour.B; int ai = PixelColour.A;
float rf = floatCol.R; float gf = floatCol.G; float bf = floatCol.B; float af = floatCol.A;
Expand Down
Loading

0 comments on commit da96fdb

Please sign in to comment.