Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
35cad11
commit c66e6a6
Showing
8 changed files
with
735 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* Reverse Engineer's Hex Editor | ||
* Copyright (C) 2024 Daniel Collins <solemnwarning@solemnwarning.net> | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 as published by | ||
* the Free Software Foundation. | ||
* | ||
* 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. | ||
*/ | ||
|
||
#include "App.hpp" | ||
#include "ByteColourMap.hpp" | ||
|
||
REHex::ByteColourMap::ByteColourMap() {} | ||
|
||
// REHex::ByteColourMap::ByteColourMap(const wxConfigBase *config) | ||
|
||
void REHex::ByteColourMap::set_colour(unsigned char byte, int colour1, int colour2, int colour_delta_steps, int colour_delta_pos) | ||
{ | ||
auto &elem = bytes[byte]; | ||
|
||
assert(colour_delta_steps >= colour_delta_pos); | ||
|
||
elem.colour1 = colour1; | ||
elem.colour2 = colour2; | ||
elem.colour_delta_steps = colour_delta_steps; | ||
elem.colour_delta_pos = colour_delta_pos; | ||
} | ||
|
||
wxColour REHex::ByteColourMap::get_colour(unsigned char byte) const | ||
{ | ||
auto &elem = bytes[byte]; | ||
|
||
return elem.get_colour(); | ||
} | ||
|
||
const REHex::ByteColourMap::Value &REHex::ByteColourMap::get_value(unsigned char byte) const | ||
{ | ||
return bytes[byte]; | ||
} | ||
|
||
bool REHex::ByteColourMap::Value::is_single() const | ||
{ | ||
return colour_delta_steps == 0; | ||
} | ||
|
||
bool REHex::ByteColourMap::Value::is_start() const | ||
{ | ||
return colour_delta_pos == 0 && colour_delta_steps > 0; | ||
} | ||
|
||
bool REHex::ByteColourMap::Value::is_end() const | ||
{ | ||
return colour_delta_pos == colour_delta_steps && colour_delta_steps > 0; | ||
} | ||
|
||
wxColour REHex::ByteColourMap::Value::get_colour() const | ||
{ | ||
wxColour c1, c2; | ||
|
||
if(colour1 >= 0 && colour1 <= Palette::PAL_MAX) | ||
{ | ||
c1 = (*active_palette)[colour1]; | ||
} | ||
else if(colour1 >= Palette::PAL_INVALID && colour2 < (Palette::PAL_INVALID + HighlightColourMap::MAX_NUM)) | ||
{ | ||
HighlightColourMap highlight_colours = wxGetApp().settings->get_highlight_colours(); | ||
c1 = highlight_colours[colour1 - Palette::PAL_INVALID].primary_colour; | ||
} | ||
else{ | ||
c1 = (*active_palette)[Palette::PAL_NORMAL_TEXT_FG]; | ||
} | ||
|
||
if(colour_delta_steps == 0) | ||
{ | ||
return c1; | ||
} | ||
|
||
if(colour2 >= 0 && colour2 <= Palette::PAL_MAX) | ||
{ | ||
c2 = (*active_palette)[colour2]; | ||
} | ||
else if(colour2 >= Palette::PAL_INVALID && colour2 < (Palette::PAL_INVALID + HighlightColourMap::MAX_NUM)) | ||
{ | ||
HighlightColourMap highlight_colours = wxGetApp().settings->get_highlight_colours(); | ||
c2 = highlight_colours[colour2 - Palette::PAL_INVALID].primary_colour; | ||
} | ||
else{ | ||
c2 = (*active_palette)[Palette::PAL_NORMAL_TEXT_FG]; | ||
} | ||
|
||
float alpha = (float)(colour_delta_pos) / (float)(colour_delta_steps); | ||
|
||
unsigned char r = wxColour::AlphaBlend(c2.Red(), c1.Red(), alpha); | ||
unsigned char g = wxColour::AlphaBlend(c2.Green(), c1.Green(), alpha); | ||
unsigned char b = wxColour::AlphaBlend(c2.Blue(), c1.Blue(), alpha); | ||
|
||
return wxColour(r, g, b); | ||
} | ||
|
||
// void REHex::ByteColourMap::save(wxConfigBase *config); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* Reverse Engineer's Hex Editor | ||
* Copyright (C) 2024 Daniel Collins <solemnwarning@solemnwarning.net> | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 as published by | ||
* the Free Software Foundation. | ||
* | ||
* 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. | ||
*/ | ||
|
||
#ifndef REHEX_BYTECOLOURMAP_HPP | ||
#define REHEX_BYTECOLOURMAP_HPP | ||
|
||
#include <wx/colour.h> | ||
#include <wx/config.h> | ||
|
||
#include "Palette.hpp" | ||
|
||
namespace REHex | ||
{ | ||
class ByteColourMap | ||
{ | ||
public: | ||
struct Value | ||
{ | ||
int colour1; /**< 0..PAL_MAX = palette colour, PAL_INVALID+n = highlight colour n */ | ||
int colour2; /**< 0..PAL_MAX = palette colour, PAL_INVALID+n = highlight colour n */ | ||
|
||
int colour_delta_steps; | ||
int colour_delta_pos; | ||
|
||
Value(): | ||
colour1(Palette::PAL_NORMAL_TEXT_FG), | ||
colour2(Palette::PAL_NORMAL_TEXT_FG), | ||
colour_delta_steps(0), | ||
colour_delta_pos(0) {} | ||
|
||
bool is_single() const; | ||
bool is_start() const; | ||
bool is_end() const; | ||
|
||
wxColour get_colour() const; | ||
}; | ||
|
||
private: | ||
Value bytes[256]; | ||
|
||
public: | ||
ByteColourMap(); | ||
ByteColourMap(const wxConfigBase *config); | ||
|
||
void set_colour(unsigned char byte, int colour1, int colour2, int colour_delta_steps, int colour_delta_pos); | ||
|
||
wxColour get_colour(unsigned char byte) const; | ||
|
||
const Value &get_value(unsigned char byte) const; | ||
|
||
void save(wxConfigBase *config); | ||
}; | ||
} | ||
|
||
#endif /* !REHEX_BYTECOLOURMAP_HPP */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.